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:de.micromata.mgc.application.webserver.config.JettyConfigTabController.java

@Override
public void initializeWithModel() {

    sslChildPane = sslPane.getChildren().get(0);
    fromModel();/*  w  w  w  .j av a  2  s  .  c  o m*/
    List<String> hosts = getListenHosts();
    hosts.add(0, "");
    listenHost.setItems(FXCollections.observableArrayList(hosts));
    port.textProperty().addListener((tc, oldVal, newVal) -> {
        String oldUrl = publicUrl.getText();
        String sc = contextPath.getText();
        String tu = "http://localhost:" + oldVal + sc;
        if (StringUtils.equals(oldUrl, tu) == true) {
            String nu = "http://localhost:" + newVal + sc;
            publicUrl.setText(nu);
        }
    });
    sslEnabled.setOnAction(event -> {
        onSslEnabled(sslEnabled.isSelected());
    });

    onSslEnabled(model.isSslEnabled());
    generateSslCert.setOnAction(event -> {
        createSsl();
    });
}

From source file:com.glaf.base.modules.sys.interceptor.AuthorizeInterceptor.java

/**
 * method - method being invoked args - arguments to the method target -
 * target of the method invocation. May be null.
 *///from w  ww  . ja v  a2 s. c o  m
public void before(Method method, Object[] args, Object target) throws Throwable {
    boolean authorized = false;
    String objectName = target.getClass().getName();
    String methodName = method.getName();
    // logger.debug("object:" + objectName);
    // logger.debug("method:" + methodName);
    if (StringUtils.startsWith(methodName, "org.springframework.web.servlet.view")) {
        return;
    }
    if (StringUtils.startsWith(methodName, "login")) {
        return;
    }
    if (StringUtils.startsWith(methodName, "logout")) {
        return;
    }
    String ip = "";
    String account = "";

    for (int i = 0; i < args.length; i++) {
        // logger.debug("args:" + args[i]);
        if (args[i] instanceof HttpServletRequest) {
            HttpServletRequest request = (HttpServletRequest) args[i];
            if (request != null && request.getParameter("method") != null) {
                methodName = request.getParameter("method");
                ip = request.getRemoteHost();
                SysUser user = RequestUtil.getLoginUser(request);
                if (user != null) {
                    //logger.debug(user.toJsonObject().toJSONString());
                    account = user.getAccount();
                    if (StringUtils.equals(user.getAdminFlag(), "1")) {
                        authorized = true;
                    }
                    if (user.isSystemAdmin()) {
                        authorized = true;
                        logger.debug(account + " is admin");
                    }
                }
                // logger.debug("IP:" + ip + ", Account:" + account);
            }
        }
    }
    methodName = objectName + "." + methodName;
    // logger.debug("methodName:" + methodName);

    // 
    if (findSysFunction(methodName)) {
        // 
        if (findUserFunction(account, methodName)) {
            // logger.debug("method is in user functions");
            authorized = true;
        }
    } else {// ?
        // logger.debug("method isn't in sys functions");
        authorized = true;
    }

    // ?
    createLog(account, methodName, ip, authorized ? 1 : 0);

    if (!authorized) {
        throw new AuthorizeException("No Privileges.");
    }
}

From source file:com.glaf.survey.web.springmvc.SurveyController.java

@ResponseBody
@RequestMapping("/delete")
public void delete(HttpServletRequest request, ModelMap modelMap) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    Long id = RequestUtils.getLong(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)) {
                Survey survey = surveyService.getSurvey(Long.valueOf(x));
                if (survey != null && (StringUtils.equals(survey.getCreateBy(), loginContext.getActorId())
                        || loginContext.isSystemAdministrator())) {
                    surveyService.deleteById(survey.getId());
                }/*from w ww . j av  a  2  s  .  c o  m*/
            }
        }
    } else if (id != null) {
        Survey survey = surveyService.getSurvey(Long.valueOf(id));
        if (survey != null && (StringUtils.equals(survey.getCreateBy(), loginContext.getActorId())
                || loginContext.isSystemAdministrator())) {
            surveyService.deleteById(survey.getId());
        }
    }
}

