Example usage for org.apache.commons.lang3 StringUtils equals

List of usage examples for org.apache.commons.lang3 StringUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils equals.

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:com.glaf.ui.web.springmvc.MxPanelController.java

@RequestMapping
public ModelAndView list(ModelMap modelMap, HttpServletRequest request) {
    RequestUtils.setRequestParameterToAttribute(request);
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    List<Panel> panels = null;
    String actorId = loginContext.getActorId();
    String isSystem = request.getParameter("isSystem");

    if (loginContext.isSystemAdministrator() && StringUtils.equals(isSystem, "true")) {
        panels = panelService.getSystemPanels();
    } else {//from www  .  java2s. com
        panels = panelService.getPanels(actorId);
    }
    modelMap.put("panels", panels);

    String jx_view = request.getParameter("jx_view");

    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view, modelMap);
    }

    String x_view = ViewProperties.getString("sys_panel.list");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/modules/ui/panel/list", modelMap);
}

From source file:com.glaf.core.web.springmvc.MxSystemSchedulerController.java

@ResponseBody
@RequestMapping("/delete")
public byte[] delete(HttpServletRequest request, ModelMap modelMap) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    String id = RequestUtils.getString(request, "id");
    String ids = request.getParameter("ids");
    if (StringUtils.isNotEmpty(ids)) {
        StringTokenizer token = new StringTokenizer(ids, ",");
        while (token.hasMoreTokens()) {
            String x = token.nextToken();
            if (StringUtils.isNotEmpty(x)) {
                Scheduler scheduler = sysSchedulerService.getSchedulerByTaskId(String.valueOf(x));
                if (scheduler != null && (StringUtils.equals(scheduler.getCreateBy(), loginContext.getActorId())
                        || loginContext.isSystemAdministrator())) {
                    QuartzUtils.stop(scheduler.getId());
                    schedulerLogService.deleteSchedulerLogByTaskId(id);
                    sysSchedulerService.deleteScheduler(id);
                }/*from  w ww  . j av a  2 s. c  o m*/
            }
        }
        return ResponseUtils.responseResult(true);
    } else if (id != null) {
        Scheduler scheduler = sysSchedulerService.getSchedulerByTaskId(String.valueOf(id));
        if (scheduler != null && (StringUtils.equals(scheduler.getCreateBy(), loginContext.getActorId())
                || loginContext.isSystemAdministrator())) {
            QuartzUtils.stop(scheduler.getId());
            schedulerLogService.deleteSchedulerLogByTaskId(id);
            sysSchedulerService.deleteScheduler(scheduler.getId());
            return ResponseUtils.responseResult(true);
        }
    }
    return ResponseUtils.responseResult(false);
}

From source file:com.glaf.core.service.impl.MxSysKeyServiceImpl.java

@Transactional
public void save(SysKey sysKey) {
    if (StringUtils.isEmpty(sysKey.getId())) {
        sysKey.setId(idGenerator.getNextId("SYS_KEY"));
    }/* w ww  .j  a v a  2 s  .  c o  m*/
    sysKey.setCreateDate(new Date());
    if (StringUtils.equals(DBUtils.POSTGRESQL, DBConnectionFactory.getDatabaseType())) {
        sysKeyMapper.insertSysKey(sysKey);
    } else {
        sysKeyMapper.insertSysKey_postgres(sysKey);
    }
}

From source file:io.wcm.wcm.commons.util.Template.java

/**
 * Lookup a template by the given template path.
 * @param templatePath Path of template//from w  ww .  j  a va 2s  .c  o  m
 * @return The {@link TemplatePathInfo} instance or null for unknown template paths
 */
@SafeVarargs
public static <E extends Enum<E> & TemplatePathInfo> TemplatePathInfo forTemplatePath(String templatePath,
        Class<E>... templateEnums) {
    if (templatePath == null || templateEnums == null) {
        return null;
    }
    for (Class<E> templateEnum : templateEnums) {
        for (E template : EnumSet.allOf(templateEnum)) {
            if (StringUtils.equals(template.getTemplatePath(), templatePath)) {
                return template;
            }
        }
    }
    return null;
}

From source file:io.wcm.wcm.parsys.componentinfo.impl.ParsysConfigManagerImpl.java

private Collection<ParsysConfig> getParsysConfigs(Resource pageComponentResource) {
    List<ParsysConfig> configs = new ArrayList<>();

    // get first jcr parsys configurations for this page component
    ResourceParsysConfigProvider resourceParsysConfigProvider = new ResourceParsysConfigProvider(
            pageComponentResource);/*from w  w w.  j  ava2  s  .  co m*/
    configs.addAll(resourceParsysConfigProvider.getPathDefs());

    // add osgi parsys configurations
    for (ParsysConfig osgiParsysConfig : osgiParsysConfigs) {
        if (StringUtils.equals(pageComponentResource.getPath(), osgiParsysConfig.getPageComponentPath())) {
            configs.add(osgiParsysConfig);
        }
    }

    return configs;
}

From source file:com.anrisoftware.globalpom.checkfilehash.CheckFileHash.java

private String readExpectedHash(URI hashResource) throws Exception {
    if (StringUtils.equals(hashResource.getScheme(), "md5")) {
        return hashResource.getSchemeSpecificPart();
    } else if (StringUtils.equals(hashResource.getScheme(), "sha1")) {
        return hashResource.getSchemeSpecificPart();
    } else {/*from  ww w  .  j av a2  s  .  co  m*/
        String line = readLines(hashResource.toURL().openStream()).get(0);
        String hash = StringUtils.split(line, SEP)[0];
        return hash;
    }
}

