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

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

Introduction

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

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:com.ning.maven.plugins.dependencyversionscheck.VersionCheckExcludes.java

public boolean matches(Artifact artifact, Version expectedVersion, Version resolvedVersion) {
    return StringUtils.equals(groupId, artifact.getGroupId())
            && StringUtils.equals(artifactId, artifact.getArtifactId())
            && StringUtils.equals(classifier, artifact.getClassifier())
            && StringUtils.equals(type, artifact.getType()) && this.expectedVersion.equals(expectedVersion)
            && this.resolvedVersion.equals(resolvedVersion);
}

From source file:com.edgenius.wiki.search.interceptor.PageIndexInterceptor.java

public void afterReturning(Object retValue, Method method, Object[] args, Object target) throws Throwable {
    //PageService.savePage()
    Page page = null;/*from  w  w  w .  j  a v a 2  s  . c  o  m*/
    String spaceUname = null;
    String removedPageUuid = null;
    boolean needRebuildRss = false;

    if (StringUtils.equals(method.getName(), PageService.savePage)) {
        page = (Page) retValue;
        int reqireSendNotify = (Integer) args[1];
        spaceUname = page.getSpace().getUnixName();
        needRebuildRss = true;

        sendNotifyMessage(page, reqireSendNotify);
    } else if (StringUtils.equals(method.getName(), SpaceService.saveHomepage)) {
        page = (Page) args[1];
        spaceUname = page.getSpace().getUnixName();
        needRebuildRss = true;
    } else if (StringUtils.equals(method.getName(), PageService.copy)) {
        page = (Page) retValue;
        spaceUname = page.getSpace().getUnixName();
        //rebuild target space RSS
        needRebuildRss = true;
    } else if (StringUtils.equals(method.getName(), PageService.removePage)) {
        //new page
        spaceUname = (String) args[0];
        removedPageUuid = (String) args[1];
        page = (Page) retValue;

        sendPageRemoveMessage(removedPageUuid, spaceUname, page);

    } else if (StringUtils.equals(method.getName(), PageService.restorePage)) {
        page = (Page) retValue;
        //Dirty FIX: MQ consumer can not get content correctly since lazy loading reason, initialize here.
        page.getContent().getContent();
        spaceUname = page.getSpace().getUnixName();
        needRebuildRss = true;
    } else if (StringUtils.equals(method.getName(), PageService.restoreHistory)) {
        page = (Page) retValue;
        //Dirty FIX: MQ consumer can not get content correctly since lazy loading reason, initialize here.
        page.getContent().getContent();
        spaceUname = page.getSpace().getUnixName();
        needRebuildRss = true;
    } else if (StringUtils.equals(method.getName(), PageService.move)) {
        //new page
        //also need do delete from index
        String fromSpaceUname = (String) args[0];
        //this flag will build move target space RSS
        spaceUname = (String) args[2];

        if (!StringUtils.equalsIgnoreCase(fromSpaceUname, spaceUname)) {
            page = (Page) retValue;
            removedPageUuid = (String) args[1];
            needRebuildRss = true; //rebuild to  space RSS 
            sendPageRemoveMessage(removedPageUuid, fromSpaceUname, page); //here will remove page RSS from fromSpaceUname
        } else {
            //if move happens in same space, then we need don't refresh index and rss!
            //actually, even no return, all below index and rss service also skipped, here just for easy code. 
            return;
        }
    }

    if (page != null && removedPageUuid == null && !page.isRemoved()) {
        log.info("JMS message send for Page index creating. Title: " + page.getTitle() + ". Uuid:"
                + page.getPageUuid());
        //the come in page bring too many information, such as user permission, roles etc. 
        //in test, the page object is almost 680k in a ~700 user system for admin user.
        //so, as trade-off, low the traffice in MQ, but add more database query in consumer side... 
        IndexMQObject mqObj = new IndexMQObject(IndexMQObject.TYPE_INSERT_PAGE, page.getUid());
        jmsTemplate.convertAndSend(queue, mqObj);

    }
    if (needRebuildRss) {
        //send RSS feed rebuild message
        RSSMQObject mqObj = new RSSMQObject(RSSMQObject.TYPE_REBUILD, spaceUname);
        jmsTemplate.convertAndSend(rssQueue, mqObj);
    }

}