From source file:com.neophob.sematrix.core.generator.Image.java

/**
 * load a new file.//  w  ww  .ja  va 2  s  .c  o  m
 *
 * @param filename the filename
 */
public synchronized void loadFile(String filename) {
    if (StringUtils.isBlank(filename)) {
        LOG.log(Level.INFO, "Empty filename provided, call ignored!");
        return;
    }

    //only load if needed
    if (StringUtils.equals(filename, this.filename)) {
        LOG.log(Level.INFO, "new filename does not differ from old: " + filename);
        return;
    }

    try {
        String fileToLoad = fileUtils.getImageDir() + File.separator + filename;

        LOG.log(Level.INFO, "load image " + fileToLoad);
        BufferedImage img = ImageIO.read(new File(fileToLoad));
        if (img == null || img.getHeight() < 2) {
            LOG.log(Level.WARNING, "Invalid image, image height is < 2!");
            return;
        }

        //convert to RGB colorspace
        int w = img.getWidth();
        int h = img.getHeight();
        int[] dataBuffInt = img.getRGB(0, 0, w, h, null, 0, w);

        LOG.log(Level.INFO, "resize to img " + filename + " " + internalBufferXSize + ", " + internalBufferYSize
                + " using " + resize.getName());
        this.internalBuffer = resize.getBuffer(dataBuffInt, internalBufferXSize, internalBufferYSize, w, h);
        this.filename = filename;

        short r, g, b;
        int rgbColor;

        //greyscale it
        for (int i = 0; i < internalBuffer.length; i++) {
            rgbColor = internalBuffer[i];
            r = (short) ((rgbColor >> 16) & 255);
            g = (short) ((rgbColor >> 8) & 255);
            b = (short) (rgbColor & 255);
            int val = (int) (r * 0.3f + g * 0.59f + b * 0.11f);
            internalBuffer[i] = val;
        }

    } catch (Exception e) {
        LOG.log(Level.WARNING, "Failed to load image " + filename, e);
    }
}

From source file:com.stefanbrenner.droplet.model.internal.Configuration.java

public static IDropletMessageProtocol getMessageProtocolProvider() {
    String string = Configuration.PREFS.get(Configuration.PREF_MESSAGE_PROTOCOL, null);
    List<IDropletMessageProtocol> plugins = PluginLoader.getPlugins(IDropletMessageProtocol.class);
    for (IDropletMessageProtocol messageService : plugins) {
        if (StringUtils.equals(messageService.getClass().getCanonicalName(), string)) {
            return messageService;
        }/*from  www  .  j av  a 2 s.com*/
    }
    // if no provider was found we use our own message protocol provider
    return Configuration.DEFAULT_MESSAGE_PROTOCOL_PROVIDER;
}

From source file:cn.vlabs.clb.server.service.auth.IAppAuthService.java

private int checkAuth(DocMeta m, String currentUser) {
    if (m.getIsPub() == DocMeta.PRIVATE_DOC && !StringUtils.equals(m.getAuthId(), currentUser)) {
        return m.getDocid();
    }//from w  ww. j a va 2s  . co  m
    return 0;
}

From source file:com.hybris.mobile.lib.commerce.data.UserInformation.java

public boolean isAnonymous() {
    return StringUtils.equals(userId, SpecificUser.UserId.ANONYMOUS.getValue());
}

From source file:com.quinsoft.zeidon.dbhandler.QualEntity.java

void addQualAttrib(QualAttrib qualAttrib) {
    qualAttribs.add(qualAttrib);/*  w  w w  . j  a v  a 2  s . c  o  m*/

    if (qualAttrib.entityDef != null && qualAttrib.entityDef != entityDef) {
        usesEntityDefs.add(qualAttrib.entityDef);
        usesChildQualification = true;

        // We're qualifying on a child entity so that's not a key.
        keyQualification = false;
    } else if (qualAttrib.columnAttributeValue != null
            && qualAttrib.columnAttributeValue.getEntityDef() != entityDef) {
        usesChildQualification = true;
        usesEntityDefs.add(qualAttrib.entityDef);
    }

    // Are we qualifying using a key?
    if (qualAttrib.attributeDef != null
            && (!qualAttrib.attributeDef.isKey() || !StringUtils.equals(qualAttrib.oper, "="))) {
        // No.
        keyQualification = false;
    }
}

