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.mail.web.rest.MailAccountResource.java

@POST
@Path("/delete/{accountId}")
public void deleteById(@PathParam("accountId") String accountId, @Context HttpServletRequest request,
        @Context UriInfo uriInfo) {
    if (accountId != null) {
        String actorId = RequestUtils.getActorId(request);
        MailAccount mailAccount = mailAccountService.getMailAccount(accountId);
        if (mailAccount != null && StringUtils.equals(mailAccount.getCreateBy(), actorId)) {
            mailAccountService.deleteById(accountId);
        }/*from ww  w .j  a  va  2 s .  co m*/
    } else {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
}

From source file:de.micromata.tpsb.doc.parser.MethodInfo.java

public boolean isGenericReturnType() {
    if (typeArgNames == null) {
        return false;
    }/*from w ww .j a v  a2 s  .  c om*/
    for (String typeName : typeArgNames) {
        if (StringUtils.equals(typeName, returnType) == true) {
            return true;
        }
    }
    return false;
}

From source file:com.thinkmore.framework.orm.Page.java

/**
 * ???./*from w w w . j ava2  s . c om*/
 * 
 * @param order
 *            ?descasc,?','.
 */
public void setOrder(final String order) {
    // order?
    String[] orders = StringUtils.split(StringUtils.lowerCase(order), ',');
    for (String orderStr : orders) {
        if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) {
            throw new IllegalArgumentException("??" + orderStr + "??");
        }
    }
    this.order = StringUtils.lowerCase(order);
}

From source file:io.wcm.handler.url.rewriter.impl.UrlExternalizerTransformer.java

@Override
public void startElement(String nsUri, String name, String raw, Attributes attrs) throws SAXException {

    // check if for this element an attribute for rewriting is configured
    String rewriteAttr = transformerConfig.getElementAttributeNames().get(name);
    if (rewriteAttr == null) {
        log.trace("Rewrite element {}: Skip - No rewrite attribute configured.", name);
        super.startElement(nsUri, name, raw, attrs);
        return;/*from  w ww  .  j  a  v  a 2  s . c o m*/
    }

    // validate URL handler
    if (urlHandler == null) {
        log.warn("Rewrite element {}: Skip - Unable to get URL handler/Integrator handler instance.", name);
        super.startElement(nsUri, name, raw, attrs);
        return;
    }

    // check if attribute exists
    int attributeIndex = attrs.getIndex(rewriteAttr);
    if (attributeIndex < 0) {
        log.trace("Rewrite element {}: Skip - Attribute does not exist: {}", name, rewriteAttr);
        super.startElement(nsUri, name, raw, attrs);
        return;
    }

    // rewrite URL
    String url = attrs.getValue(attributeIndex);
    if (StringUtils.isEmpty(url)) {
        log.trace("Rewrite element {}: Skip - URL is empty.", name);
        super.startElement(nsUri, name, raw, attrs);
        return;
    }

    // remove escaping
    url = StringEscapeUtils.unescapeHtml4(url);

    // externalize URL (if it is not already externalized)
    String rewrittenUrl = urlHandler.get(url).buildExternalResourceUrl();

    if (StringUtils.equals(url, rewrittenUrl)) {
        log.debug("Rewrite element {}: Skip - URL is already externalized: {}", name, url);
        super.startElement(nsUri, name, raw, attrs);
        return;
    }

    // set new attribute value
    log.debug("Rewrite element {}: Rewrite URL {} to {}", name, url, rewrittenUrl);
    AttributesImpl newAttrs = new AttributesImpl(attrs);
    newAttrs.setValue(attributeIndex, rewrittenUrl);
    super.startElement(nsUri, name, raw, newAttrs);
}

From source file:com.inkubator.hrm.web.personalia.BioRelasiPerusahaanFormController.java

