Package org.apache.sling.bgservlets

Examples of org.apache.sling.bgservlets.JobStatus


    protected void doGet(SlingHttpServletRequest request,
            SlingHttpServletResponse response) throws ServletException,
            IOException {
        try {
            final Node n = request.getResource().adaptTo(Node.class);
            final JobStatus j = jobConsole.getJobStatus(n.getSession(), n.getPath());
            final String streamPath =  j.getStreamPath();
            final String fullStreamPath = request.getContextPath() + streamPath;
            final String ext = request.getRequestPathInfo().getExtension();
            Renderer r = renderers.get(ext);
            if(r == null) {
                r = renderers.get(DEFAULT_EXT);
View Full Code Here


        JobConsolePlugin.destroyPlugin();
    }
   
    public JobStatus getJobStatus(Session session, String path) {
        // Try ExecutionEngine first, persistent storage if not found
        JobStatus result = executionEngine.getJobStatus(path);
        if(result == null) {
            try {
                if(session.itemExists(path)) {
                    final Item i = session.getItem(path);
                    if(i.isNode()) {
View Full Code Here

       
        private void processCommands(HttpServletRequest req, PrintWriter pw, Session s, JobConsole console) {
            // TODO should use POST
            final String jobPath = req.getParameter("jobPath");
            if (jobPath != null) {
                final JobStatus job = console.getJobStatus(s, jobPath);
                if (job != null) {
                    final String action = req.getParameter("action");
                    if ("suspend".equals(action)) {
                        job.requestStateChange(JobStatus.State.SUSPENDED);
                    } else if ("stop".equals(action)) {
                        job.requestStateChange(JobStatus.State.STOPPED);
                    } else if ("resume".equals(action)) {
                        job.requestStateChange(JobStatus.State.RUNNING);
                    }
                }
            }
        }
View Full Code Here

        final Session session = request.getResourceResolver().adaptTo(Session.class);
        if(session == null) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ResourceResolver does not adapt to a Session");
            return;
        }
        final JobStatus j = jobConsole.getJobStatus(session, request.getResource().getPath());
        final JobStatus.State oldState = j.getState();
        j.requestStateChange(desiredState);
        final JobStatus.State newState = j.getState();
       
        response.setContentType("application/json");
        response.setCharacterEncoding("UTF-8");
        final JSONWriter w = new JSONWriter(response.getWriter());
        try {
            w.object();
            w.key("info").value("Requested state change");
            w.key(PARAM_STATE).value(desiredState.toString());
            w.key("path").value(j.getPath());
            w.key("currentState").value(newState);
            w.key("stateChanged").value(newState != oldState);
            w.endObject();
        } catch(JSONException je) {
            throw new ServletException("JSONException in doPost", je);
View Full Code Here

        public Date getCreationTime() {
            return creationTime;
        }

        public State getState() {
            final JobStatus j = getActiveJob();
            if(j == null) {
                log.debug("Job {} not found by getActiveJob, assuming status==DONE", path);
                return State.DONE;
            }
            return j.getState();
        }
View Full Code Here

            }
            return j.getState();
        }
   
        public void requestStateChange(State s) {
            final JobStatus j = getActiveJob();
            if(j == null) {
                log.debug("Job {} is not active, cannot change state", path);
            } else {
                j.requestStateChange(s);
            }
        }
View Full Code Here

            }
        }
       
        /** @inheritDoc */
        public State [] getAllowedHumanStateChanges() {
            final JobStatus j = getActiveJob();
            if(j == null) {
                return new State[] {};
            }
            return j.getAllowedHumanStateChanges();
        }
View Full Code Here

        }

        public JobProgressInfo getProgressInfo() {
            // If job is active, return its info, else
            // return info from our job node
            final JobStatus active = getActiveJob();
            if(active != null) {
                return active.getProgressInfo();
            } else {
                return new JobProgressInfo() {
                    public String getProgressMessage() {
                        return getState().toString();
                    }
View Full Code Here

TOP

Related Classes of org.apache.sling.bgservlets.JobStatus

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.