use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class FileSystems method getReplicationPolicy.
private static FilePolicyRestRep getReplicationPolicy(ViPRCoreClient client, FileShareRestRep fs) {
if (fs != null) {
// Check file system vpool has replication policy!!!
FileVirtualPoolRestRep vpool = client.fileVpools().get(fs.getVirtualPool().getId());
if (vpool != null && vpool.getFileProtectionPolicies() != null && !vpool.getFileProtectionPolicies().isEmpty()) {
for (String uriPolicy : vpool.getFileProtectionPolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType())) {
return policyRestRep;
}
}
}
// Check file system project has replication policy!!!
ProjectRestRep project = client.projects().get(fs.getProject().getId());
if (project != null && project.getFileProtectionPolicies() != null && !project.getFileProtectionPolicies().isEmpty()) {
for (String uriPolicy : project.getFileProtectionPolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType()) && policyRestRep.getVpool() != null && policyRestRep.getVpool().getId() != null && policyRestRep.getVpool().getId().equals(vpool.getId())) {
return policyRestRep;
}
}
}
// Check file system has replication policy!!!
if (fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
for (String uriPolicy : fs.getFilePolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType())) {
return policyRestRep;
}
}
}
}
return null;
}
use of com.emc.storageos.model.project.ProjectRestRep 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;
}
use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class VirtualNasServers method getVirtualNasServers.
private static List<VirtualNasServerInfo> getVirtualNasServers(String projectId) {
if (projectId == null) {
return Collections.EMPTY_LIST;
}
List<VirtualNasServerInfo> vNasServers = Lists.newArrayList();
ProjectRestRep projRestRep = getViprClient().projects().get(uri(projectId));
Set<String> vNasIds = projRestRep.getAssignedVNasServers();
List<URI> vNasUris = Lists.newArrayList();
if (vNasIds != null) {
for (String id : vNasIds) {
vNasUris.add(uri(id));
}
if (!vNasUris.isEmpty()) {
List<VirtualNASRestRep> vNas = getViprClient().virtualNasServers().getByIds(vNasUris);
for (VirtualNASRestRep vNasServer : vNas) {
vNasServers.add(new VirtualNasServerInfo(vNasServer, true));
}
}
}
return vNasServers;
}
use of com.emc.storageos.model.project.ProjectRestRep in project coprhd-controller by CoprHD.
the class Projects method delete.
@FlashException("list")
public static void delete(@As(",") String[] ids) {
String tenantId = null;
if (ids != null && ids.length > 0) {
ProjectRestRep project = ProjectUtils.getProject(ids[0]);
if (project != null) {
tenantId = project.getTenant().toString();
}
for (String id : ids) {
ProjectUtils.deactivate(uri(id));
}
flash.success(MessagesUtils.get("projects.deleted"));
}
list();
}
use of com.emc.storageos.model.project.ProjectRestRep 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();
}
}
Aggregations