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

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

Introduction

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

Prototype

public static String upperCase(final String str) 

Source Link

Document

Converts a String to upper case as per String#toUpperCase() .

A null input String returns null .

 StringUtils.upperCase(null)  = null StringUtils.upperCase("")    = "" StringUtils.upperCase("aBc") = "ABC" 

Note: As described in the documentation for String#toUpperCase() , the result of this method is affected by the current locale.

Usage

From source file:org.meruvian.yama.showcase.interceptor.SessionCredentialInterceptor.java

@Override
public String intercept(ActionInvocation invocation) throws Exception {
    ValueStack stack = invocation.getStack();
    stack.set("currentUser", sessionCredential.getCurrentUser());
    stack.set("adminRole", adminRole);

    List<String> roles = sessionCredential.getCurrentRoles();
    boolean isAdmin = roles.contains(StringUtils.upperCase(adminRole));

    stack.set("currentRoles", roles);
    stack.set("isAdmin", isAdmin);

    return invocation.invoke();
}

From source file:org.mitre.mpf.wfm.camel.operations.markup.MarkupStageSplitter.java

@Override
public final List<Message> performSplit(TransientJob transientJob, TransientStage transientStage)
        throws Exception {
    List<Message> messages = new ArrayList<>();

    int lastDetectionStageIndex = findLastDetectionStageIndex(transientJob.getPipeline());

    hibernateMarkupResultDao.deleteByJobId(transientJob.getId());

    for (int actionIndex = 0; actionIndex < transientStage.getActions().size(); actionIndex++) {
        int mediaIndex = 0;
        TransientAction transientAction = transientStage.getActions().get(actionIndex);
        for (TransientMedia transientMedia : transientJob.getMedia()) {
            if (transientMedia.isFailed()) {
                log.debug("Skipping '{}' - it is in an error state.", transientMedia.getId(),
                        transientMedia.getLocalPath());
                continue;
            } else if (!StringUtils.startsWith(transientMedia.getType(), "image")
                    && !StringUtils.startsWith(transientMedia.getType(), "video")) {
                log.debug("Skipping Media {} - only image and video files are eligible for markup.",
                        transientMedia.getId());
            } else {
                List<Markup.BoundingBoxMapEntry> boundingBoxMapEntryList = createMap(transientJob.getId(),
                        transientMedia, lastDetectionStageIndex,
                        transientJob.getPipeline().getStages().get(lastDetectionStageIndex))
                                .toBoundingBoxMapEntryList();
                Markup.MarkupRequest markupRequest = Markup.MarkupRequest.newBuilder().setMediaIndex(mediaIndex)
                        .setTaskIndex(transientJob.getCurrentStage()).setActionIndex(actionIndex)
                        .setMediaId(transientMedia.getId())
                        .setMediaType(Markup.MediaType.valueOf(StringUtils.upperCase(
                                transientMedia.getType().substring(0, transientMedia.getType().indexOf('/')))))
                        .setRequestId(redis.getNextSequenceValue())
                        .setSourceUri(//  w ww.  java  2 s .  co m
                                new File(transientMedia.getLocalPath()).getAbsoluteFile().toURI().toString())
                        .setDestinationUri(
                                boundingBoxMapEntryList.size() > 0
                                        ? propertiesUtil
                                                .createMarkupPath(transientJob.getId(), transientMedia.getId(),
                                                        getMarkedUpMediaExtensionForMediaType(
                                                                transientMedia.getMediaType()))
                                                .toUri().toString()
                                        : propertiesUtil
                                                .createMarkupPath(transientJob.getId(), transientMedia.getId(),
                                                        getFileExtension(transientMedia.getType()))
                                                .toUri().toString())
                        .addAllMapEntries(boundingBoxMapEntryList).build();

                DefaultMessage message = new DefaultMessage(); // We will sort out the headers later.
                message.setHeader(MpfHeaders.RECIPIENT_QUEUE, String.format("jms:MPF.%s_%s_REQUEST",
                        transientStage.getActionType(), transientAction.getAlgorithm()));
                message.setHeader(MpfHeaders.JMS_REPLY_TO,
                        StringUtils.replace(MpfEndpoints.COMPLETED_MARKUP, "jms:", ""));
                message.setBody(markupRequest);
                messages.add(message);
            }
            mediaIndex++;
        }
    }

    return messages;
}

From source file:org.mitre.mpf.wfm.data.entities.transients.Track.java

/**
 * Creates a new track instance with the given immutable parameters.
 *
 * @param jobId The job with which this track is associated.
 * @param mediaId The medium with which this track is associated.
 * @param stageIndex The stage of the pipeline containing the action with which this track is associated.
 * @param actionIndex The index of the action in the stage of the pipeline which created this track.
 * @param startOffsetFrameInclusive The zero-based index where the track begins in the medium. Frame number is relevant for image and video files.
 * @param endOffsetFrameInclusive The zero-based and inclusive stop index where the track ends in the medium. Frame number is relevant for image and video files.
 * @param startOffsetTimeInclusive The zero-based index where the track begins in the medium. Time is given in milliseconds, and is relevant for video and audio files.
 * @param endOffsetTimeInclusive The zero-based and inclusive stop index where the track ends in the medium. Time is given in milliseconds, and is relevant for video and audio files.
 * @param type The type of object associated with this track. This value is trimmed (to null) and converted to uppercase for convenience.
 *///from   w w  w. j  a  v  a 2  s.co m