From source file:ch.cyberduck.core.openstack.SwiftAttributesFeature.java

@Override
public PathAttributes find(final Path file) throws BackgroundException {
    if (file.isRoot()) {
        return PathAttributes.EMPTY;
    }/*  w  w  w .j a  v  a2  s.  c  o m*/
    final Region region = regionService.lookup(file);
    try {
        if (containerService.isContainer(file)) {
            final ContainerInfo info = session.getClient().getContainerInfo(region,
                    containerService.getContainer(file).getName());
            final PathAttributes attributes = new PathAttributes();
            attributes.setSize(info.getTotalSize());
            attributes.setRegion(info.getRegion().getRegionId());
            return attributes;
        }
        final PathAttributes attributes = new PathAttributes();
        final ObjectMetadata metadata = session.getClient().getObjectMetaData(region,
                containerService.getContainer(file).getName(), containerService.getKey(file));
        if (file.isDirectory()) {
            if (!StringUtils.equals("application/directory", metadata.getMimeType())) {
                throw new NotfoundException(String.format("Path %s is file", file.getAbsolute()));
            }
        }
        if (file.isFile()) {
            if (StringUtils.equals("application/directory", metadata.getMimeType())) {
                throw new NotfoundException(String.format("Path %s is directory", file.getAbsolute()));
            }
        }
        attributes.setSize(Long.valueOf(metadata.getContentLength()));
        try {
            attributes.setModificationDate(dateParser.parse(metadata.getLastModified()).getTime());
        } catch (InvalidDateException e) {
            log.warn(String.format("%s is not RFC 1123 format %s", metadata.getLastModified(), e.getMessage()));
        }
        if (StringUtils.isNotBlank(metadata.getETag())) {
            final String etag = StringUtils.removePattern(metadata.getETag(), "\"");
            attributes.setETag(etag);
            if (metadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) {
                // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of
                // the concatenated string of ETags for each of the segments in the manifest.
                attributes.setChecksum(null);
            } else {
                attributes.setChecksum(Checksum.parse(etag));
            }
        }
        return attributes;
    } catch (GenericException e) {
        throw new SwiftExceptionMappingService().map("Failure to read attributes of {0}", e, file);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file);
    }
}

From source file:com.inkubator.hrm.web.loan.LoanNewApprovalFormController.java

@PostConstruct
@Override//from   w  w  w .  ja v a2s . c  o  m
public void initialization() {
    try {
        super.initialization();
        String id = FacesUtil.getRequestParameter("execution");
        selectedApprovalActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1)));
        askingRevisedActivity = approvalActivityService.getEntityByActivityNumberAndSequence(
                selectedApprovalActivity.getActivityNumber(), selectedApprovalActivity.getSequence() - 1);
        isWaitingApproval = selectedApprovalActivity
                .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL;
        isWaitingRevised = selectedApprovalActivity
                .getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED;
        isApprover = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getApprovedBy());
        isRequester = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getRequestBy());

        Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create();
        selectedLoanNewApplication = gson.fromJson(selectedApprovalActivity.getPendingData(),
                LoanNewApplication.class);
        EmpData empData = empDataService.getByIdWithDetail(selectedLoanNewApplication.getEmpData().getId());
        selectedLoanNewApplication.setEmpData(empData);
        listLoanInstallment = loanNewApplicationService.getAllDataLoanNewApplicationInstallment(
                selectedLoanNewApplication.getLoanNewType().getInterest().doubleValue(),
                selectedLoanNewApplication.getTermin(), selectedLoanNewApplication.getFirstLoanPaymentDate(),
                selectedLoanNewApplication.getNominalPrincipal(),
                selectedLoanNewApplication.getLoanNewType().getInterestMethod());
    } catch (Exception ex) {
        LOGGER.error("Error", ex);

    }
}