コード例 #1
0
 /**
  * Updates the Ds3Request's parameter: BucketId is changed from type UUID to String if said
  * parameter exists within the request
  */
 protected static Ds3Request updateDs3RequestParamTypes(final Ds3Request ds3Request) {
   return new Ds3Request(
       ds3Request.getName(),
       ds3Request.getHttpVerb(),
       ds3Request.getClassification(),
       ds3Request.getBucketRequirement(),
       ds3Request.getObjectRequirement(),
       ds3Request.getAction(),
       ds3Request.getResource(),
       ds3Request.getResourceType(),
       ds3Request.getOperation(),
       ds3Request.getIncludeInPath(),
       ds3Request.getDs3ResponseCodes(),
       updateDs3ParamListTypes(ds3Request.getOptionalQueryParams()),
       updateDs3ParamListTypes(ds3Request.getRequiredQueryParams()));
 }
コード例 #2
0
  @Test
  public void SingleRequestHandler() throws IOException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec =
        parser.getSpec(
            Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/singleRequestHandler.xml"));
    assertThat(spec, is(notNullValue()));
    assertThat(spec.getRequests().size(), is(1));

    final Ds3Request ds3Request = spec.getRequests().get(0);
    assertThat(
        ds3Request.getName(),
        is("com.spectralogic.s3.server.handler.reqhandler.amazons3.GetObjectRequest"));
    assertThat(ds3Request.getHttpVerb(), is(HttpVerb.GET));
    assertThat(ds3Request.getClassification(), is(Classification.amazons3));
    assertThat(ds3Request.getBucketRequirement(), is(Requirement.REQUIRED));
    assertThat(ds3Request.getObjectRequirement(), is(Requirement.REQUIRED));
    assertThat(ds3Request.getAction(), is(nullValue()));
    assertThat(ds3Request.getResource(), is(nullValue()));
    assertThat(ds3Request.getResourceType(), is(nullValue()));
    assertThat(ds3Request.getOperation(), is(nullValue()));

    assertThat(ds3Request.getDs3ResponseCodes().size(), is(1));
    assertThat(ds3Request.getDs3ResponseCodes().get(0).getCode(), is(200));
    assertThat(ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().size(), is(1));
    assertThat(
        ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().get(0).getType(),
        is("java.lang.String"));
    assertThat(
        ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().get(0).getComponentType(),
        is(nullValue()));

    assertThat(ds3Request.getOptionalQueryParams().size(), is(0));
    assertThat(ds3Request.getRequiredQueryParams().size(), is(1));
    assertThat(ds3Request.getRequiredQueryParams().get(0).getName(), is("Id"));
    assertThat(ds3Request.getRequiredQueryParams().get(0).getType(), is("java.util.UUID"));
  }
コード例 #3
0
  @Override
  public Request generate(
      final Ds3Request ds3Request, final String packageName, final Ds3DocSpec docSpec) {
    final Ds3Request updatedRequest = updateDs3RequestParamTypes(ds3Request);
    final String requestName = removePath(updatedRequest.getName());
    final String requestPath = getRequestPath(updatedRequest);
    final String parentClass = getParentClass(ds3Request);

    final ImmutableList<Arguments> optionalArguments =
        splitAllUuidOptionalArguments(
            toOptionalArgumentsList(updatedRequest.getOptionalQueryParams()));

    final ImmutableList<RequestConstructor> constructors =
        splitAllUuidConstructors(toConstructorList(updatedRequest, requestName, docSpec));

    final ImmutableList<Variable> classVariableArguments =
        convertAllUuidClassVariables(toClassVariableArguments(updatedRequest));

    final ImmutableList<String> imports = getAllImports(updatedRequest, packageName);

    final ImmutableList<String> withConstructors =
        toWithConstructorList(optionalArguments, requestName, docSpec);

    return new Request(
        packageName,
        requestName,
        parentClass,
        updatedRequest.getHttpVerb(),
        requestPath,
        updatedRequest.getOperation(),
        updatedRequest.getAction(),
        optionalArguments,
        constructors,
        classVariableArguments,
        imports,
        withConstructors);
  }