コード例 #1
0
 /**
  * Creates the Java request path code for an AmazonS3 request
  *
  * @param ds3Request A request
  * @return The Java request path code for an AmazonS3 request
  */
 protected static String getAmazonS3RequestPath(final Ds3Request ds3Request) {
   final StringBuilder builder = new StringBuilder();
   if (ds3Request.getClassification() != Classification.amazons3) {
     return builder.toString();
   }
   builder.append("\"/\"");
   if (ds3Request.getBucketRequirement() == Requirement.REQUIRED) {
     builder.append(" + this.bucketName");
   }
   if (ds3Request.getObjectRequirement() == Requirement.REQUIRED) {
     builder.append(" + \"/\" + this.objectName");
   }
   return builder.toString();
 }
コード例 #2
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()));
 }
コード例 #3
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"));
  }