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

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

Introduction

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

Prototype

public static String lowerCase(String str) 

Source Link

Document

Converts a String to lower case as per String#toLowerCase() .

Usage

From source file:org.telscenter.sail.webapp.presentation.web.controllers.LostPasswordStudentReminderWizardController.java

/**
 * This method is called after the onBind and onBindAndValidate method. It
 * acts in the same way as the validator
 * /*from w w w  .jav  a 2 s.  co  m*/
 * @see org.springframework.web.servlet.mvc.AbstractWizardFormController#validatePage(java.lang.Object,
 *      org.springframework.validation.Errors, int)
 */
@Override
protected void validatePage(Object command, Errors errors, int page) {

    ReminderParameters reminderParameters = (ReminderParameters) command;

    switch (page) {
    case 0:
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.username-not-found");
        try {

            String username = reminderParameters.get(ReminderParameters.USERNAME);
            username = StringUtils.trimToNull(username);
            user = userService.retrieveUserByUsername(username);
        } catch (EmptyResultDataAccessException e) {
            //TODO: archana needs to update these
            errors.reject("username", "error.username-not-found");
        }

        break;
    case 1:
        //TODO: archana needs to update these
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "submittedAccountAnswer",
                "error.submitted-account-question-blank");

        String submittedAccountAnswer = reminderParameters.getSubmittedAccountAnswer();

        String accountAnswer = reminderParameters.getAccountAnswer();

        accountAnswer = StringUtils.lowerCase(accountAnswer);

        submittedAccountAnswer = StringUtils.lowerCase(submittedAccountAnswer);
        ;

        if (!accountAnswer.equals(submittedAccountAnswer)) {
            //TODO: archana needs to update these
            errors.reject("error.submitted-account-question");
        }

        break;
    case 2:

        //TODO: archana needs to update these
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "verifyPassword", "error.verify-newpassword");

        //TODO: archana needs to update these
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newPassword", "error.verify-newpassword");

        String newPassword = reminderParameters.getNewPassword();

        String verifyPassword = reminderParameters.getVerifyPassword();

        verifyPassword = StringUtils.lowerCase(verifyPassword);

        newPassword = StringUtils.lowerCase(newPassword);

        verifyPassword = StringUtils.lowerCase(verifyPassword);

        if (!verifyPassword.equals(newPassword)) {
            //TODO: archana needs to update these
            errors.reject("error.verify-newpassword");
        }
        break;
    default:
        break;
    }
}

From source file:org.tinygroup.springmvc.coc.impl.RestfulConventionHandlerMethodResolver.java

@Override
public Method getHandlerMethod(HttpServletRequest request) {
    Method mtd = super.getHandlerMethod(request);
    if (mtd != null) {
        request.setAttribute(RESTFUL_CONVENTION_VIEW_PATH, StringUtils.lowerCase(mtd.getName()).substring(2));// "doxx" skip "do"
    }//from w ww  . j av  a 2  s.  com
    return mtd;
}

From source file:org.usergrid.persistence.cassandra.ConnectionRefImpl.java

/**
 * @param columns//from w  ww .j  ava  2 s  .c  om
 */
public static ConnectionRefImpl loadFromColumns(List<HColumn<String, ByteBuffer>> columns) {

    List<ConnectedEntityRef> pairedConnections = new ArrayList<ConnectedEntityRef>();

    Map<String, ByteBuffer> map = CassandraPersistenceUtils.getColumnMap(columns);

    String connectingEntityType = filterDefault(string(map.get(CONNECTING_ENTITY_TYPE)));
    UUID connectingEntityId = filterDefault(uuid(map.get(CONNECTING_ENTITY_ID)));

    EntityRef connectingEntity = ref(connectingEntityType, connectingEntityId);

    int i = 0;
    UUID pairedConnectingEntityId = filterDefault(uuid(map.get(PAIRED_CONNECTING_ENTITY_ID)));

    while (pairedConnectingEntityId != null) {

        String pairedConnectionType = filterDefault(
                StringUtils.lowerCase(string(map.get(PAIRED_CONNECTION_TYPE + i))));

        String pairedConnectingEntityType = filterDefault(string(map.get(PAIRED_CONNECTING_ENTITY_TYPE + i)));
        ConnectedEntityRef pairedConnection = new ConnectedEntityRefImpl(pairedConnectionType,
                pairedConnectingEntityType, pairedConnectingEntityId);
        pairedConnections.add(pairedConnection);

        i++;

        pairedConnectingEntityId = filterDefault(uuid(map.get(PAIRED_CONNECTING_ENTITY_ID + i)));
    }

    String connectionType = filterDefault(StringUtils.lowerCase(string(map.get(CONNECTION_TYPE))));

    String connectedEntityType = filterDefault(string(map.get(CONNECTED_ENTITY_TYPE)));
    UUID connectedEntityId = filterDefault(uuid(map.get(CONNECTED_ENTITY_ID)));

    ConnectedEntityRef connectedEntity = new ConnectedEntityRefImpl(connectionType, connectedEntityType,
            connectedEntityId);

    return new ConnectionRefImpl(connectingEntity, pairedConnections, connectedEntity);

}

