use of controllers.deadbolt.Restrictions in project coprhd-controller by CoprHD.
the class DisasterRecovery method switchover.
@FlashException("list")
@Restrictions({ @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void switchover(String id) {
String standby_name = null;
String standby_vip = null;
String active_name = null;
Boolean isSwitchover = false;
// Get active site details
SiteRestRep activesite = DisasterRecoveryUtils.getActiveSite();
active_name = activesite == null ? "N/A" : activesite.getName();
SiteRestRep result = DisasterRecoveryUtils.getSite(id);
if (result != null) {
// Check Switchover or Failover
SiteActive currentSite = DisasterRecoveryUtils.checkActiveSite();
if (currentSite.getIsActive() == true) {
DisasterRecoveryUtils.doSwitchover(id);
isSwitchover = true;
} else {
DisasterRecoveryUtils.doFailover(id);
isSwitchover = false;
}
standby_name = result.getName();
standby_vip = result.getVipEndpoint();
}
String site_uuid = id;
maintenance(active_name, standby_name, standby_vip, site_uuid, isSwitchover);
}
use of controllers.deadbolt.Restrictions in project coprhd-controller by CoprHD.
the class DisasterRecovery method edit.
@Restrictions({ @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void edit(String id) {
SiteRestRep siteRest = DisasterRecoveryUtils.getSite(id);
if (siteRest != null) {
DisasterRecoveryForm disasterRecovery = new DisasterRecoveryForm(siteRest);
edit(disasterRecovery);
} else {
flash.error(MessagesUtils.get(UNKNOWN, id));
list();
}
}
use of controllers.deadbolt.Restrictions in project coprhd-controller by CoprHD.
the class DisasterRecovery method resume.
@FlashException("list")
@Restrictions({ @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN"), @Restrict("SYSTEM_ADMIN"), @Restrict("RESTRICTED_SYSTEM_ADMIN") })
public static void resume(String id) {
SiteRestRep result = DisasterRecoveryUtils.getSite(id);
if (result != null) {
SiteRestRep siteresume = DisasterRecoveryUtils.resumeStandby(id);
flash.success(MessagesUtils.get(RESUMED_SUCCESS, siteresume.getName()));
}
list();
}
use of controllers.deadbolt.Restrictions in project coprhd-controller by CoprHD.
the class VirtualDataCenters method save.
@FlashException(keep = true, referrer = { "create", "edit" })
@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void save(VirtualDataCenterForm vdc) {
vdc.validate("vdc");
if (Validation.hasErrors()) {
Common.handleError();
}
if (vdc.isNew()) {
VirtualDataCenterAddParam vdcToAdd = new VirtualDataCenterAddParam();
vdcToAdd.setName(vdc.name);
vdcToAdd.setApiEndpoint(vdc.apiEndpoint);
vdcToAdd.setDescription(vdc.description);
vdcToAdd.setSecretKey(vdc.secretKey);
try {
vdcToAdd.setCertificateChain(FileUtils.readFileToString(vdc.certChain));
} catch (Exception e) {
flash.error(MessagesUtils.get("vdc.certChain.invalid.error"));
Common.handleError();
}
Task<VirtualDataCenterRestRep> task = VirtualDataCenterUtils.create(vdcToAdd);
flash.put("inProgressTask", task.getTaskResource().getId());
} else {
VirtualDataCenterRestRep currentVDC = VirtualDataCenterUtils.get(vdc.id);
if (currentVDC != null) {
VirtualDataCenterModifyParam vdcToUpdate = new VirtualDataCenterModifyParam();
vdcToUpdate.setName(vdc.name);
vdcToUpdate.setDescription(vdc.description);
Task<VirtualDataCenterRestRep> task = VirtualDataCenterUtils.update(uri(vdc.id), vdcToUpdate);
flash.put("inProgressTask", task.getTaskResource().getId());
}
}
Cache.delete(Common.VDCS);
if (StringUtils.isNotBlank(vdc.referrerUrl)) {
redirect(vdc.referrerUrl);
} else {
list();
}
}
use of controllers.deadbolt.Restrictions in project coprhd-controller by CoprHD.
the class StorageOSDeadboltHandler method getRoleSetsFromController.
/*
* Query the roles required by the deadbolt annotations. This is used for logging purposes to show what the controller
* requires.
*/
private static List<String> getRoleSetsFromController() {
List<String> roleSets = Lists.newArrayList();
Restrictions restrictions = getActionAnnotation(Restrictions.class);
if (restrictions == null) {
restrictions = getControllerInheritedAnnotation(Restrictions.class);
}
if (restrictions != null) {
Restrict[] restrictArray = restrictions.value();
for (int i = 0; i < restrictArray.length; i++) {
roleSets.add(StringUtils.join(restrictArray[i].value(), " & "));
}
}
Restrict restrict = getActionAnnotation(Restrict.class);
if (restrict == null) {
restrict = getControllerInheritedAnnotation(Restrict.class);
}
if (restrict != null) {
roleSets.add(StringUtils.join(restrict.value(), " & "));
}
return roleSets;
}
Aggregations