Package org.eclipse.orion.server.git.objects

Examples of org.eclipse.orion.server.git.objects.ConfigOption


                null));
      Repository db = null;
      try {
        db = FileRepositoryBuilder.create(gitDir);
        URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG);
        ConfigOption configOption = new ConfigOption(cloneLocation, db);
        OrionServlet.writeJSONResponse(request, response, configOption.toJSON(/* all */), JsonURIUnqualificationStrategy.ALL_NO_GIT);
        return true;
      } finally {
        if (db != null) {
          db.close();
        }
      }
    } else if (p.segment(1).equals(Clone.RESOURCE) && p.segment(2).equals("file")) { //$NON-NLS-1$
      // expected path /gitapi/config/{key}/clone/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
      if (gitDir == null)
        return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(2)),
                null));
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG_OPTION);
      Repository db = null;
      try {
        db = FileRepositoryBuilder.create(gitDir);
        ConfigOption configOption = new ConfigOption(cloneLocation, db, p.segment(0));
        if (!configOption.exists())
          return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND,
              "There is no config entry with key provided", null));
        OrionServlet.writeJSONResponse(request, response, configOption.toJSON(), JsonURIUnqualificationStrategy.ALL_NO_GIT);
        return true;
      } catch (IllegalArgumentException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), e));
      } finally {
        if (db != null) {
View Full Code Here


        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST,
            "Config entry value must be provided", null));
      Repository db = null;
      try {
        db = FileRepositoryBuilder.create(gitDir);
        ConfigOption configOption = new ConfigOption(cloneLocation, db, key);
        boolean present = configOption.exists();
        ArrayList<String> valList = new ArrayList<String>();
        if (present) {
          String[] val = configOption.getValue();
          valList.addAll(Arrays.asList(val));
        }
        valList.add(value);
        save(configOption, valList);

        JSONObject result = configOption.toJSON();
        OrionServlet.writeJSONResponse(request, response, result, JsonURIUnqualificationStrategy.ALL_NO_GIT);
        response.setHeader(ProtocolConstants.HEADER_LOCATION, result.getString(ProtocolConstants.KEY_LOCATION));
        response.setStatus(HttpServletResponse.SC_CREATED);
        return true;
      } catch (IllegalArgumentException e) {
View Full Code Here

                null));
      Repository db = null;
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.CONFIG_OPTION);
      try {
        db = FileRepositoryBuilder.create(gitDir);
        ConfigOption configOption = new ConfigOption(cloneLocation, db, p.segment(0));

        JSONObject toPut = OrionServlet.readJSONRequest(request);
        JSONArray value = toPut.optJSONArray(GitConstants.KEY_CONFIG_ENTRY_VALUE);
        if (value == null || (value.length() == 1 && value.isNull(0)))
          return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST,
              "Config entry value must be provided", null));

        // PUT allows only to modify existing config entries
        if (!configOption.exists()) {
          response.setStatus(HttpServletResponse.SC_NOT_FOUND);
          return true;
        }

        ArrayList<String> valList = new ArrayList<String>();
        for (int i = 0; i < value.length(); i++) {
          valList.add(value.getString(i));
        }

        save(configOption, valList);

        JSONObject result = configOption.toJSON();
        OrionServlet.writeJSONResponse(request, response, result);
        response.setHeader(ProtocolConstants.HEADER_LOCATION, result.getString(ProtocolConstants.KEY_LOCATION));
        return true;
      } catch (IllegalArgumentException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), e));
View Full Code Here

                null));
      Repository db = null;
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.CONFIG_OPTION);
      try {
        db = FileRepositoryBuilder.create(gitDir);
        ConfigOption configOption = new ConfigOption(cloneLocation, db, GitUtils.decode(p.segment(0)));
        if (configOption.exists()) {
          String query = request.getParameter("index"); //$NON-NLS-1$
          if (query != null) {
            List<String> existing = new ArrayList<String>(Arrays.asList(configOption.getValue()));
            existing.remove(Integer.parseInt(query));
            save(configOption, existing);
          } else {
            delete(configOption);
          }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.git.objects.ConfigOption

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.