From source file:org.usergrid.persistence.cassandra.ConnectionRefImpl.java

public static UUID getId(EntityRef connectingEntity, ConnectedEntityRef connectedEntity,
        ConnectedEntityRef... pairedConnections) {
    UUID uuid = null;//from  w  ww. jav a2  s  . c  o  m
    try {

        if (connectionsNull(pairedConnections) && connectionsNull(connectedEntity)) {
            return connectingEntity.getUuid();
        }

        ByteArrayOutputStream byteStream = new ByteArrayOutputStream(16 + (32 * pairedConnections.length));

        byteStream.write(uuidToBytesNullOk(connectingEntity.getUuid()));

        for (ConnectedEntityRef connection : pairedConnections) {
            String connectionType = connection.getConnectionType();
            UUID connectedEntityID = connection.getUuid();

            byteStream.write(ascii(StringUtils.lowerCase(connectionType)));
            byteStream.write(uuidToBytesNullOk(connectedEntityID));

        }

        String connectionType = connectedEntity.getConnectionType();
        if (connectionType == null) {
            connectionType = NULL_ENTITY_TYPE;
        }

        UUID connectedEntityID = connectedEntity.getUuid();

        byteStream.write(ascii(StringUtils.lowerCase(connectionType)));
        byteStream.write(uuidToBytesNullOk(connectedEntityID));

        byte[] raw_id = byteStream.toByteArray();

        // logger.info("raw connection index id: " +
        // Hex.encodeHexString(raw_id));

        uuid = UUID.nameUUIDFromBytes(raw_id);

        // logger.info("connection index uuid: " + uuid);

    } catch (IOException e) {
        logger.error("Unable to create connection UUID", e);
    }
    return uuid;
}

From source file:org.usergrid.persistence.cassandra.ConnectionRefImpl.java

public static UUID getIndexId(EntityRef connectingEntity, String connectionType, String connectedEntityType,
        ConnectedEntityRef... pairedConnections) {

    UUID uuid = null;/*w ww  .  ja  v a2  s.c  om*/
    try {

        if (connectionsNull(pairedConnections) && ((connectionType == null) && (connectedEntityType == null))) {
            return connectingEntity.getUuid();
        }

        ByteArrayOutputStream byteStream = new ByteArrayOutputStream(16 + (32 * pairedConnections.length));

        byteStream.write(uuidToBytesNullOk(connectingEntity.getUuid()));

        for (ConnectedEntityRef connection : pairedConnections) {
            String type = connection.getConnectionType();
            UUID id = connection.getUuid();

            byteStream.write(ascii(StringUtils.lowerCase(type)));
            byteStream.write(uuidToBytesNullOk(id));

        }

        if (connectionType == null) {
            connectionType = NULL_ENTITY_TYPE;
        }
        if (connectedEntityType == null) {
            connectedEntityType = NULL_ENTITY_TYPE;
        }

        byteStream.write(ascii(StringUtils.lowerCase(connectionType)));
        byteStream.write(ascii(StringUtils.lowerCase(connectedEntityType)));

        byte[] raw_id = byteStream.toByteArray();

        logger.info("raw connection index id: " + Hex.encodeHexString(raw_id));

        uuid = UUID.nameUUIDFromBytes(raw_id);

        logger.info("connection index uuid: " + uuid);

    } catch (IOException e) {
        logger.error("Unable to create connection index UUID", e);
    }
    return uuid;

}

From source file:org.vaadin.addons.javaee.container.rest.RestEntityContainer.java

@Override
@SuppressWarnings("unchecked")
public <SUB_ENTITY extends PersistentEntity> EntityContainer<SUB_ENTITY> getSubContainer(String propertyId) {
    Class<SUB_ENTITY> entityClass = (Class<SUB_ENTITY>) getType(propertyId);
    // TODO path should contain id
    return new RestEntityContainer<>(entityClass, StringUtils.lowerCase(entityClass.getSimpleName()));
}

From source file:org.wise.portal.presentation.web.controllers.forgotaccount.ResetPasswordController.java

/**
 * Called when the user chooses a new password and submits the form.
 * @param passwordReminderParameters the object that contains values from the form
 * @param bindingResult the object used for validation in which errors will be stored
 * @param modelMap the model object that contains values for the page to use when rendering the view
 * @param request the http request//from w w w .  ja  va  2 s . c  om
 * @return the path of the view to display
 */
