Examples of ResourceDescriptor


Examples of com.volantis.map.operation.ResourceDescriptor

        String rule,
        String fileName,
        String[][] parameters,
        boolean enableGif) throws Exception {

        ResourceDescriptor descriptor = ResourceDescriptorFactory.getInstance()
            .createDescriptor("ics", "image.");
        URL sourceURL = TestUtilities.class.getResource("images/" + fileName);
        descriptor.getInputParameters().setParameterValue(ParameterNames.SOURCE_URL, sourceURL.toExternalForm());

        HttpServletRequestMock request = new HttpServletRequestMock(
            "test-request", expectationContainer);
        String pathInfo = "/" + rule + "/" + fileName;
        request.expects.getPathInfo().returns(pathInfo).any();
        final MockFactory mf = MockFactory.getDefaultInstance();

        // use a vector as we need to return an enumeration for calls to
        // getHeaderNames()
        final Map params = new HashMap();
        request.fuzzy.getParameter(mf.expectsAny()).does(new MethodAction(){
            public Object perform(MethodActionEvent event) throws Throwable {
                return params.get(event.getArguments()[0]);
            }
        }).any();

        StringBuffer url = new StringBuffer(pathInfo);
        char c = '?';
        if (parameters != null) {
            url.append('/');
            for (int i = 0; i < parameters.length; i++) {
                if (parameters[i].length != 2) {
                    throw new IllegalArgumentException(
                        "Supplied parameter " +
                        i +
                        " has incorrect " +
                        "length: expected 2 got " +
                        parameters[i].length);
                }
                url.append(c).append(parameters[i][0]).append("=").append(parameters[i][1]);
                c = '&';
                params.put(parameters[i][0], parameters[i][1]);
            }
        }

        // Hack to enable gif support without having a config file.
        if (enableGif) {
            params.put("v.gifEnabled", "true");
            url.append(c).append("v.gifEnabled=true");
        }

        request.expects.getParameterNames().does(new MethodAction() {
            public Object perform(MethodActionEvent event) throws Throwable {
                return Collections.enumeration(params.keySet());
            }
        }).any();

        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        ServletOutputStream os = new ServletOutputStream() {
            public void write(int b) {
                outputStream.write(b);
            }
        };
        HttpServletResponseMock response = new HttpServletResponseMock(
            "test-response", expectationContainer);
        response.expects.getOutputStream().returns(os).any();

        // content type should only be set once
        response.fuzzy.setContentType(mf.expectsAny()).returns().any();
        response.fuzzy.setDateHeader(mf.expectsAny(), mf.expectsAny()).returns().any();
        response.fuzzy.addDateHeader(mf.expectsAny(), mf.expectsAny()).returns().any();
        response.fuzzy.addHeader(mf.expectsAny(), mf.expectsAny()).returns().any();
        response.fuzzy.addIntHeader(mf.expectsAny(), mf.expectsAny()).returns().any();

        response.fuzzy.setContentLength(mf.expectsAny()).returns().any();

        ICSParamBuilder builder = new ICSParamBuilder();
        builder.build(new URI(url.toString()),
                      descriptor.getInputParameters());

        ComponentContextMock componentCtx
                = new ComponentContextMock("componentCtx", expectationContainer);
        ICSOperation op = new ICSOperation();
View Full Code Here

Examples of com.volantis.map.operation.ResourceDescriptor

    public void testNotUsingPreservation() throws Exception {

        PreservationParamsBuilder ppb = new PreservationParamsBuilder();

        // override the default repository url with nothing
        ResourceDescriptor descriptor = createResourceDescriptor("image/jpeg",
                                                                 2000);
        Parameters params = descriptor.getInputParameters();
        HttpServletRequest request = createHttpRequest("TestDevice/");

        ppb.process(request, descriptor);

        assertFalse("MaxImageSize shouldn't have been changed ",
View Full Code Here

Examples of com.volantis.map.operation.ResourceDescriptor

     */
    private ResourceDescriptor createResourceDescriptor(String ImageMIMEType,
                                                        int ImageSize)
        throws Exception {

        ResourceDescriptor descriptor = ResourceDescriptorFactory.getInstance().
            createDescriptor("an-external-id", "a-resource-type");
        MutableParameters params = descriptor.getInputParameters();
        params.setParameterValue(ParameterNames.SOURCE_IMAGE_MIME_TYPE, ImageMIMEType);
        params.setParameterValue("InputImageSize",
                                 Integer.toString(ImageSize));
        params.setParameterValue(ParameterNames.DEVICE_REPOSITORY_URL,
                                 getRepositoryURL());
View Full Code Here

Examples of com.volantis.map.operation.ResourceDescriptor

    public void processRequest(HttpServletRequest request,
                               HttpServletResponse response)
        throws ServletException, IOException {


        ResourceDescriptor descriptor =
            ResourceDescriptorFactory.getInstance()
            .createDescriptor("ICS", "image");


        try {
            // build up the parameters based on the ICS request
            ICSParamBuilder builder = new ICSParamBuilder();
            StringBuffer uri = new StringBuffer();
            uri.append(getStandardisedPathInfo(request));
            String queryString = request.getQueryString();

            if (queryString != null && !"".equals(queryString)) {
                uri.append('?').append(queryString);
            }

            builder.build(new URI(uri.toString()),
                          descriptor.getInputParameters());
           
            // todo: delegate to the Operation Engine here, which does exactly the same
            ServiceReference[] references =
                context.getBundleContext().getServiceReferences(
                    Operation.class.getName(), "(operationType=ics)");
            if (null == references || references.length < 1) {
                throw new OperationNotFoundException(
                    "operation-type-not-found",
                    descriptor.getResourceType());
            } else {
                Result result = Result.UNSUPPORTED;
                for (int i=0; i< references.length &&
                    result == Result.UNSUPPORTED; i++) {

                    ServiceReference ref = references[i];
                    Object service =
                        context.getBundleContext().getService(ref);
                    if (null == service) {
                        Object[] params = new Object[] {
                            ref.getProperty("service.pid"),
                            ref.getBundle().getSymbolicName()
                        };
                        LOGGER.error("service-has-been-unregistered", params);
                    } else {
                        Operation operation =
                            (Operation) service;
                        result  = operation.execute(
                            descriptor, request, response);
                    }
                }
                if (result == Result.UNSUPPORTED) {
                    throw new OperationNotFoundException(
                        "no-plugin-available",
                            new String[] { descriptor.getExternalID(), descriptor.getResourceType() });
                }
            }
        } catch (OperationNotFoundException x) {
            sendError(response, descriptor, HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, x);
        } catch (ParameterBuilderException x) {
View Full Code Here

Examples of com.volantis.synergetics.descriptorstore.ResourceDescriptor

        }

        // TODO later If there's an appropriate plugin, allow it to do pre-processing of the parameters.
        // plugin.preProcess(inputParameters, outputParameters, device);

        ResourceDescriptor descriptor = descriptorStore.createDescriptor(
            request.getResourceType(), inputParameters, outputParameters,
            timeToLive);

        // TODO later If there's an appropriate plugin, allow it to do post-processing of the parameters.
        // plugin.postProcess(outputParameters, device);

        MutableParameters callbackParameters = COMMON_FACTORY.createMutableParameters();
        Iterator processedParameters = descriptor.getOutputParameters().iterator();
        while (processedParameters.hasNext()) {
            Parameters.Entry entry = (Parameters.Entry) processedParameters.next();
            callbackParameters.setParameterValue(entry.getName(), entry.getValue());
        }
        String externalId = descriptor.getExternalID();
        externalIds.add(externalId);
        // base 64 can contain "/"
        externalId = externalId.replaceAll("/", "-");
        callbackParameters.setParameterValue(
            OUTPUT_URL_PARAMETER_NAME, urlPrefix + externalId);
View Full Code Here

Examples of com.volantis.synergetics.descriptorstore.ResourceDescriptor

     * @return true if obj is equal to this instance
     */
    public boolean equals(Object obj) {
        boolean result = false;
        if (getClass() == obj.getClass()) {
            ResourceDescriptor other = (ResourceDescriptor) obj;
            if (getExternalID().equals(other.getExternalID())
                && getInputParameters().equals(
                    other.getInputParameters())
                && getOutputParameters().equals(
                    other.getOutputParameters())
                && getRequestedParameterNames().equals(
                    other.getRequestedParameterNames())){
                result = true;
            }
        }
        return result;
    }
View Full Code Here

Examples of com.volantis.synergetics.descriptorstore.ResourceDescriptor

        com.volantis.map.operation.ResourceDescriptor localDescriptor = null;
        try {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Obtaining descriptor for id " + externalID);
            }
            ResourceDescriptor descriptor = store.getDescriptor(externalID);
            localDescriptor = new DelegatingResourceDescriptor(descriptor);
        } catch (ResourceDescriptorStoreException e) {
            throw new ResourceDescriptorNotFoundException(e);
        }
View Full Code Here

Examples of org.apache.hadoop.gateway.descriptor.ResourceDescriptor

  }

  private void contributeResources( DeploymentContext context, Service service ) throws URISyntaxException {
    List<FilterParamDescriptor> params;

    ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
    rootResource.role( service.getRole() );
    rootResource.pattern( EXTERNAL_PATH + "/?**" );
    addWebAppSecFilters(context, service, rootResource);
    addAuthenticationFilter( context, service, rootResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( rootResource.createFilterParam().name( "response.headers" ).value( getQualifiedName() + "/headers/outbound" ) );
    addRewriteFilter( context, service, rootResource, params );
    addIdentityAssertionFilter( context, service, rootResource );
    addAuthorizationFilter(context, service, rootResource);
    addDispatchFilter( context, service, rootResource );
   
    ResourceDescriptor pathResource = context.getGatewayDescriptor().addResource();
    pathResource.role( service.getRole() );
    pathResource.pattern( EXTERNAL_PATH + "/**?**" );
    addWebAppSecFilters(context, service, pathResource);
    addAuthenticationFilter( context, service, pathResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( rootResource.createFilterParam().name( "response.headers" ).value( getQualifiedName() + "/headers/outbound" ) );
    addRewriteFilter( context, service, pathResource, params );
    addIdentityAssertionFilter( context, service, pathResource );
    addAuthorizationFilter(context, service, pathResource);
    addDispatchFilter( context, service, pathResource );

    ResourceDescriptor statusResource = context.getGatewayDescriptor().addResource();
    statusResource.role( service.getRole() );
    statusResource.pattern( EXTERNAL_PATH + "/status/cluster?**" );
    addWebAppSecFilters(context, service, statusResource);
    addAuthenticationFilter( context, service, statusResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( statusResource.createFilterParam().name( "response.body" ).value( getQualifiedName() + "/status/outbound" ) );
    addRewriteFilter( context, service, statusResource, params );
    addIdentityAssertionFilter( context, service, statusResource );
    addAuthorizationFilter(context, service, statusResource);
    addDispatchFilter( context, service, statusResource );

    ResourceDescriptor regionResource = context.getGatewayDescriptor().addResource();
    regionResource.role( service.getRole() );
    regionResource.pattern( EXTERNAL_PATH + "/*/regions?**" );
    addWebAppSecFilters(context, service, regionResource);
    addAuthenticationFilter( context, service, regionResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( regionResource.createFilterParam().name( "response.body" ).value( getQualifiedName() + "/regions/outbound" ) );
    addRewriteFilter( context, service, regionResource, params );
    addIdentityAssertionFilter( context, service, regionResource );
    addAuthorizationFilter(context, service, regionResource);
    addDispatchFilter( context, service, regionResource );
  }
View Full Code Here

Examples of org.apache.hadoop.gateway.descriptor.ResourceDescriptor

    stream.close();
    return rules;
  }

  private void contributeResources( DeploymentContext context, Service service ) throws URISyntaxException {
    ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
    rootResource.role( service.getRole() );
    rootResource.pattern( WEBHCAT_EXTERNAL_PATH + "/?**" );
    addWebAppSecFilters( context, service, rootResource );
    addAuthenticationFilter( context, service, rootResource );
    addRewriteFilter( context, service, rootResource, null );
    addIdentityAssertionFilter( context, service, rootResource );
    addAuthorizationFilter( context, service, rootResource );
    addDispatchFilter( context, service, rootResource );

    ResourceDescriptor pathResource = context.getGatewayDescriptor().addResource();
    pathResource.role( service.getRole() );
    pathResource.pattern( WEBHCAT_EXTERNAL_PATH + "/**?**" );
    addWebAppSecFilters( context, service, pathResource );
    addAuthenticationFilter( context, service, pathResource );
    addRewriteFilter( context, service, pathResource, null );
    addIdentityAssertionFilter( context, service, pathResource );
    addAuthorizationFilter( context, service, pathResource );
View Full Code Here

Examples of org.apache.hadoop.gateway.descriptor.ResourceDescriptor

    clusterRules.addRules( serviceRules );
  }

  public void contributeNameNodeResource( DeploymentContext context, Service service ) throws URISyntaxException {
    List<FilterParamDescriptor> params;
    ResourceDescriptor rootResource = context.getGatewayDescriptor().addResource();
    rootResource.role( service.getRole() );
    rootResource.pattern( WEBHDFS_EXTERNAL_PATH + "/?**" );
    addWebAppSecFilters(context, service, rootResource);
    addAuthenticationFilter( context, service, rootResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( rootResource.createFilterParam().
        name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/root" ) );
    addRewriteFilter( context, service, rootResource, params );
    addIdentityAssertionFilter( context, service, rootResource );
    addAuthorizationFilter( context, service, rootResource );
    addDispatchFilter( context, service, rootResource, "dispatch", "http-client" );

    ResourceDescriptor fileResource = context.getGatewayDescriptor().addResource();
    fileResource.role( service.getRole() );
    fileResource.pattern( WEBHDFS_EXTERNAL_PATH + "/**?**" );
    addWebAppSecFilters(context, service, fileResource);
    addAuthenticationFilter( context, service, fileResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( fileResource.createFilterParam().
        name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/file" ) );
    params.add( fileResource.createFilterParam().
        name( UrlRewriteServletFilter.RESPONSE_HEADERS_FILTER_PARAM ).value( getQualifiedName() + "/outbound/namenode/headers" ) );
    addRewriteFilter( context, service, fileResource, params );
    addIdentityAssertionFilter( context, service, fileResource );
    addAuthorizationFilter( context, service, fileResource );
    addDispatchFilter( context, service, fileResource, "dispatch", "http-client" );

    ResourceDescriptor homeResource = context.getGatewayDescriptor().addResource();
    homeResource.role( service.getRole() );
    homeResource.pattern( WEBHDFS_EXTERNAL_PATH + "/~?**" );
    addWebAppSecFilters(context, service, homeResource);
    addAuthenticationFilter( context, service, homeResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( homeResource.createFilterParam().
        name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/home" ) );
    addRewriteFilter( context, service, homeResource, params );
    addIdentityAssertionFilter( context, service, homeResource );
    addAuthorizationFilter( context, service, homeResource );
    addDispatchFilter( context, service, homeResource, "dispatch", "http-client" );

    ResourceDescriptor homeFileResource = context.getGatewayDescriptor().addResource();
    homeFileResource.role( service.getRole() );
    homeFileResource.pattern( WEBHDFS_EXTERNAL_PATH + "/~/**?**" );
    addWebAppSecFilters(context, service, homeFileResource);
    addAuthenticationFilter( context, service, homeFileResource );
    params = new ArrayList<FilterParamDescriptor>();
    params.add( homeFileResource.createFilterParam().
        name( UrlRewriteServletFilter.REQUEST_URL_RULE_PARAM ).value( getQualifiedName() + "/inbound/namenode/home/file" ) );
    params.add( homeFileResource.createFilterParam().
        name( UrlRewriteServletFilter.RESPONSE_HEADERS_FILTER_PARAM ).value( getQualifiedName() + "/outbound/namenode/headers" ) );
    addRewriteFilter( context, service, homeFileResource, params );
    addIdentityAssertionFilter( context, service, homeFileResource );
    addAuthorizationFilter( context, service, homeFileResource );
    addDispatchFilter( context, service, homeFileResource, "dispatch", "http-client" );
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.