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();
}
}
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();
}
}
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));
}
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);
}
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);
}
Aggregations