@RequestMapping(method = RequestMethod.POST)
protected String onSubmit(
        @ModelAttribute("passwordReminderParameters") PasswordReminderParameters passwordReminderParameters,
        BindingResult bindingResult, Model model, HttpServletRequest request) throws Exception {
    String view = formView;

    //get the password values the user entered
    String newPassword = passwordReminderParameters.getNewPassword();
    String verifyPassword = passwordReminderParameters.getVerifyPassword();

    //make the passwords lower case
    verifyPassword = StringUtils.lowerCase(verifyPassword);
    newPassword = StringUtils.lowerCase(newPassword);

    if (!verifyPassword.equals(newPassword)) {
        //passwords are not the same
        bindingResult.reject("error.verify-newpassword");

        //do not display the "Forgot Username or Password?" link
        model.addAttribute("displayForgotPasswordSelectAccountTypeLink", false);

        //do not display the sign in button
        model.addAttribute("displayLoginLink", false);
    } else if (verifyPassword.equals("")) {
        //password is empty string
        bindingResult.reject("error.verify-password-empty");

        //do not display the "Forgot Username or Password?" link
        model.addAttribute("displayForgotPasswordSelectAccountTypeLink", false);

        //do not display the sign in button
        model.addAttribute("displayLoginLink", false);
    } else {
        //get the reset password key
        String resetPasswordKey = request.getParameter("k");

        //get the user associated with the reset password key
        User user = userService.retrieveByResetPasswordKey(resetPasswordKey);

        //update the user's password
        userService.updateUserPassword(user, verifyPassword);

        //set the reset password key and time so the key can no longer be used
        user.getUserDetails().setResetPasswordKey(null);
        user.getUserDetails().setResetPasswordRequestTime(null);
        userService.updateUser(user);

        //get the user name
        String username = user.getUserDetails().getUsername();

        //get the portal name
        String portalName = wiseProperties.getProperty("wise.name");

        //get the user's email
        String userEmail = user.getUserDetails().getEmailAddress();
        String[] recipients = new String[] { userEmail };

        // get user Locale
        Locale userLocale = request.getLocale();

        // subject looks like this: "Notification from WISE4@Berkeley: Password Changed"
        String defaultSubject = messageSource.getMessage(
                "forgotaccount.teacher.index.passwordChangedEmailSubject", new Object[] { portalName },
                Locale.US);
        String subject = messageSource.getMessage("forgotaccount.teacher.index.passwordChangedEmailSubject",
                new Object[] { portalName }, defaultSubject, userLocale);
        String defaultBody = messageSource.getMessage("forgotaccount.teacher.index.passwordChangedEmailBody",
                new Object[] { username, portalName }, Locale.US);
        String body = messageSource.getMessage("forgotaccount.teacher.index.passwordChangedEmailBody",
                new Object[] { username, portalName }, defaultBody, userLocale);

        // send password in the email here
        mailService.postMail(recipients, subject, body, userEmail);

        //passwords are the same so we will change their password
        bindingResult.reject("changePassword_success");

        //tell the jsp to display the success message
        request.setAttribute("passwordResetSuccess", true);

        //do not display the "Forgot Username or Password?" link
        model.addAttribute("displayForgotPasswordSelectAccountTypeLink", false);

        //display the sign in button
        model.addAttribute("displayLoginLink", true);
    }

    return view;
}

From source file:pl.otros.logview.gui.actions.search.StringContainsSearchMatcher.java

@Override
public boolean matches(LogData logData) {
    return StringUtils.contains(StringUtils.lowerCase(logData.getMessage()), searchChar);
}

From source file:pt.ist.maidSyncher.domain.activeCollab.ACProject.java

