Search in sources :

Example 11 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class Common method toSafeRedirectURL.

@Util
public static String toSafeRedirectURL(String url) {
    String cleanUrl = "";
    try {
        // Remove Host and port from referrer
        URI uriObject = new URI(url);
        cleanUrl += uriObject.getPath();
        String query = uriObject.getQuery();
        if (!StringUtils.isBlank(query)) {
            cleanUrl += "?" + query;
        }
    } catch (URISyntaxException ignore) {
        Logger.error(ignore.getMessage());
    }
    return cleanUrl;
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) BourneUtil(util.BourneUtil) Util(play.mvc.Util)

Example 12 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class TaskUtils method getTaskSummary.

@Util
public static TaskSummary getTaskSummary(TaskResourceRep task) {
    TaskSummary taskSummary = new TaskSummary(task);
    if (task != null && task.getResource() != null && task.getResource().getId() != null) {
        ResourceType resourceType = ResourceType.fromResourceId(task.getResource().getId().toString());
        taskSummary.resourceType = resourceType.name();
    }
    taskSummary.orderId = TagUtils.getOrderIdTagValue(task);
    taskSummary.orderNumber = TagUtils.getOrderNumberTagValue(task);
    if (Security.isSystemAdmin() || Security.isSystemMonitor()) {
        if (task.getWorkflow() != null && task.getWorkflow().getId() != null) {
            taskSummary.steps = getWorkflowSteps(task.getWorkflow().getId());
        }
    }
    return taskSummary;
}
Also used : ResourceType(com.emc.sa.util.ResourceType) URIUtil(com.emc.storageos.db.client.URIUtil) Util(play.mvc.Util)

Example 13 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class VirtualArrays method getVirtualArray.

/**
 * Gets the given virtual array. If the array cannot be found, an error is show and redirects back to the referrer
 * or to the list page.
 *
 * @param id
 *            the virtual array ID.
 * @return the virtual array.
 */
@Util
public static VirtualArrayRestRep getVirtualArray(String id) {
    VirtualArrayRestRep virtualArray = VirtualArrayUtils.getVirtualArray(id);
    if (virtualArray == null) {
        flash.error(MessagesUtils.get(UNKNOWN, id));
        backToReferrer();
        list();
    }
    return virtualArray;
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) BourneUtil(util.BourneUtil) Util(play.mvc.Util)

Example 14 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class Common method handleExpiredToken.

@Util
public static void handleExpiredToken(Throwable throwable) {
    if (throwable instanceof ViPRHttpException) {
        ViPRHttpException ve = (ViPRHttpException) throwable;
        if (ve.getHttpCode() == HttpStatus.SC_UNAUTHORIZED) {
            Logger.info("Clearing auth token");
            // Auth token may have expired
            Security.clearAuthToken();
            Security.redirectToAuthPage();
        }
    }
}
Also used : ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) BourneUtil(util.BourneUtil) Util(play.mvc.Util)

Example 15 with Util

use of play.mvc.Util in project coprhd-controller by CoprHD.

the class BlockVolumes method createCopiesParam.

@Util
private static CopiesParam createCopiesParam(String continuousCopyId) {
    Copy copy = new Copy();
    copy.setType(COPY_NATIVE);
    copy.setCopyID(uri(continuousCopyId));
    List<Copy> copies = Lists.newArrayList();
    copies.add(copy);
    CopiesParam input = new CopiesParam(copies);
    return input;
}
Also used : Copy(com.emc.storageos.model.block.Copy) CopiesParam(com.emc.storageos.model.block.CopiesParam) BourneUtil(util.BourneUtil) Util(play.mvc.Util)

Aggregations

Util (play.mvc.Util)23 BourneUtil (util.BourneUtil)7 URI (java.net.URI)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)3 UserInfo (models.security.UserInfo)3 ResourceType (com.emc.sa.util.ResourceType)2 URIUtil (com.emc.storageos.db.client.URIUtil)2 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)2 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)2 Parameter (com.emc.vipr.model.catalog.Parameter)2 ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)2 BreadCrumb (models.BreadCrumb)2 DataObjectRestRep (com.emc.storageos.model.DataObjectRestRep)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 ACLAssignmentChanges (com.emc.storageos.model.auth.ACLAssignmentChanges)1 ACLEntry (com.emc.storageos.model.auth.ACLEntry)1 AuthnProviderRestRep (com.emc.storageos.model.auth.AuthnProviderRestRep)1 CopiesParam (com.emc.storageos.model.block.CopiesParam)1 Copy (com.emc.storageos.model.block.Copy)1 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)1