Package org.apache.ivory.resource

Examples of org.apache.ivory.resource.APIResult


  private volatile Exception threadException;

  @Test(expectedExceptions=IvoryWebException.class)
  public void testBeanLoading() {

    APIResult result = em.getStatus("type", "entity", "colo");
  }
View Full Code Here


    }

    public static IvoryWebException newException(String message,
                                                 Response.Status status) {
        LOG.error("Action failed: " + status + "\nError:" + message);
        APIResult result = new APIResult(APIResult.Status.FAILED, message);
        return new IvoryWebException(Response.status(status).
                entity(result).type(MediaType.TEXT_XML_TYPE).build());
    }
View Full Code Here

                entity(result).type(MediaType.TEXT_XML_TYPE).build());
    }

    public static IvoryWebException newInstanceException(String message, Response.Status status) {
        LOG.error("Action failed: " + status + "\nError:" + message);
        APIResult result = new InstancesResult(APIResult.Status.FAILED, message);
        return new IvoryWebException(Response.status(status).entity(result).type(MediaType.TEXT_XML_TYPE).build());
    }
View Full Code Here

  }
 
  private String parseAPIResult(ClientResponse clientResponse)
      throws IvoryCLIException {

    APIResult result = clientResponse.getEntity(APIResult.class);
    return result.getMessage();

  }
View Full Code Here

            public APIResult execute() {
                try {
                    EntityUtil.getEntity(type, entity);
                    return super.execute();
                } catch (EntityNotRegisteredException e) {
                    return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") removed successfully");
                } catch (IvoryException e) {
                    throw IvoryWebException.newException(e, Response.Status.BAD_REQUEST);
                }
            }
           
View Full Code Here

        StringBuilder buffer = new StringBuilder();
        StringBuilder requestIds = new StringBuilder();
        int statusCount = 0;
        for (Entry<String, APIResult> entry : results.entrySet()) {
            String colo = entry.getKey();
            APIResult result = entry.getValue();
            buffer.append(colo).append('/').append(result.getMessage()).append('\n');
            requestIds.append(colo).append('/').append(result.getRequestId()).append('\n');
            statusCount += result.getStatus().ordinal();
        }

        APIResult.Status status = (statusCount == 0) ? APIResult.Status.SUCCEEDED
                : ((statusCount == results.size() * 2) ? APIResult.Status.FAILED : APIResult.Status.PARTIAL);
        APIResult result = new APIResult(status, buffer.toString());
        result.setRequestId(requestIds.toString());
        return result;
    }
View Full Code Here

            for (String colo : colos) {
                try {
                    results.put(colo, doExecute(colo));
                } catch (IvoryException e) {
                    results.put(colo, new APIResult(APIResult.Status.FAILED, e.getClass().getName() + "::" + e.getMessage()));
                }
            }
            APIResult finalResult = consolidateResult(results);
            if (finalResult.getStatus() != APIResult.Status.SUCCEEDED) {
                throw IvoryWebException.newException(finalResult, Response.Status.BAD_REQUEST);
            } else {
                return finalResult;
            }
        }
View Full Code Here

            Set<String> colos = getColosFromExpression(coloExpr, type, name);

            Map<String, InstancesResult> results = new HashMap<String, InstancesResult>();
            for (String colo:colos) {
                try {
                    APIResult resultHolder = doExecute(colo);
                    if (resultHolder instanceof InstancesResult) {
                        results.put(colo, (InstancesResult) resultHolder);
                    } else {
                        throw new IvoryException(resultHolder.getMessage());
                    }
                } catch (IvoryException e) {
                    results.put(colo, new InstancesResult(APIResult.Status.FAILED,
                            e.getClass().getName() + "::" + e.getMessage(),
                            new InstancesResult.Instance[0]));
View Full Code Here

TOP

Related Classes of org.apache.ivory.resource.APIResult

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.