From source file:com.piesky.core.orm.Page.java

/**
 * ???.//from  w  w w . jav  a 2s.  co m
 * 
 * @param order
 *            ?descasc,?','.
 */
public void setOrder(final String order) {
    String lowcaseOrder = StringUtils.lowerCase(order);

    // order?
    String[] orders = StringUtils.split(lowcaseOrder, ',');
    for (String orderStr : orders) {
        if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) {
            throw new IllegalArgumentException("??" + orderStr + "??");
        }
    }

    this.order = lowcaseOrder;
}

From source file:ch.cyberduck.core.s3.S3VersionedObjectListService.java

@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener)
        throws BackgroundException {
    final String prefix = this.createPrefix(directory);
    final Path bucket = containerService.getContainer(directory);
    final AttributedList<Path> children = new AttributedList<Path>();
    try {//from  w ww  . java2 s . c  o  m
        String priorLastKey = null;
        String priorLastVersionId = null;
        do {
            final VersionOrDeleteMarkersChunk chunk = session.getClient().listVersionedObjectsChunked(
                    bucket.getName(), prefix, String.valueOf(Path.DELIMITER),
                    preferences.getInteger("s3.listing.chunksize"), priorLastKey, priorLastVersionId, true);
            // Amazon S3 returns object versions in the order in which they were
            // stored, with the most recently stored returned first.
            final List<BaseVersionOrDeleteMarker> items = Arrays.asList(chunk.getItems());
            int i = 0;
            for (BaseVersionOrDeleteMarker marker : items) {
                final String key = PathNormalizer.normalize(marker.getKey());
                if (String.valueOf(Path.DELIMITER).equals(key)) {
                    log.warn(String.format("Skipping prefix %s", key));
                    continue;
                }
                if (new Path(bucket, key, EnumSet.of(Path.Type.directory)).equals(directory)) {
                    continue;
                }
                final PathAttributes attributes = new PathAttributes();
                if (!StringUtils.equals("null", marker.getVersionId())) {
                    // If you have not enabled versioning, then S3 sets the version ID value to null.
                    attributes.setVersionId(marker.getVersionId());
                }
                attributes.setRevision(++i);
                attributes.setDuplicate((marker.isDeleteMarker() && marker.isLatest()) || !marker.isLatest());
                attributes.setModificationDate(marker.getLastModified().getTime());
                attributes.setRegion(bucket.attributes().getRegion());
                if (marker instanceof S3Version) {
                    final S3Version object = (S3Version) marker;
                    attributes.setSize(object.getSize());
                    if (StringUtils.isNotBlank(object.getEtag())) {
                        attributes.setChecksum(Checksum.parse(object.getEtag()));
                        attributes.setETag(object.getEtag());
                    }
                    if (StringUtils.isNotBlank(object.getStorageClass())) {
                        attributes.setStorageClass(object.getStorageClass());
                    }
                }
                final Path f = new Path(directory, PathNormalizer.name(key), EnumSet.of(Path.Type.file),
                        attributes);
                children.add(f);
            }
            final String[] prefixes = chunk.getCommonPrefixes();
            for (String common : prefixes) {
                if (String.valueOf(Path.DELIMITER).equals(common)) {
                    log.warn(String.format("Skipping prefix %s", common));
                    continue;
                }
                final String key = PathNormalizer.normalize(common);
                if (new Path(bucket, key, EnumSet.of(Path.Type.directory)).equals(directory)) {
                    continue;
                }
                final PathAttributes attributes = new PathAttributes();
                attributes.setRegion(bucket.attributes().getRegion());
                final Path file = new Path(
                        String.format("%s%s%s", bucket.getAbsolute(), String.valueOf(Path.DELIMITER), key),
                        EnumSet.of(Path.Type.directory, Path.Type.placeholder), attributes);
                children.add(file);
            }
            priorLastKey = chunk.getNextKeyMarker();
            priorLastVersionId = chunk.getNextVersionIdMarker();
            listener.chunk(directory, children);
        } while (priorLastKey != null);
        return children;
    } catch (ServiceException e) {
        throw new S3ExceptionMappingService().map("Listing directory {0} failed", e, directory);
    }
}

From source file:cn.com.infcn.ade.common.persistence.Page.java

/**
 * ???.//www.j  a v  a2 s . co m
 * 
 * @param order ?descasc,?','.
 */
public void setOrder(final String order) {
    String lowcaseOrder = StringUtils.lowerCase(order);

    //order?
    String[] orders = StringUtils.split(lowcaseOrder, ',');
    for (String orderStr : orders) {
        if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) {
            throw new IllegalArgumentException("??" + orderStr + "??");
        }
    }

    this.order = lowcaseOrder;
}

From source file:com.mirth.connect.plugins.datatypes.ncpdp.NCPDPReference.java

public String getSegmentIdByName(String description, String version) {
    if (StringUtils.equals(version, VERSION_D0)) {
        for (String key : segmentD0Map.keySet()) {
            if (segmentD0Map.get(key).equals(description)) {
                return key;
            }/*from  w w w.  j  av a2s.co m*/
        }
    } else {
        for (String key : segment51Map.keySet()) {
            if (segment51Map.get(key).equals(description)) {
                return key;
            }
        }
    }

    return description;
}