private SyncActionWrapper syncCreateEvent(final SyncEvent syncEvent) {
    final Set<String> tickedDescriptors = new HashSet<>();
    for (String changedDescriptor : syncEvent.getChangedPropertyDescriptorNames().getUnmodifiableList()) {
        tickedDescriptors.add(changedDescriptor);
        switch (changedDescriptor) {
        case DSC_PERMALINK:
        case DSC_UPDATED_BY_ID:
        case DSC_UPDATED_ON:
        case DSC_BUDGET:
        case DSC_ID:
        case DSC_CREATED_ON:
        case DSC_OVERVIEW:
        case DSC_URL:
        case DSC_CREATED_BY_ID:
            break; //the ones above, there'se no sense in changing anything
        case DSC_TYPE:
        case DSC_ARCHIVED:
        case DSC_NAME:
        case DSC_STATUS:
            break;
        default:/*from   ww w.  j  a v a 2  s.  c om*/
            tickedDescriptors.remove(changedDescriptor); //if we did not fall on any of the above
            //cases, let's remove it from the ticked descriptors

        }

    }

    return new SyncActionWrapper<SynchableObject>() {

        @Override
        public Set<SynchableObject> sync() throws SyncActionError {
            Set<SynchableObject> changedObjects = new HashSet<>();
            try {
                if (getArchived())
                    return Collections.emptySet();
                Set<GHLabel> labelsToAssignToDSIProject = new HashSet<GHLabel>();
                //let us get all of the repositories we need to create a label for
                Set<GHRepository> repositoriesWeNeedToCreateLabelsFor = new HashSet(
                        MaidRoot.getInstance().getGhRepositoriesSet());

                final Set<GHLabel> appliableAndAlreadyExistingLabels = GHLabel
                        .getAllLabelsWith(GHLabel.PROJECT_PREFIX + getName());
                for (GHLabel ghLabel : appliableAndAlreadyExistingLabels) {
                    repositoriesWeNeedToCreateLabelsFor.remove(ghLabel.getRepository());
                    labelsToAssignToDSIProject.add(ghLabel);
                }

                //let us create the labels we need to
                LabelService labelService = new LabelService(MaidRoot.getGitHubClient());
                for (GHRepository ghRepository : repositoriesWeNeedToCreateLabelsFor) {
                    Label newLabel = new Label();
                    newLabel.setName(GHLabel.PROJECT_PREFIX + getName());
                    Label newlyCreatedLabel = labelService.createLabel(ghRepository, newLabel);
                    labelsToAssignToDSIProject
                            .add(GHLabel.process(newlyCreatedLabel, ghRepository.getId(), true));
                }

                //let us remove the old labels and set the new ones on
                //the appropriate DSIProject relation
                DSIProject dsiProject = (DSIProject) getDSIObject();
                dsiProject.getGitHubLabelsSet().clear();
                dsiProject.getGitHubLabelsSet().addAll(labelsToAssignToDSIProject);

                changedObjects.addAll(labelsToAssignToDSIProject);
                //now let's take care of the TaskCategory, i.e., we created a new ACProject
                //thus we need to create a taskcategory for each repository
                Set<ACTaskCategory> taskCategoriesDefined = getTaskCategoriesDefinedSet();
                Set<String> taskCategoriesNames = new HashSet<>(
                        Collections2.transform(taskCategoriesDefined, new Function<ACTaskCategory, String>() {

                            @Override
                            public String apply(ACTaskCategory acTaskCategory) {
                                if (acTaskCategory == null)
                                    return null;
                                return StringUtils.lowerCase(acTaskCategory.getName());
                            }
                        }));

                Set<ACCategory> taskCategoriesToCreate = new HashSet<>();

                Set<GHRepository> repositoriesToCreateTaskCategoriesFor = new HashSet(
                        MaidRoot.getInstance().getGhRepositoriesSet());

                Iterator<GHRepository> repoIterator = repositoriesToCreateTaskCategoriesFor.iterator();
                //let's see if any of them are appropriate to be used
                while (repoIterator.hasNext()) {
                    GHRepository ghRepository = repoIterator.next();
                    String taskCategoryName = StringUtils
                            .lowerCase(ACTaskCategory.REPOSITORY_PREFIX + ghRepository.getName());
                    if (taskCategoriesNames.contains(taskCategoryName))
                        repoIterator.remove();

                }

                for (GHRepository ghRepository : repositoriesToCreateTaskCategoriesFor) {
                    String taskCategoryToCreateName = ACTaskCategory.REPOSITORY_PREFIX + getName();
                    if (taskCategoriesNames
                            .contains(StringUtils.lowerCase(taskCategoryToCreateName)) == false) {
                        ACCategory acCategory = new ACCategory();
                        acCategory.setName(taskCategoryToCreateName);
                        changedObjects.add(ACTaskCategory.process(
                                ACCategory.create(acCategory, getId(), ACTaskCategory.class), getId(), true));
                    }

                }
            } catch (IOException ex) {
                throw new SyncActionError(ex, changedObjects);
            }

            return changedObjects;
        }

        @Override
        public Collection<String> getPropertyDescriptorNamesTicked() {
            return tickedDescriptors;
        }

        @Override
        public SyncEvent getOriginatingSyncEvent() {
            return syncEvent;
        }

        @Override
        public Collection<DSIObject> getSyncDependedDSIObjects() {
            return Collections.emptySet();
        }

        @Override
        public Set<Class> getSyncDependedTypesOfDSIObjects() {
            return Collections.emptySet();
        }
    };
}

From source file:pt.webdetails.cdb.CdbContentGenerator.java

@Override
protected Method getMethod(String methodName) throws NoSuchMethodException {
    Method method = exposedMethods.get(StringUtils.lowerCase(methodName));
    if (method == null) {
        throw new NoSuchMethodException();
    }/*w  ww. j av a 2  s  .  c o m*/
    return method;
}