private String createAssetIfNotExisting(
      Repository repository, String location, String name, String type, byte[] content) {
    try {
      boolean assetExists = repository.assetExists(location + "/" + name + "." + type);
      if (!assetExists) {
        // create theme asset
        AssetBuilder assetBuilder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte);
        assetBuilder.content(content).location(location).name(name).type(type).version("1.0");

        Asset<byte[]> customEditorsAsset = assetBuilder.getAsset();

        return repository.createAsset(customEditorsAsset);
      }

    } catch (Exception e) {
      logger.error(e.getMessage());
    }

    return null;
  }
  /**
   * Processing a new request from ElFinder client.
   *
   * @param request
   * @param response
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response) {
    parseRequest(request, response);
    IDiagramProfile profile = ServletUtil.getProfile(request, "jbpm", getServletContext());
    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 {
      System.out.println(
          "*********************************** COMMAND: " + requestParams.get("cmd"));
      Iterator<String> keys = requestParams.keySet().iterator();
      while (keys.hasNext()) {
        String key = keys.next();
        System.out.println(
            "******************************* PARAM: " + key + " -- val: " + requestParams.get(key));
      }

      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 (AssetNotFoundException 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);
      }
    }
  }