@JsonCreator
public Track(@JsonProperty("jobId") long jobId, @JsonProperty("mediaId") long mediaId,
        @JsonProperty("stageIndex") int stageIndex, @JsonProperty("actionIndex") int actionIndex,
        @JsonProperty("startOffsetFrameInclusive") int startOffsetFrameInclusive,
        @JsonProperty("endOffsetFrameInclusive") int endOffsetFrameInclusive,
        @JsonProperty("startOffsetTimeInclusive") int startOffsetTimeInclusive,
        @JsonProperty("endOffsetTimeInclusive") int endOffsetTimeInclusive, @JsonProperty("type") String type) {
    this.jobId = jobId;
    this.mediaId = mediaId;
    this.stageIndex = stageIndex;
    this.actionIndex = actionIndex;
    this.startOffsetFrameInclusive = startOffsetFrameInclusive;
    this.endOffsetFrameInclusive = endOffsetFrameInclusive;
    this.startOffsetTimeInclusive = startOffsetTimeInclusive;
    this.endOffsetTimeInclusive = endOffsetTimeInclusive;
    this.type = StringUtils.upperCase(StringUtils.trimToNull(type));
    this.detections = new TreeSet<Detection>();
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/** Gets an ActionDefinition by name (case-insensitive). */
public ActionDefinition getAction(String name) {
    return actions.get(StringUtils.upperCase(name));
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

public List<TaskDefinition> getTasks(String pipelineName) {
    List<TaskDefinition> taskDefinitions = new ArrayList<TaskDefinition>();
    for (TaskDefinitionRef taskDefinitionRef : pipelines.get(StringUtils.upperCase(pipelineName))
            .getTaskRefs()) {/*from  w  w  w  .ja v a2  s  .c o m*/
        taskDefinitions.add(getTask(taskDefinitionRef));
    }
    return taskDefinitions;
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/**
 * Gets a TaskDefinition by name (case-insensitive).
 */
public TaskDefinition getTask(String name) {
    return tasks.get(StringUtils.upperCase(name));
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/** Gets a PipelineDefinition by name (case-insensitive). */
public PipelineDefinition getPipeline(String name) {
    return pipelines.get(StringUtils.upperCase(name));
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/** Adds an algorithm. This will return false if the algorithm could not be added. */
public boolean addAlgorithm(AlgorithmDefinition algorithm) {
    if (isValidAlgorithm(algorithm)) {
        log.debug("{}: Adding algorithm", StringUtils.upperCase(algorithm.getName()));
        algorithms.put(StringUtils.upperCase(algorithm.getName()), algorithm);
        return true;
    } else {//from  ww  w . j a  va  2 s  .c om
        log.warn("{}: This algorithm was not added.", algorithm);
        return false;
    }
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/** Adds an action. This will return false if the action could not be added. */
public boolean addAction(ActionDefinition actionNode) {
    if (isValidAction(actionNode)) {
        log.debug("{}: Adding action", StringUtils.upperCase(actionNode.getName()));
        actions.put(StringUtils.upperCase(actionNode.getName()), actionNode);
        return true;
    } else {//from ww  w  . ja  va  2s  .  c o m
        log.warn("{}: This action was not added.", actionNode);
        return false;
    }
}

From source file:org.mitre.mpf.wfm.pipeline.PipelineManager.java

/** Adds a task. This will return false if the task could not be added. */
public boolean addTask(TaskDefinition task) {
    if (!isValidTask(task)) {
        log.warn("{}: This task was not added.", task);
        return false;
    }//  ww  w .ja va2s.  c o  m

    log.debug("{}: Adding task", StringUtils.upperCase(task.getName()));
    tasks.put(StringUtils.upperCase(task.getName()), task);
    for (ActionDefinitionRef actionRef : task.getActions()) {
        AlgorithmDefinition algorithm = getAlgorithm(actionRef);
        String taskName = StringUtils.upperCase(task.getName());

        if (algorithm.getProvidesCollection() != null
                && algorithm.getProvidesCollection().getStates() != null) {
            providedTaskStates.put(taskName, algorithm.getProvidesCollection().getStates());
        } else {
            providedTaskStates.put(taskName, Collections.emptySet());
        }

        if (algorithm.getRequiresCollection() != null
                && algorithm.getRequiresCollection().getStateRefs() != null) {
            requiredTaskStates.put(taskName, algorithm.getRequiresCollection().getStateRefs());
        } else {
            requiredTaskStates.put(taskName, Collections.emptySet());
        }
    }
    return true;
}