Examples of ResourceInstance


Examples of org.apache.ambari.server.api.resources.ResourceInstance

    verify(m_controller, resource, resourceDefinition, schema);
  }

  @Test
  public void testAddProperty__localSubCategory() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();

    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);

    Query query = new TestQuery(resource, null);
    query.addProperty("category", "nestedCategory", null);
View Full Code Here

Examples of org.apache.ambari.server.api.resources.ResourceInstance

    verify(m_controller, resource, resourceDefinition, schema);
  }

  @Test
  public void testAddProperty__localCategorySubPropsOnly() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    Schema schema = createNiceMock(Schema.class);

    //expectations
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition).anyTimes();

    expect(resourceDefinition.getType()).andReturn(Resource.Type.Service).anyTimes();

    expect(m_controller.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();
    expect(resource.getSubResources()).andReturn(Collections.<String, ResourceInstance>emptyMap()).anyTimes();

    replay(m_controller, resource, resourceDefinition, schema);

    Query query = new TestQuery(resource, null);
    query.addProperty(null, "category", null);
View Full Code Here

Examples of org.apache.ambari.server.api.resources.ResourceInstance

    verify(m_controller, resource, resourceDefinition, schema);
  }

  @Test
  public void testAddProperty__subProperty() throws Exception {
    ResourceInstance resource = createNiceMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition = createNiceMock(ResourceDefinition.class);
    ResourceInstance subResource = createNiceMock(ResourceInstance.class);
    Schema schema = createNiceMock(Schema.class);

    Map<Resource.Type, String> mapResourceIds = new HashMap<Resource.Type, String>();
    mapResourceIds.put(Resource.Type.Service, "serviceName");
    mapResourceIds.put(Resource.Type.Component, "componentName");
View Full Code Here

Examples of org.apache.ambari.server.api.resources.ResourceInstance

      // add a child node for the resource and provide a unique name.  The name is never used.
      //todo: provide a more meaningful node name
      TreeNode<Resource> node = tree.addChild(resource, resource.getType() + ":" + count++);
      for (Map.Entry<String, ResourceInstance> entry : m_mapSubResources.entrySet()) {
        String subResCategory = entry.getKey();
        ResourceInstance r = entry.getValue();

        setParentIdsOnSubResource(resource, r);

        TreeNode<Resource> childResult = r.getQuery().execute().getResultTree();
        childResult.setName(subResCategory);
        childResult.setProperty("isCollection", "false");
        node.addChild(childResult);
      }
    }
View Full Code Here

Examples of org.apache.wink.server.internal.registry.ResourceInstance

    private boolean isContinuedSearchPolicy;

    public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable {

        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        // resource method
        if (resource.isExactMatch()) {
            handleResourceMethod(context, chain);
            return;
        }

        // sub-resource method or locator
        UriTemplateMatcher templateMatcher = resource.getMatcher();
        String tail = UriTemplateProcessor.normalizeUri(templateMatcher.getTail(false));

        // get a sorted set of all the sub-resources (methods and locators)
        List<SubResourceInstance> subResources = resource.getRecord().getMatchingSubResources(tail);
        if (subResources.size() == 0) {
            result.setError(new WebApplicationException(Response.Status.NOT_FOUND));
            return;
        }
View Full Code Here

Examples of org.apache.wink.server.internal.registry.ResourceInstance

        // and we need to find the dispatch method.
        // if no method is found then a RequestMatchingException exception is
        // thrown
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        MethodRecord method = null;
        try {
            // if no method is found then a RequestMatchingException exception
            // is thrown
View Full Code Here

Examples of org.apache.wink.server.internal.registry.ResourceInstance

                                         List<SubResourceInstance> subResources,
                                         MessageContext context,
                                         HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();
        SubResourceRecord subResourceRecord = subResourceInstance.getRecord();
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();
        String pattern = subResourceRecord.getTemplateProcessor().getPatternString();
        // dispatch to one of the sub-resource methods.
        SubResourceInstance method = null;
View Full Code Here

Examples of org.apache.wink.server.internal.registry.ResourceInstance

        if (subResource == null) {
            result.setError(new WebApplicationException(Status.NOT_FOUND));
            return;
        }
        ResourceRecord record = registry.getRecord(subResource, false);
        ResourceInstance resourceInstance = new ResourceInstance(subResource, record, matcher);
        // save the resource for UriInfo
        result.getData().getMatchedResources().addFirst(resourceInstance);

        // call recursively to search in the sub-resource
        result.setFound(false);
View Full Code Here

Examples of org.apache.wink.server.internal.registry.ResourceInstance

    private static final Logger logger = LoggerFactory.getLogger(FindResourceMethodHandler.class);

    public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable {

        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        // resource method
        if (resource.isExactMatch()) {
            logger
                .debug("Root resource @Path matches exactly so finding root resource method in {}",
                       resource.getResourceClass().getName());
            handleResourceMethod(context, chain);
            return;
        }

        // sub-resource method or locator
        UriTemplateMatcher templateMatcher = resource.getMatcher();
        String tail = UriTemplateProcessor.normalizeUri(templateMatcher.getTail(false));
        logger.debug("Unmatched tail to the URI: {}", tail);

        // get a sorted list of all the sub-resources (methods and locators)
        List<SubResourceInstance> subResources = resource.getRecord().getMatchingSubResources(tail);
        logger.debug("Possible subresources found: {}", subResources);
        if (subResources.size() == 0) {
            result.setError(new WebApplicationException(Response.Status.NOT_FOUND));
            return;
        }
View Full Code Here

Examples of org.apache.wink.server.internal.registry.ResourceInstance

        // and we need to find the dispatch method.
        // if no method is found then a RequestMatchingException exception is
        // thrown
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        MethodRecord method = null;
        try {
            // if no method is found then a RequestMatchingException exception
            // is thrown
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.