use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class FileProtectionPolicies method edit.
@FlashException(value = "list", keep = true)
public static void edit(String id) {
FilePolicyRestRep filePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(id));
if (filePolicyRestRep != null) {
SchedulePolicyForm schedulePolicy = new SchedulePolicyForm().form(filePolicyRestRep);
addRenderArgs();
addDateTimeRenderArgs();
addTenantOptionsArgs();
addRenderApplyPolicysAt();
addNumWorkerThreadsArgs();
render(schedulePolicy);
} else {
flash.error(MessagesUtils.get(UNKNOWN, id));
list();
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class Common method flashExceptionHandler.
/**
* Extremely low priority exception handler that will automatically
* flashException and redirect for action methods decorated with a
* FlashException annotation. Rethrow if the annotation is
* absent.
*/
@Catch(value = Exception.class, priority = Integer.MAX_VALUE)
public static void flashExceptionHandler(Exception e) throws Exception {
FlashException handler = getActionAnnotation(FlashException.class);
if (handler != null) {
flashException(e);
if (handler.keep()) {
params.flash();
Validation.keep();
}
String action = handler.value();
String[] referrer = handler.referrer();
if (!action.isEmpty()) {
if (!action.contains(".")) {
action = getControllerClass().getName() + "." + action;
}
redirect(action);
} else if (referrer != null && referrer.length > 0) {
Http.Header headerReferrer = request.headers.get("referer");
if (headerReferrer != null && StringUtils.isNotBlank(headerReferrer.value())) {
Pattern p = Pattern.compile(StringUtils.join(referrer, "|"), Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(headerReferrer.value());
if (m.find()) {
redirectToReferrer();
} else {
Logger.error(String.format("The redirect page is not valid base on the FlashException referrer restriction: %s", referrer.toString()));
}
} else {
Logger.error("Unable to redirect. No referrer available in request header");
}
} else {
redirectToReferrer();
}
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class ComputeImageServers method edit.
@FlashException("list")
public static void edit(String id) {
addReferenceData();
ComputeImageServerRestRep computeImageServer = ComputeImageServerUtils.getComputeImageServer(id);
if (computeImageServer != null) {
ComputeImageServerForm computeImageServers = new ComputeImageServerForm(computeImageServer);
render("@edit", computeImageServers);
} else {
flash.error(MessagesUtils.get(UNKNOWN, id));
list();
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class ComputeSystems method edit.
public static void edit(String id) {
try {
addReferenceData();
ComputeSystemRestRep computeSystem = ComputeSystemUtils.getComputeSystem(id);
if (computeSystem != null) {
if (computeSystem.getVlans() != null) {
List<StringOption> vlanOptions = new ArrayList<StringOption>();
vlanOptions.add(VlanListTypes.option(VlanListTypes.NO_OSINSTALL_NONE));
List<String> vlanList = new ArrayList<String>(Arrays.asList(computeSystem.getVlans().split(",")));
for (String vlan : vlanList) {
vlanOptions.add(VlanListTypes.option(vlan));
}
renderArgs.put("computeSystemVlanList", vlanOptions);
}
List<StringOption> computeImageServerOptions = new ArrayList<StringOption>();
computeImageServerOptions.add(ComputeImageServerListTypes.option(ComputeImageServerListTypes.NO_COMPUTE_IMAGE_SERVER_NONE));
List<ComputeImageServerRestRep> computeImageServersList = ComputeImageServerUtils.getComputeImageServers();
if (computeImageServersList != null) {
List<String> computeImageServersArrayList = new ArrayList<String>();
for (ComputeImageServerRestRep cisrr : computeImageServersList) {
if (cisrr.getComputeImageServerStatus().equalsIgnoreCase(AVAILABLE)) {
computeImageServersArrayList.add(cisrr.getName());
}
}
for (String imageServerId : computeImageServersArrayList) {
computeImageServerOptions.add(ComputeImageServerListTypes.option(imageServerId));
}
renderArgs.put("availableComputeImageServersList", computeImageServerOptions);
}
ComputeSystemForm computeSystems = new ComputeSystemForm(computeSystem);
render("@edit", computeSystems);
} else {
flash.error(MessagesUtils.get(UNKNOWN, id));
list();
}
} catch (Exception e) {
flashException(e);
list();
}
}
use of controllers.util.FlashException in project coprhd-controller by CoprHD.
the class HostClusters method delete.
@FlashException("list")
public static void delete(@As(",") String[] ids, boolean detachStorage) {
for (URI id : ResourceUtils.uris(ids)) {
ClusterUtils.deactivate(id, detachStorage);
}
flash.success(MessagesUtils.get(DELETED));
list();
}
Aggregations