Search in sources :

Example 71 with FlashException

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();
    }
}
Also used : FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FlashException(controllers.util.FlashException)

Example 72 with FlashException

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();
        }
    }
}
Also used : FlashException(controllers.util.FlashException) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) Catch(play.mvc.Catch)

Example 73 with FlashException

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();
    }
}
Also used : ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep) FlashException(controllers.util.FlashException)

Example 74 with FlashException

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();
    }
}
Also used : StringOption(util.StringOption) ArrayList(java.util.ArrayList) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) Common.flashException(controllers.Common.flashException) URISyntaxException(java.net.URISyntaxException) FlashException(controllers.util.FlashException) ComputeImageServerRestRep(com.emc.storageos.model.compute.ComputeImageServerRestRep)

Example 75 with FlashException

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();
}
Also used : 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