From source file:com.intel.cosbench.driver.operator.Preparer.java

@Override
protected void operate(int idx, int all, Session session) {
    String[] path = null;//  ww  w . ja v a 2s .  c  o  m
    String opTye = getOpType();
    String lastContainer = null;

    while ((path = objScanner.nextObjPath(path, idx, all)) != null) {
        if (createContainer && !StringUtils.equals(lastContainer, path[0])) {
            doInit(path[0], config, session);
            lastContainer = path[0];
        }
        if (path[1] == null)
            continue;
        Random random = session.getRandom();
        long size = sizePicker.pickObjSize(random);
        long len = chunked ? -1 : size;
        RandomInputStream in = new RandomInputStream(size, random, isRandom, hashCheck);
        Sample sample = doWrite(in, len, path[0], path[1], config, session);
        sample.setOpType(opTye);
        session.getListener().onSampleCreated(sample);
    }

    Date now = new Date();
    Result result = new Result(now, opTye, getSampleType(), true);
    session.getListener().onOperationCompleted(result);
}

From source file:com.usergrid.count.common.Count.java

public Count apply(Count count) {
    if (!StringUtils.equals(count.getCounterName(), getCounterName())) {
        throw new IllegalArgumentException("Attempt to apply a counter with a different name");
    }/*from w w  w . j  a  va  2 s  .c o  m*/
    this.value += count.getValue();
    return this;
}

From source file:com.dp2345.controller.mall.member.PasswordController.java

/**
 * /*from  w  w  w  .j av a2 s  .  c om*/
 */
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(String currentPassword, String password, HttpServletRequest request,
        RedirectAttributes redirectAttributes) {
    if (StringUtils.isEmpty(password) || StringUtils.isEmpty(currentPassword)) {
        return ERROR_VIEW;
    }
    if (!isValid(Member.class, "password", password)) {
        return ERROR_VIEW;
    }
    Setting setting = SettingUtils.get();
    if (password.length() < setting.getPasswordMinLength()
            || password.length() > setting.getPasswordMaxLength()) {
        return ERROR_VIEW;
    }
    Member member = memberService.getCurrent();
    if (!StringUtils.equals(DigestUtils.md5Hex(currentPassword), member.getPassword())) {
        return ERROR_VIEW;
    }
    member.setPassword(DigestUtils.md5Hex(password));
    memberService.update(member);
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:edit.jhtml";
}

From source file:edu.mayo.cts2.framework.core.plugin.SupplementalPropetiesLoader.java

@Override
public void afterPropertiesSet() throws Exception {
    File overridesDir = new File(this.configInitializer.getContextConfigDirectory().getPath() + File.separator
            + ConfigConstants.CONFIG_DIRECTORY);

    if (overridesDir.exists()) {
        FileFilter nonDeploymentConfigFiles = new FileFilter() {
            @Override//from  www.  jav  a 2 s.  c  o m
            public boolean accept(File file) {
                return !StringUtils.equals(ConfigConstants.CTS2_DEPLOYMENT_CONFIG_FILE_NAME, file.getName());
            }
        };

        for (File file : overridesDir.listFiles(nonDeploymentConfigFiles)) {
            Properties props = ConfigUtils.loadProperties(file);
            String pid = (String) props.get(Constants.SERVICE_PID);

            if (pid == null) {
                throw new IllegalStateException(
                        "Overriding Properties File must include a " + Constants.SERVICE_PID + " propery.");
            }

            this.overrides.put(pid, props);
        }
    }
}

From source file:com.sammyun.controller.shop.member.PasswordController.java

