Package org.glassfish.admin.rest.utils.xml

Examples of org.glassfish.admin.rest.utils.xml.RestActionReporter


            //delete operations can be supported through POST. Redirect html
            //client POST request for delete operation to DELETE method.
            if ("__deleteoperation".equals(data.get("operation"))) {
                data.remove("operation");
                delete(data);
                return new RestActionReporter();
            }
            //just update it.
            data = ResourceUtil.translateCamelCasedNamesToXMLNames(data);
            RestActionReporter ar = Util.applyChanges(data, uriInfo, getSubject());
            if (ar.getActionExitCode() != ActionReport.ExitCode.SUCCESS) {
                throwError(Status.BAD_REQUEST, "Could not apply changes" + ar.getMessage()); // i18n
            }

            return ar;
        } catch (Exception ex) {
            throw new WebApplicationException(ex, Response.Status.INTERNAL_SERVER_ERROR);
View Full Code Here


                        localStrings.getLocalString("rest.resource.not.deleted",
                        "Resource not deleted. Value of \"name\" should be the name of this resource."));
            }
        }

        RestActionReporter actionReport = runCommand(getDeleteCommand(), data);

        if (actionReport != null) {
            ActionReport.ExitCode exitCode = actionReport.getActionExitCode();
            if (exitCode != ActionReport.ExitCode.FAILURE) {
                return exitCode;
            }

            throwError(Status.BAD_REQUEST, actionReport.getMessage());
        }

        throw new WebApplicationException(handleError(Status.BAD_REQUEST,
                localStrings.getLocalString("rest.resource.delete.forbidden",
                "DELETE on \"{0}\" is forbidden.", new Object[]{uriInfo.getAbsolutePath()})));
View Full Code Here

            }
        }
        if (!parameters.entrySet().isEmpty()) {
           return ResourceUtil.runCommand("set", parameters, null); //TODO The last parameter is resultType and is not used. Refactor the called method to remove it
        } else {
            return new RestActionReporter(); // noop
        }
    }
View Full Code Here

    }

    public static Map<String, String> getCurrentValues(String basePath, ServiceLocator habitat) {
        Map<String, String> values = new HashMap<String, String>();
        final String path = (basePath.endsWith(".")) ? basePath.substring(0, basePath.length()-1) : basePath;
        RestActionReporter gr = ResourceUtil.runCommand("get", new ParameterMap() {{
            add ("DEFAULT", path);
        }}, habitat, "");

        MessagePart top = gr.getTopMessagePart();
        for (MessagePart child : top.getChildren()) {
            String message = child.getMessage();
            if (message.contains("=")) {
                String[] parts = message.split("=");
                values.put(parts[0], (parts.length > 1) ? parts[1] : "");
View Full Code Here

     *
     * @param changes
     * @param basePath
     */
    public void applyChanges(Map<String, String> changes, String basePath, Subject subject) {
        RestActionReporter ar = Util.applyChanges(changes, basePath, subject);
        if (!ar.getActionExitCode().equals(ExitCode.SUCCESS)) {
            throw new WebApplicationException(Response.status(Status.BAD_REQUEST).
                    entity(ar.getCombinedMessage()).build());
        }
    }
View Full Code Here

     * @param throwBadRequest (vs. NOT_FOUND)
     * @param throwOnWarning  (vs.ignore warning)
     * @return
     */
    public ActionReporter executeCommand(Subject subject, String command, ParameterMap parameters, Status status, boolean includeFailureMessage, boolean throwOnWarning, boolean managed) {
        RestActionReporter ar = ResourceUtil.runCommand(command, parameters, subject, managed);
        ExitCode code = ar.getActionExitCode();
        if (code.equals(ExitCode.FAILURE) || (code.equals(ExitCode.WARNING) && throwOnWarning)) {
            Throwable t = ar.getFailureCause();
            if (t instanceof SecurityException) {
              throw new WebApplicationException(Response.status(Status.UNAUTHORIZED).build());
            }
            if (includeFailureMessage) {
                throw new WebApplicationException(Response.status(status).entity(ar.getCombinedMessage()).build());
            } else {
                throw new WebApplicationException(status);
            }
        }
        return ar;
View Full Code Here

    protected Response accepted(String command, ParameterMap parameters, URI childUri) {
        return accepted(responseBody(), launchDetachedCommand(command, parameters), childUri);
    }
    protected URI launchDetachedCommand(String command, ParameterMap parameters) {
        CommandRunner cr = Globals.getDefaultHabitat().getService(CommandRunner.class);
        final RestActionReporter ar = new RestActionReporter();
        final CommandRunner.CommandInvocation commandInvocation =
                cr.getCommandInvocation(command, ar, getSubject()).
                parameters(parameters);
        final String jobId = DetachedCommandHelper.invokeAsync(commandInvocation);
        return getUri("jobs/id/" + jobId);
View Full Code Here

            }
        }
        if (!parameters.entrySet().isEmpty()) {
           return ResourceUtil.runCommand("set", parameters, habitat, ""); //TODO The last parameter is resultType and is not used. Refactor the called method to remove it
        } else {
            return new RestActionReporter(); // noop
        }
    }
View Full Code Here

    }

    private static Map<String, String> getCurrentValues(String basePath, Habitat habitat) {
        Map<String, String> values = new HashMap<String, String>();
        final String path = (basePath.endsWith(".")) ? basePath.substring(0, basePath.length()-1) : basePath;
        RestActionReporter gr = ResourceUtil.runCommand("get", new ParameterMap() {{
            add ("DEFAULT", path);
        }}, habitat, "");

        MessagePart top = gr.getTopMessagePart();
        for (MessagePart child : top.getChildren()) {
            String message = child.getMessage();
            if (message.contains("=")) {
                String[] parts = message.split("=");
                values.put(parts[0], (parts.length > 1) ? parts[1] : "");
View Full Code Here

            }
        }
        if (!parameters.entrySet().isEmpty()) {
           return ResourceUtil.runCommand("set", parameters, null); //TODO The last parameter is resultType and is not used. Refactor the called method to remove it
        } else {
            return new RestActionReporter(); // noop
        }
    }
View Full Code Here

TOP

Related Classes of org.glassfish.admin.rest.utils.xml.RestActionReporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.