Search in sources :

Example 6 with Util

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

the class ResourceController method validateActiveProjectId.

@Util
private static boolean validateActiveProjectId(String activeProjectId) {
    if (StringUtils.isNotBlank(activeProjectId)) {
        URI activeProjectIdUri = URI.create(activeProjectId);
        String tenantId = Models.currentAdminTenant();
        List<ProjectRestRep> projects = getProjects(tenantId);
        for (ProjectRestRep project : projects) {
            if (project.getId().equals(activeProjectIdUri)) {
                return true;
            }
        }
    }
    return false;
}
Also used : ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) AppSupportUtil(util.AppSupportUtil) Util(play.mvc.Util)

Example 7 with Util

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

the class Projects method saveProjectACLs.

@Util
private static void saveProjectACLs(String projectId, List<AclEntryForm> aclEntries) {
    List<ACLEntry> currentProjectAcls = ProjectUtils.getACLs(projectId);
    ACLAssignmentChanges changes = new ACLAssignmentChanges();
    changes.getAdd().addAll(AclEntryForm.getAddedAcls(currentProjectAcls, aclEntries));
    changes.getRemove().addAll(AclEntryForm.getRemovedAcls(currentProjectAcls, aclEntries));
    try {
        ProjectUtils.updateACLs(projectId, changes);
    } catch (ViPRException e) {
        Logger.error(e, "Failed to update Project ACLs");
        String errorDesc = e.getMessage();
        if (e instanceof ServiceErrorException) {
            errorDesc = ((ServiceErrorException) e).getDetailedMessage();
        }
        flash.error(MessagesUtils.get("projects.updateProjectACLs.failed", errorDesc));
    }
}
Also used : ACLAssignmentChanges(com.emc.storageos.model.auth.ACLAssignmentChanges) ACLEntry(com.emc.storageos.model.auth.ACLEntry) ViPRException(com.emc.vipr.client.exceptions.ViPRException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Util(play.mvc.Util)

Example 8 with Util

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

the class Tenants method addRenderArgs.

@Util
private static void addRenderArgs(TenantForm tenant) {
    List<String> domains = Lists.newArrayList();
    for (AuthnProviderRestRep authProvider : AuthnProviderUtils.getAuthnProviders()) {
        if (!authProvider.getDisable()) {
            domains.addAll(authProvider.getDomains());
        }
    }
    Gson g = new Gson();
    renderArgs.put("domainsJson", g.toJson(domains));
    List<StringOption> allNamespace = TenantUtils.getUnmappedNamespace();
    renderArgs.put("namespaceOptions", allNamespace);
}
Also used : Gson(com.google.gson.Gson) AuthnProviderRestRep(com.emc.storageos.model.auth.AuthnProviderRestRep) Util(play.mvc.Util)

Example 9 with Util

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

the class Notifications method getNotifications.

@Util
public static List<Notification> getNotifications() {
    ViPRCatalogClient2 catalog = getCatalogClient();
    List<Notification> notifications = Lists.newArrayList();
    List<ApprovalRestRep> approvals = catalog.approvals().search().byStatus(ApprovalRestRep.PENDING).run();
    for (ApprovalRestRep approval : approvals) {
        if (approval.getOrder() != null) {
            OrderRestRep order = getOrder(approval.getOrder());
            if (order != null) {
                CatalogServiceRestRep service = getCatalogService(order.getCatalogService());
                Notification notification = new Notification();
                notification.id = approval.getId().toString();
                notification.orderId = order.getId().toString();
                if (service != null) {
                    notification.image = service.getImage();
                    notification.message = MessagesUtils.get("notification.approvalPending", service.getTitle(), order.getSubmittedBy());
                }
                notification.lastUpdated = approval.getDateActioned() != null ? approval.getDateActioned() : approval.getCreationTime().getTime();
                notifications.add(notification);
            }
        }
    }
    return notifications;
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) Util(play.mvc.Util)

Example 10 with Util

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

the class FileProtectionPolicies method addRenderArgs.

@Util
private static void addRenderArgs() {
    List<StringOption> policyTypeOptions = Lists.newArrayList();
    policyTypeOptions.add(new StringOption("file_snapshot", MessagesUtils.get("schedulePolicy.snapshot")));
    policyTypeOptions.add(new StringOption("file_replication", MessagesUtils.get("schedulePolicy.replication")));
    renderArgs.put("policyTypeOptions", policyTypeOptions);
    List<StringOption> replicationTypeOptions = Lists.newArrayList();
    replicationTypeOptions.add(new StringOption("REMOTE", MessagesUtils.get("schedulePolicy.replicationRemote")));
    replicationTypeOptions.add(new StringOption("LOCAL", MessagesUtils.get("schedulePolicy.replicationLocal")));
    renderArgs.put("replicationTypeOptions", replicationTypeOptions);
    List<StringOption> replicationCopyTypeOptions = Lists.newArrayList();
    replicationCopyTypeOptions.add(new StringOption("ASYNC", MessagesUtils.get("schedulePolicy.replicationAsync")));
    renderArgs.put("replicationCopyTypeOptions", replicationCopyTypeOptions);
    List<StringOption> policyPriorityOptions = Lists.newArrayList();
    policyPriorityOptions.add(new StringOption("Normal", MessagesUtils.get("schedulePolicy.priorityNormal")));
    policyPriorityOptions.add(new StringOption("High", MessagesUtils.get("schedulePolicy.priorityHigh")));
    renderArgs.put("policyPriorityOptions", policyPriorityOptions);
}
Also used : StringOption(util.StringOption) 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