Search in sources :

Example 51 with FlashException

use of controllers.util.FlashException in project coprhd-controller by CoprHD.

the class Projects method save.

@FlashException(keep = true, referrer = { "create", "edit" })
public static void save(ProjectForm project) {
    if (project == null) {
        Logger.error("No project parameters passed");
        badRequest("No project parameters passed");
        return;
    }
    project.validate("project");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    if (project.isNew()) {
        project.id = stringId(ProjectUtils.create(project.tenantId, new ProjectParam(project.name)));
        saveProjectQuota(project);
        saveProjectACLs(project.id, project.aclEntries);
    } else {
        ProjectRestRep currentProject = ProjectUtils.getProject(project.id);
        if (currentProject != null) {
            saveProjectQuota(project);
            saveProjectACLs(project.id, project.aclEntries);
            ProjectUtils.update(project.id, new ProjectUpdateParam(project.name, project.owner));
        }
    }
    flash.success(MessagesUtils.get("projects.saved", project.name));
    JsonObject jobject = getCookieAsJson(VIPR_START_GUIDE);
    if (jobject != null && jobject.get(GUIDE_COMPLETED_STEP) != null && jobject.get(GUIDE_VISIBLE) != null) {
        if (jobject.get("completedSteps").getAsInt() == 7 && jobject.get("guideVisible").getAsBoolean()) {
            JsonObject dataObject = getCookieAsJson(GUIDE_DATA);
            JsonArray projects = dataObject.getAsJsonArray("projects");
            if (projects == null) {
                projects = new JsonArray();
            }
            boolean addToCookie = true;
            for (Object projectObject : projects) {
                JsonObject projectjson = (JsonObject) projectObject;
                if (projectjson.get("id") != null) {
                    String projectId = projectjson.get("id").getAsString();
                    if (StringUtils.equals(projectId, project.id)) {
                        // update case, don't add in cookie
                        addToCookie = false;
                        break;
                    }
                }
            }
            if (addToCookie) {
                JsonObject projectObject = new JsonObject();
                projectObject.addProperty("id", project.id);
                projectObject.addProperty("name", project.name);
                projects.add(projectObject);
                dataObject.add("projects", projects);
                saveJsonAsCookie("GUIDE_DATA", dataObject);
            }
        }
    }
    if (StringUtils.isNotBlank(project.referrerUrl)) {
        redirect(project.referrerUrl);
    } else {
        list();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ProjectParam(com.emc.storageos.model.project.ProjectParam) ProjectUpdateParam(com.emc.storageos.model.project.ProjectUpdateParam) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 52 with FlashException

use of controllers.util.FlashException in project coprhd-controller by CoprHD.

the class Projects method edit.

@FlashException(value = "list", keep = true)
public static void edit(String id) {
    ProjectRestRep viprProject = ProjectUtils.getProject(id);
    if (viprProject == null) {
        flash.error(MessagesUtils.get(UNKNOWN, id));
        list();
    }
    QuotaInfo quota = null;
    if (Security.isTenantAdmin()) {
        quota = ProjectUtils.getQuota(id);
    }
    if (viprProject != null) {
        ProjectForm project = new ProjectForm().from(viprProject, quota);
        project.aclEntries = AclEntryForm.loadAclEntryForms(ProjectUtils.getACLs(id));
        addRenderArgs();
        render(project);
    } else {
        flash.error(MessagesUtils.get("projects.unknown", id));
        list();
    }
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 53 with FlashException

use of controllers.util.FlashException in project coprhd-controller by CoprHD.

the class Projects method listJson.

@FlashException(value = "list", keep = true)
public static void listJson() {
    String userId = Security.getUserInfo().getIdentifier();
    List<ProjectRestRep> viprProjects = ProjectUtils.getProjects(Models.currentAdminTenant());
    List<ProjectsDataTable.Project> projects = Lists.newArrayList();
    for (ProjectRestRep viprProject : viprProjects) {
        if (Security.isTenantAdmin() || (Security.isProjectAdmin() && StringUtils.equalsIgnoreCase(userId, viprProject.getOwner()))) {
            projects.add(new ProjectsDataTable.Project(viprProject));
        }
    }
    renderJSON(DataTablesSupport.createJSON(projects, params));
}
Also used : ProjectsDataTable(models.datatable.ProjectsDataTable) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 54 with FlashException

use of controllers.util.FlashException in project coprhd-controller by CoprHD.

the class VirtualArrays method addNetworks.

/**
 * Adds a number of networks to the given virtual array, and redisplays the networks page.
 *
 * @param virtualArrayId
 *            the virtual array ID.
 * @param ids
 *            the IDs of the networks to add.
 */
@FlashException
public static void addNetworks(String virtualArrayId, @As(",") String[] ids) {
    if ((ids == null) || (ids.length == 0)) {
        networks(virtualArrayId);
    }
    VirtualArrayRestRep virtualArray = getVirtualArray(virtualArrayId);
    updateNetworks(uris(ids), addVirtualArray(virtualArray));
    networks(virtualArrayId);
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) FlashException(controllers.util.FlashException)

Example 55 with FlashException

use of controllers.util.FlashException in project coprhd-controller by CoprHD.

the class VirtualArrays method addStorageSystems.

/**
 * Adds all ports of the given storage systems to the virtual array.
 *
 * @param virtualArrayId
 *            the virtual array ID.
 * @param ids
 *            the storage system IDs.
 */
@FlashException(referrer = { "edit", "list" })
public static void addStorageSystems(String virtualArrayId, @As(",") String[] ids) {
    List<URI> storagePorts = Lists.newArrayList();
    for (URI storageSystemId : uris(ids)) {
        List<StoragePortRestRep> ports = StoragePortUtils.getStoragePortsByStorageSystem(storageSystemId);
        storagePorts.addAll(ResourceUtils.ids(ports));
    }
    if (!storagePorts.isEmpty()) {
        VirtualArrayRestRep virtualArray = getVirtualArray(virtualArrayId);
        updateStoragePorts(storagePorts, addVirtualArray(virtualArray));
    }
    edit(virtualArrayId);
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) URI(java.net.URI) FlashException(controllers.util.FlashException)

Aggregations

FlashException (controllers.util.FlashException)122 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)45 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)9 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)9 URI (java.net.URI)9 ExportUpdateParam (com.emc.storageos.model.block.export.ExportUpdateParam)8 Restrictions (controllers.deadbolt.Restrictions)8 ArrayList (java.util.ArrayList)7 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)6 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 CopiesParam (com.emc.storageos.model.block.CopiesParam)4 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)4 ExportRule (com.emc.storageos.model.file.ExportRule)4 ExportRules (com.emc.storageos.model.file.ExportRules)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)4 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)4 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)4 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)2