Package org.apache.ambari.server.api.services

Examples of org.apache.ambari.server.api.services.ResultStatus


    try {
      RequestStatus status = getPersistenceManager().update(resource, body);

      result = createResult(status);
      if (result.isSynchronous()) {
        result.setResultStatus(new ResultStatus(ResultStatus.STATUS.OK));
      } else {
        result.setResultStatus(new ResultStatus(ResultStatus.STATUS.ACCEPTED));
      }

    } catch (UnsupportedPropertyException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e));
    } catch (IllegalArgumentException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e));
    } catch (NoSuchParentResourceException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e));
    } catch (NoSuchResourceException e) {
      if (resource.isCollectionResource()) {
        //todo: what is the correct status code here.  The query didn't match any resource
        //todo: so no resource were updated.  200 may be ok but we would need to return a collection
        //todo: of resources that were updated.
        result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.OK, e));
      } else {
        result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e));
      }
    } catch (SystemException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e));
    }

    return result;
  }
View Full Code Here


      RequestStatus status = getPersistenceManager().create(resource, body);

      result = createResult(status);

      if (result.isSynchronous()) {
        result.setResultStatus(new ResultStatus(ResultStatus.STATUS.CREATED));
      } else {
        result.setResultStatus(new ResultStatus(ResultStatus.STATUS.ACCEPTED));
      }

    } catch (UnsupportedPropertyException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
    } catch (NoSuchParentResourceException e) {
      //todo: is this the correct status code?
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e.getMessage()));
    } catch (SystemException e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Caught a system exception while attempting to create a resource", e.getMessage());
      }
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e.getMessage()));
    } catch (ResourceAlreadyExistsException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.CONFLICT, e.getMessage()));
    } catch(IllegalArgumentException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
    } catch (RuntimeException e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Caught a runtime exception while attempting to create a resource", e);
      }
      //result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e.getMessage()));
View Full Code Here

    query.setMinimal(request.isMinimal());

    try {
      addFieldsToQuery(request, query);
    } catch (IllegalArgumentException e) {
      return new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
    }

    Result result;
    Predicate p = null;
    try {
      p = request.getQueryPredicate();
      query.setUserPredicate(p);

      result = query.execute();
      result.setResultStatus(new ResultStatus(ResultStatus.STATUS.OK));
    } catch (SystemException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.SERVER_ERROR, e));
    } catch (NoSuchParentResourceException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e.getMessage()));
    } catch (UnsupportedPropertyException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e.getMessage()));
    } catch (NoSuchResourceException e) {
      if (p == null) {
        // no predicate specified, resource requested by id
        result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e.getMessage()));
      } else {
        // resource(s) requested using predicate
        result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.OK, e));
        result.getResultTree().setProperty("isCollection", "true");
      }
    } catch (IllegalArgumentException e) {
      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST,
          "Invalid Request: " + e.getMessage()));
      LOG.error("Bad request: ", e);
    catch (RuntimeException e) {
      if (LOG.isErrorEnabled()) {
        LOG.error("Caught a runtime exception executing a query", e);
View Full Code Here

    UriInfo uriInfo = createMock(UriInfo.class);
    Resource resource = createMock(Resource.class);
    //Resource resource2 = createMock(Resource.class);

    Result result = new ResultImpl(true);
    result.setResultStatus(new ResultStatus(ResultStatus.STATUS.OK));
    TreeNode<Resource> tree = result.getResultTree();
    //tree.setName("items");
    TreeNode<Resource> child = tree.addChild(resource, "resource1");
    child.setProperty("href", "this is an href");
    //child.addChild(resource2, "sub-resource");
View Full Code Here

    UriInfo uriInfo = createMock(UriInfo.class);
    Resource resource = createMock(Resource.class);
    //Resource resource2 = createMock(Resource.class);

    Result result = new ResultImpl(true);
    result.setResultStatus(new ResultStatus(ResultStatus.STATUS.OK));
    TreeNode<Resource> tree = result.getResultTree();
    //tree.setName("items");
    TreeNode<Resource> child = tree.addChild(resource, "resource1");
    child.setProperty("href", "this is an href");
    //child.addChild(resource2, "sub-resource");
View Full Code Here

    UriInfo uriInfo = createMock(UriInfo.class);
    Resource resource = createMock(Resource.class);
    //Resource resource2 = createMock(Resource.class);

    Result result = new ResultImpl(true);
    result.setResultStatus(new ResultStatus(ResultStatus.STATUS.OK));
    TreeNode<Resource> tree = result.getResultTree();


    TreeNode<Resource> resourcesNode = tree.addChild(null, "resources");
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.api.services.ResultStatus

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.