/**
 * //from  ww  w .j a va 2 s.c  o  m
 */
@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(String currentPassword, String password, HttpServletRequest request,
        RedirectAttributes redirectAttributes) {
    if (StringUtils.isEmpty(password) || StringUtils.isEmpty(currentPassword)) {
        return ERROR_VIEW;
    }
    if (!isValid(Member.class, "password", password)) {
        return ERROR_VIEW;
    }
    Setting setting = SettingUtils.get();
    if (password.length() < setting.getPasswordMinLength()
            || password.length() > setting.getPasswordMaxLength()) {
        return ERROR_VIEW;
    }
    Member member = memberService.getCurrent();
    if (!StringUtils.equals(DigestUtils.md5Hex(currentPassword), member.getPassword())) {
        return ERROR_VIEW;
    }
    member.setPassword(DigestUtils.md5Hex(password));
    memberService.update(member);
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:edit.ct";
}

From source file:com.bluexml.xforms.generator.forms.renderable.classes.RenderableAttribute.java

/**
 * Checks if is the attribute refers to a file field.
 * //from   w ww . j ava 2s.c  o  m
 * @return true, if is file field
 */
private boolean isFileField() {
    return (StringUtils.equals(attribute.getName(), "content")
            || StringUtils.equals(attribute.getName(), "repositoryContent"));
}

From source file:com.anite.antelope.modules.actions.security.AddUser.java

public void doPerform(RunData data, Context context) throws Exception {
    FormTool form = (FormTool) context.get(FormTool.DEFAULT_TOOL_NAME);
    SecurityTool security = (SecurityTool) context.get(SecurityTool.DEFAULT_TOOL_NAME);

    if (form.isAllValid()) {
        // Declare variables

        UserManager usermanager;/*from   w  ww. j a va 2  s .  c o m*/

        FieldMap fieldMap;
        Field usernameField;
        Field passwordField, confPasswordField;

        usermanager = security.getUserManager();
        fieldMap = form.getFields();

        usernameField = (Field) fieldMap.get("username");

        // check the username isnt alreay used
        if (usermanager.checkExists(usernameField.getValue())) {
            usernameField.addMessage("Username already taken!");
            data.setScreenTemplate("security,AddUser.vm");
            return;
        }

        passwordField = (Field) fieldMap.get("password");
        confPasswordField = (Field) fieldMap.get("confpassword");

        // check the password match before adding the user
        if (StringUtils.equals(passwordField.getValue(), confPasswordField.getValue())) {
            User user;
            user = usermanager.getUserInstance(usernameField.getValue());
            usermanager.addUser(user, passwordField.getValue());
        } else {
            passwordField.addMessage("Passwords dont match!");
            data.setScreenTemplate("security,AddUser.vm");
        }
    } else {
        data.setScreenTemplate("security,AddUser.vm");
    }
}

From source file:com.glaf.core.web.rest.DataServiceResource.java

@GET
@POST//ww  w  .jav a2  s  . c om
@Path("/response/{id}")
@ResponseBody
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public byte[] response(@PathParam("id") String id, @Context HttpServletRequest request) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    String dataType = request.getParameter("dataType");
    String systemName = request.getParameter("systemName");
    if (dataType == null) {
        dataType = "xml";
    }
    if (systemName == null) {
        systemName = com.glaf.core.config.Environment.DEFAULT_SYSTEM_NAME;
    }
    Map<String, Object> contextMap = RequestUtils.getParameterMap(request);
    contextMap.put("systemName", systemName);
    String ipAddress = RequestUtils.getIPAddress(request);
    DataServiceBean bean = new DataServiceBean();
    bean.setSysDataService(sysDataService);
    if (StringUtils.equals(dataType, "json")) {
        return bean.responseJson(systemName, id, loginContext.getActorId(), ipAddress, contextMap);
    }
    return bean.responseXml(systemName, id, loginContext.getActorId(), ipAddress, contextMap);
}