@PostConstruct
@Override/*  w ww .j a va2s .  com*/
public void initialization() {
    super.initialization();
    try {
        isUpdate = Boolean.FALSE;
        isCountrySelected = Boolean.FALSE;
        isProvinceSelected = Boolean.FALSE;
        model = new BioRelasiPerusahaanModel();
        countries = countryService.getAllData();
        provinces = new ArrayList<Province>();
        cities = new ArrayList<City>();

        String bioDataId = FacesUtil.getRequestParameter("bioDataId");
        model.setBioData(Long.parseLong(bioDataId));

        //parameter is Revision untuk flag jika ini datangnya dari request perubahan biodata
        isRevision = FacesUtil.getRequestParameter("isRevision");
        if (StringUtils.isNotBlank(isRevision)) {
            String isEditOnRevision = FacesUtil.getRequestParameter("isEditOnRevision");
            if (StringUtils.equals(isEditOnRevision, "Yes")) {

                Map<String, Object> sessionMap = FacesUtil.getExternalContext().getSessionMap();
                BioRelasiPerusahaan bioRelasiPerusahaan = (BioRelasiPerusahaan) sessionMap
                        .get("selectedBioRelasiPerusahaan");

                model.setId(bioRelasiPerusahaan.getId());
                model.setCity(bioRelasiPerusahaan.getCity().getId());
                model.setRelasiAddress(bioRelasiPerusahaan.getRelasiAddress());
                model.setCountryId(bioRelasiPerusahaan.getCity().getProvince().getCountry().getId());
                model.setProvinceId(bioRelasiPerusahaan.getCity().getProvince().getId());
                model.setCityId(bioRelasiPerusahaan.getCity().getId());
                model.setRelasiCompany(bioRelasiPerusahaan.getRelasiCompany());
                model.setRelasiEmail(bioRelasiPerusahaan.getRelasiEmail());
                model.setPostCode(bioRelasiPerusahaan.getPostalCode());
                model.setRelasiJabatan(bioRelasiPerusahaan.getRelasiJabatan());
                model.setRelasiMobilePhone(bioRelasiPerusahaan.getRelasiMobilePhone());
                model.setRelasiName(bioRelasiPerusahaan.getRelasiName());
                model.setRelasiPhoneNumber(bioRelasiPerusahaan.getRelasiPhoneNumber());
                model.setRelasiAttachmentName(bioRelasiPerusahaan.getRelasiAttachmentName());

                provinces = provinceService.getByCountryId(model.getCountryId());
                cities = cityService.getByProvinceId(model.getProvinceId());
            }
        } else {
            String bioRelasiPerusahaanId = FacesUtil.getRequestParameter("bioRelasiPerusahaanId");
            if (StringUtils.isNotEmpty(bioRelasiPerusahaanId)) {
                BioRelasiPerusahaan bioRelasiPerusahaan = bioRelasiPerusahaanService
                        .getEntityByPkWithDetail(Long.parseLong(bioRelasiPerusahaanId));
                if (bioRelasiPerusahaan != null) {
                    model = getModelFromEntity(bioRelasiPerusahaan);
                    provinces = provinceService.getByCountryId(model.getCountryId());
                    cities = cityService.getByProvinceId(model.getProvinceId());
                    isUpdate = Boolean.TRUE;
                }
            }
        }

    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

From source file:ke.co.tawi.babblesms.server.servlet.admin.smsgateway.AddNotificationUrl.java

/**
*
* @param request//from   w w  w.j av a  2 s.  co m
* @param response
* @throws ServletException, IOException
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    HttpSession session = request.getSession(false);

    String user = StringUtils.trimToEmpty(request.getParameter("user"));
    String url = StringUtils.trimToEmpty(request.getParameter("url"));
    String password = StringUtils.trimToEmpty(request.getParameter("password"));
    String password2 = StringUtils.trimToEmpty(request.getParameter("password2"));
    // This is used to store parameter names and values from the form.
    Map<String, String> paramHash = new HashMap<>();
    paramHash.put("url", url);

    String uuid = user.split("\\|")[0];
    String uname = user.split("\\|")[1];
    /*System.out.println(uuid);
    System.out.println(uname);*/

    // No Url provided      
    if (StringUtils.isBlank(url)) {
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_ERROR_KEY, "please provide a Url");

        // usernane exist   
    } // No Url provided      

    else if (StringUtils.isBlank(password)) {
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_ERROR_KEY, "please provide password");

        // usernane exist   
    } else if (StringUtils.isBlank(password2)) {
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_ERROR_KEY, "please confirm password");

        // usernane exist   
    } else if (userNameExist(uname)) {
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_ERROR_KEY,
                "username already exist in the System");
    } else if (!StringUtils.equals(password, password2)) {
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_ERROR_KEY, "Password Mismatch");
    } else {
        // If we get this far then all parameter checks are ok.         
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_SUCCESS_KEY, "s");

        // Reduce our session data
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_PARAMETERS, null);
        session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_ERROR_KEY, null);
        TawiGateway g = new TawiGateway();
        g.setAccountUuid(uuid);
        g.setUrl(url);
        g.setUsername(uname);
        g.setPasswd(password);
        gatewayDAO.put(g);
        //session.setAttribute(SessionConstants.ADMIN_ADD_SUCCESS, "Account created successfully.");
    }

    response.sendRedirect("addaccount.jsp");
    session.setAttribute(SessionConstants.ADMIN_ADD_ACCOUNT_PARAMETERS, paramHash);
}

From source file:com.glaf.base.modules.sys.service.mybatis.SysRoleServiceImpl.java

@Transactional
public void deleteById(Long id) {
    if (id != null) {
        SysRole sysRole = sysRoleMapper.getSysRoleById(id);
        if (sysRole != null && StringUtils.equals(sysRole.getType(), "SYS")) {
            throw new RuntimeException("Can't delete system role");
        }// ww w  .j  ava  2  s.  c  om
        List<SysRole> roles = sysRoleMapper.getSysRolesOfDeptRole(id);
        if (roles != null && !roles.isEmpty()) {
            throw new RuntimeException("Can't delete role");
        } else {
            sysRoleMapper.deleteSysRoleById(id);
        }
    }
}

From source file:com.mgmtp.jfunk.core.mail.MessagePredicates.java

