protected void processRequest(HttpServletRequest request,
                                  HttpServletResponse response) {
        parseRequest(request,
                     response);
        if (profile == null) {
            profile = _profileService.findProfile(request,
                                                  "jbpm");
        }
        Repository repository = profile.getRepository();
        if (!initialized) {
            try {
                initializeDefaultRepo(profile,
                                      repository,
                                      request);
                initialized = true;
            } catch (Exception e) {
                logger.error("Unable to initialize repository: " + e.getMessage());
            }
        }
        JSONObject returnJson = new JSONObject();
        try {
            Iterator<String> keys = requestParams.keySet().iterator();
            while (keys.hasNext()) {
                String key = keys.next();
            }

            String cmd = (String) requestParams.get("cmd");
            if (cmd != null && cmd.equals("open")) {
                OpenCommand command = new OpenCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("mkdir")) {
                MakeDirCommand command = new MakeDirCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("mkfile")) {
                MakeFileCommand command = new MakeFileCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("rm")) {
                RemoveAssetCommand command = new RemoveAssetCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("rename")) {
                RenameCommand command = new RenameCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("paste")) {
                PasteCommand command = new PasteCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("upload")) {
                UploadCommand command = new UploadCommand();
                command.init(request,
                             response,
                             profile,
                             repository,
                             requestParams,
                             listFiles,
                             listFileStreams);
                output(response,
                       false,
                       command.execute());
            } else if (cmd != null && cmd.equals("getsvg")) {
                try {
                    Asset asset = profile.getRepository().loadAssetFromPath((String) requestParams.get("current"));
                    if (asset != null && asset.getAssetContent() != null) {
                        outputPlain(response,
                                    false,
                                    (String) asset.getAssetContent(),
                                    "image/svg+xml");
                    } else {
                        outputPlain(response,
                                    true,
                                    "<p><b>Process image not available.</p><p>You can generate the process image in the process editor.</b></p>",
                                    null);
                    }
                } catch (NoSuchFileException e) {
                    logger.warn("Error loading process image: " + e.getMessage());
                    outputPlain(response,
                                true,
                                "<p><b>Could not find process image.</p><p>You can generate the process image in the process editor.</b></p>",
                                null);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            logger.error(e.getMessage());
            putResponse(returnJson,
                        "error",
                        e.getMessage());

            // output the error
            try {
                output(response,
                       false,
                       returnJson);
            } catch (Exception ee) {
                logger.error("",
                             ee);
            }
        }
    }
protected void processRequest ( HttpServletRequest request , HttpServletResponse response ) { parseRequest ( request , response ) ; if ( profile == null ) { profile = _profileService . findProfile ( request , "jbpm" ) ; } Repository repository = profile . getRepository ( ) ; if ( ! initialized ) { try { initializeDefaultRepo ( profile , repository , request ) ; initialized = true ; } catch ( Exception e ) { logger . error ( "Unable to initialize repository: " + e . getMessage ( ) ) ; } } JSONObject returnJson = new JSONObject ( ) ; try { Iterator < String > keys = requestParams . keySet ( ) . iterator ( ) ; while ( keys . hasNext ( ) ) { String key = keys . next ( ) ; } String cmd = ( String ) requestParams . get ( "cmd" ) ; if ( cmd != null && cmd . equals ( "open" ) ) { OpenCommand command = new OpenCommand ( ) ; command . init ( request , response , profile , repository , requestParams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "mkdir" ) ) { MakeDirCommand command = new MakeDirCommand ( ) ; command . init ( request , response , profile , repository , requestParams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "mkfile" ) ) { MakeFileCommand command = new MakeFileCommand ( ) ; command . init ( request , response , profile , repository , requestParams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "rm" ) ) { RemoveAssetCommand command = new RemoveAssetCommand ( ) ; command . init ( request , response , profile , repository , requestParams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "rename" ) ) { RenameCommand command = new RenameCommand ( ) ; command . init ( request , response , profile , repository , requestParams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "paste" ) ) { PasteCommand command = new PasteCommand ( ) ; command . init ( request , response , profile , repository , requestParams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "upload" ) ) { UploadCommand command = new UploadCommand ( ) ; command . init ( request , response , profile , repository , requestParams , listFiles , listFileStreams ) ; output ( response , false , command . execute ( ) ) ; } else if ( cmd != null && cmd . equals ( "getsvg" ) ) { try { Asset asset = profile . getRepository ( ) . loadAssetFromPath ( ( String ) requestParams . get ( "current" ) ) ; if ( asset != null && asset . getAssetContent ( ) != null ) { outputPlain ( response , false , ( String ) asset . getAssetContent ( ) , "image/svg+xml" ) ; } else { outputPlain ( response , true , "<p><b>Process image not available.</p><p>You can generate the process image in the process editor.</b></p>" , null ) ; } } catch ( NoSuchFileException e ) { logger . warn ( "Error loading process image: " + e . getMessage ( ) ) ; outputPlain ( response , true , "<p><b>Could not find process image.</p><p>You can generate the process image in the process editor.</b></p>" , null ) ; } } } catch ( Exception e ) { e . printStackTrace ( ) ; logger . error ( e . getMessage ( ) ) ; putResponse ( returnJson , "error" , e . getMessage ( ) ) ; try { output ( response , false , returnJson ) ; } catch ( Exception ee ) { logger . error ( "" , ee ) ; } } }
Processing a new request from ElFinder client.
@param request
@param response