/**
 * Creates a {@link Predicate} for matching a mail header and subject. If multiple header values
 * are present for the given header name this Predicate returns true if at least one header
 * value matches the given header value.
 * //from ww w  . j  a v  a2s  .co m
 * @param subjectPattern
 *            the regex pattern to match
 * @param headerName
 *            the header name to match
 * @param headerValue
 *            the header value to match
 * @return the predicate
 */
public static Predicate<MailMessage> forSubjectAndHeaders(final Pattern subjectPattern, final String headerName,
        final String headerValue) {
    return new Predicate<MailMessage>() {
        @Override
        public boolean apply(final MailMessage input) {
            boolean result = false;
            List<String> headers = input.getHeaders().get(headerName);
            for (String singleHeader : headers) {
                if (StringUtils.equals(singleHeader, headerValue)) {
                    result = true;
                    break;
                }
            }
            return result && subjectPattern.matcher(input.getSubject()).matches();
        }

        @Override
        public String toString() {
            return String.format("subject to match pattern '%s' and headers to include header '%s=%s'",
                    subjectPattern, headerName, headerValue);
        }
    };
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.macros.GWikiSwitchSpaceMacro.java

@Override
public boolean renderImpl(GWikiContext ctx, MacroAttributes attrs) {

    GWikiSpaces spaces = ctx.getWikiWeb().getSpaces();
    if (StringUtils.isNotBlank(space) == true) {
        GWikiElementInfo ei = spaces.findWelcomeForSpace(ctx, space);

        if (ei == null) {
            return true;
        } else {/*from ww  w.j a v  a 2 s  .  c  o  m*/
            String turl = "window.location='"
                    + ctx.escape(ctx.localUrl(ctx.getCurrentElement().getElementInfo().getId())) + "?"
                    + GWikiSpaceFilter.WIKI_SET_SPACE_PARAM + "=" + space + "'";
            ctx.append("<a href='#' onclick=\"" + turl + "\">");
            String title = ctx.getTranslatedProp(ei.getTitle());
            ctx.appendEscText(title);
            ctx.append("</a>");
        }
    } else {
        List<SpaceInfo> list = ctx.getWikiWeb().getSpaces().getAvailableSpaces(ctx);
        if (list.isEmpty() == true) {
            return true;
        }
        ctx.append("<select class='gwikiSwitchSpace' onchange=\"window.location='"
                + ctx.escape(ctx.localUrl(ctx.getCurrentElement().getElementInfo().getId())) + "?"
                + GWikiSpaceFilter.WIKI_SET_SPACE_PARAM + "=' + this.value\">\n");
        ctx.append("<option value=''></option>\n");
        String curSpace = spaces.getUserCurrentSpaceId(ctx);
        for (SpaceInfo p : list) {
            String selected = "";
            if (StringUtils.equals(p.getSpaceId(), curSpace) == true) {
                selected = " selected='selected '";
            }
            ctx.append("<option " + selected + "value='" + ctx.escape(p.getSpaceId()) + "'>")
                    .appendEscText(p.getTitle()).append("</option>\n");
        }
        ctx.append("</select>");
    }
    return true;
}

From source file:com.glaf.jbpm.assignment.ProcessStarterAssignment.java

public void assign(Assignable assignable, ExecutionContext ctx) {
    logger.debug("-------------------------------------------------------");
    logger.debug("----------------ProcessStarterAssignment---------------");
    logger.debug("-------------------------------------------------------");

    ContextInstance contextInstance = ctx.getContextInstance();

    String actorId = (String) contextInstance.getVariable(Constant.PROCESS_STARTERID);
    if (StringUtils.isEmpty(actorId)) {
        long taskInstanceId = Long.MAX_VALUE;
        TaskMgmtInstance tmi = ctx.getProcessInstance().getTaskMgmtInstance();
        Collection<TaskInstance> taskInstances = tmi.getTaskInstances();
        Iterator<TaskInstance> iterator = taskInstances.iterator();
        while (iterator.hasNext()) {
            TaskInstance taskInstance = iterator.next();
            if (taskInstance.hasEnded() && StringUtils.isNotEmpty(taskInstance.getActorId())) {
                if (taskInstance.getId() < taskInstanceId) {
                    taskInstanceId = taskInstance.getId();
                }//from  ww w.j  a  v  a 2 s .  c om
            }
        }
        if (taskInstanceId < Long.MAX_VALUE) {
            TaskInstance taskInstance = ctx.getJbpmContext().getTaskInstance(taskInstanceId);
            actorId = taskInstance.getActorId();
        }
    }

    if (StringUtils.isNotEmpty(actorId)) {
        assignable.setActorId(actorId);
        if (StringUtils.isNotEmpty(sendMail) && StringUtils.equals(sendMail, "true")) {
            Set<String> actorIds = new HashSet<String>();
            actorIds.add(actorId);
            MailBean mailBean = new MailBean();
            mailBean.setContent(content);
            mailBean.setSubject(subject);
            mailBean.setTaskContent(taskContent);
            mailBean.setTemplateId(templateId);
            mailBean.execute(ctx, actorIds);
        }
        return;
    }

}