Java 类javax.ws.rs.core.UriBuilderException 实例源码

项目:che    文件:ExternalIpURLRewriter.java   
@Override
public String rewriteURL(@Nullable RuntimeIdentity identity, @Nullable String name, String url)
    throws InfrastructureException {

  if (externalIpOfContainers != null) {
    try {
      URI uri = UriBuilder.fromUri(url).host(externalIpOfContainers).build();
      url = uri.toString();
    } catch (UriBuilderException | IllegalArgumentException e) {
      throw new InternalInfrastructureException(
          format(
              "Rewriting of host '%s' in URL '%s' failed. Error: %s",
              externalIpOfContainers, url, e.getMessage()));
    }
  }
  return url;
}
项目:im-java-api    文件:ImClient.java   
/**
 * Returns a Rest client configured with the specified properties.
 * 
 * @param path
 *          : path where the client is going to connect (e.g.
 *          /infrastructures/asdalk-asd34/vms)
 * @param parameters
 *          : extra parameters for the call (if needed)
 * @return : REST client
 */
public Builder configureClient(final String path,
    final RestParameter... parameters) throws ImClientException {
  try {
    WebTarget webtarget = getClient()
        .target(UriBuilder.fromUri(getTargetUrl()).build()).path(path);

    if (parameters != null && parameters.length > 0
        && parameters[0] != null) {
      for (RestParameter parameter : parameters) {
        webtarget.queryParam(parameter.getName(), parameter.getValues());
      }
    }

    return webtarget.request(MediaType.APPLICATION_JSON)
        .header(AUTH_HEADER_TAG, getParsedAuthFile());
  } catch (IllegalArgumentException | UriBuilderException exception) {
    ImJavaApiLogger.severe(this.getClass(), exception);
    throw exception;
  }
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @param baseUri
 *
 * @return
 *
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
private Invocation preparePOSTInvocationBuilder(final String mimeType, final String contentType, final String query)
                throws IllegalArgumentException, UriBuilderException, UnsupportedEncodingException {
    final UriBuilder baseBuilder = UriBuilder.fromUri(HOST).port(PORT);
    final URI targetUri = baseBuilder.path(QueryExecutor.ENDPOINT_NAME).build();

    final Client client = ClientBuilder.newClient();
    final WebTarget resourceTarget = client.target(targetUri);
    final Builder invocationBuilder = resourceTarget.request(mimeType);

    final Entity<String> entity = Entity.entity(query,
                    Variant.mediaTypes(MediaType.valueOf(contentType))
                    .encodings("UTF-8")
                    .build()
                    .get(0),
                    null);
    final Invocation invocation = invocationBuilder.buildPost(entity);

    return invocation;
}
项目:checklistbank    文件:NameUsageMatchWsClientTest.java   
/**
 * Test http://dev.gbif.org/issues/browse/POR-2688
 * We expect a client handler or uniform interface exception cause we did not setup the entire jersey stack properly.
 * We only want to make sure there is no UriBuilderException thrown
 */
@Test
public void testCurlyBrackets() {
  try {
    WebResource api = Client.create().resource("http://api.gbif.org/v1/species/match");
    WebResource  q = api.queryParam("name", "Nereis southerni %7B%7Bnowrap Abdel-Moez & Humphries, 1955");
    assertEquals(
      "http://api.gbif.org/v1/species/match?name=Nereis+southerni+%7B%7Bnowrap+Abdel-Moez+%26+Humphries,+1955",
      q.toString());

    NameUsageMatchWsClient client = new NameUsageMatchWsClient(api);

    client.match("Nereis southerni {{nowrap Abdel-Moez & Humphries, 1955", null, null, false, false);
  } catch (RuntimeException e) {
    if (e instanceof UriBuilderException) {
      throw e;
    }
    System.out.println(e.toString());
  }
}
项目:freedomotic    文件:ReactionTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    testCOPY = false;
    Command com = new Command();
    com.setName("Reaction Command");
    com.setHardwareLevel(false);

    Trigger t = new Trigger();
    t.setName("Reaction trigger");
    Trigger t2 = new Trigger();
    t2.setName("Second Trigger");

    getApi().triggers().create(t);
    getApi().triggers().create(t2);

    getApi().commands().create(com);

    Reaction r = new Reaction(t, com);
    setItem(new ReactionRepresentation(r));

    initPath(ReactionResource.class);
    setListType(new GenericType<List<ReactionRepresentation>>(){});
    setSingleType(new GenericType<ReactionRepresentation>(){});
}
项目:freedomotic    文件:ZoneTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    setItem(new Zone());
    getItem().setName("Test Zone");
    getItem().setAsRoom(true);
    getItem().setDescription("Before editing");
    e.setName("Test env for zone");
    e.setUUID(getUuid());
    el.setPojo(e);
    el.init();
    getApi().environments().create(el);

    initPath(UriBuilder.fromResource(EnvironmentResource.class).path(e.getUUID()).path("/rooms").build().toString());
    setListType(new GenericType<List<Zone>>(){});
    setSingleType(new GenericType<Zone>(){});        
}
项目:Java-9-Programming-Blueprints    文件:AuthenticationResource.java   
private String getCallbackUri() throws UriBuilderException, IllegalArgumentException {
    return uriInfo.getBaseUriBuilder()
            .path("auth")
            .path("callback")
            .build()
            .toASCIIString();
}
项目:firehose    文件:ConfigurationResource.java   
Response getResponse(boolean updated, UriInfo info) throws UriBuilderException, IllegalArgumentException {
    if (updated) {
        return Response.
                noContent().
                build();
    } else {
        URI uri = info.getAbsolutePathBuilder().
                build();
        return Response.
                created(uri).
                build();
    }
}
项目:emodb    文件:EmoUriBuilder.java   
private URI createURI(String uri) {
    try {
        return new URI(uri);
    } catch (URISyntaxException ex) {
        throw new UriBuilderException(ex);
    }
}
项目:MyVidCoRe    文件:EmbeddedHttpServer.java   
private HttpServer createHttpServer()
    throws IOException, IllegalArgumentException, UriBuilderException, URISyntaxException {
    ResourceConfig resourceConfig = new ResourceConfig()
        .packages(true, Configuration.instance().getStrings("APP.Jersey.Resources").toArray(new String[0]))
        .register(FrontendFeature.class);
    EncodingFilter.enableFor(resourceConfig, GZipEncoder.class);
    return GrizzlyHttpServerFactory.createHttpServer(getURI(), resourceConfig, false);
}
项目:FinanceAnalytics    文件:MockUriBuilder.java   
@Override
public URI build(Object... values) throws IllegalArgumentException, UriBuilderException {
  String url = null;
  try {
    url = new Formatter().format(_pathFormat, values).toString();
  } catch (Exception ex) {
    throw new UriBuilderException("Problem building url from format[" + _pathFormat + "] and values[" + values + "]", ex);
  }
  return URI.create(url);
}
项目:incubator-taverna-server    文件:Uri.java   
@Override
public URI buildFromMap(Map<String, ?> values,
        boolean encodeSlashInPath) throws IllegalArgumentException,
        UriBuilderException {
    return rewrite(wrapped.buildFromEncoded(values,
            encodeSlashInPath));
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @param baseUri
 *
 * @return
 *
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
private Invocation prepareGETInvocationBuilder(final String mimeType, final String query)
                throws IllegalArgumentException, UriBuilderException, UnsupportedEncodingException {
    final UriBuilder baseBuilder = UriBuilder.fromUri(HOST).port(PORT);
    final URI targetUri = baseBuilder.path(QueryExecutor.ENDPOINT_NAME)
                    .queryParam(QUERY_PARAM, URLEncoder.encode(query, "UTF-8").replace("+", "%20")).build();

    final Client client = ClientBuilder.newClient();
    final WebTarget resourceTarget = client.target(targetUri);
    final Builder invocationBuilder = resourceTarget.request(mimeType);
    final Invocation invocation = invocationBuilder.buildGet();

    return invocation;
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
@Test
public void testQueryExecutionSuccessfulGET()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testSuccessfulMethod(Method.GET);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
@Test
public void testQueryExecutionSuccessfulURLPOST()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testSuccessfulMethod(Method.URL_ENCODED_POST);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
@Test
public void testQueryExecutionSuccessfulDirectPOST()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testSuccessfulMethod(Method.DIRECT_POST);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
@Test
public void testQueryExecutionInvalidFormatOnGET()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testUnsuccessfulMethod(Method.GET, QueryExecutor.INVALID_FORMAT_STATUS_CODE);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
@Test
public void testQueryExecutionInvalidFormatURLPOST()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testUnsuccessfulMethod(Method.URL_ENCODED_POST, QueryExecutor.INVALID_FORMAT_STATUS_CODE);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
@Test
public void testQueryExecutionInvalidFormatDirectPOST()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testUnsuccessfulMethod(Method.DIRECT_POST, QueryExecutor.INVALID_FORMAT_STATUS_CODE);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
//@Test
public void testQueryExecutionQuerySyntaxErrorOnGET()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testInvalidQueryMethod(Method.GET);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
//@Test
public void testQueryExecutionQuerySyntaxErrorURLPOST()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testInvalidQueryMethod(Method.URL_ENCODED_POST);
}
项目:semanticoctopus    文件:QueryExecutorTest.java   
/**
 * @throws IllegalMimeTypeException
 * @throws UnsupportedEncodingException
 * @throws UriBuilderException
 * @throws IllegalArgumentException
 */
//@Test
public void testQueryExecutionQuerySyntaxErrorDirectPOST()
                throws IllegalMimeTypeException, IllegalArgumentException, UriBuilderException,
                UnsupportedEncodingException {
    testInvalidQueryMethod(Method.DIRECT_POST);
}
项目:fintp_api    文件:GroupMessagesResource.java   
/**
 * Returns the resource formatted as json
 * 
 * @return JSONObject * @throws JSONException
 */
@SuppressWarnings("unchecked")
public JSONObject asJson() throws JSONException {
    JSONObject messagesAsJson = super.asJson();

    // fill data
    JSONArray queuesArray = new JSONArray();
    List<?> items = getItems();
    if (items.size() > 0) {
        if (null != queueEntity){
            for (Object[] messageEntity : (List<Object[]>) items) {
                try {
                    queuesArray.put(GroupMessageResource.asJson(
                            messageEntity,
                            isMessageInQueue,
                            needsPayload,UriBuilder.fromPath(getUriInfo().getPath())
                            .path(messageEntity[0].toString()).build()
                            .getPath()));
                } catch (IllegalArgumentException | UriBuilderException
                        | ParseException e) {
                    // TODO Auto-generated catch block
                }
            }
        }
    }
    messagesAsJson.put("groupmessages", queuesArray);
    return messagesAsJson;
}
项目:mymam    文件:RestClientProvider.java   
private static URI stringToUri(String string) throws ConfigErrorException {
    try {
        return UriBuilder.fromUri(string).build();
    }
    catch ( IllegalArgumentException | UriBuilderException e ) {
        throw new ConfigErrorException(string + " is not a valid URI.");
    }
}
项目:connector4java    文件:AuthService.java   
URI getAuthorizationUri(Scope... scopes) {
    checkState(!Strings.isNullOrEmpty(clientRedirectUri), "Can't create the login uri: redirect URI was not set.");
    try {
        String formattedScopes = getScopesAsString(scopes);

        return UriBuilder.fromUri(endpoint).path("/oauth/authorize")
                .queryParam("client_id", clientId)
                .queryParam("response_type", "code")
                .queryParam("redirect_uri", clientRedirectUri)
                .queryParam("scope", formattedScopes)
                .build();
    } catch (UriBuilderException | IllegalArgumentException e) {
        throw new OsiamClientException("Unable to create redirect URI", e);
    }
}
项目:fcrepo4    文件:FedoraLdp.java   
private static String checkInteractionModel(final List<String> links) {
    if (links == null) {
        return null;
    }

    try {
        for (String link : links) {
            final Link linq = Link.valueOf(link);
            if ("type".equals(linq.getRel())) {
                final Resource type = createResource(linq.getUri().toString());
                if (type.equals(NON_RDF_SOURCE) || type.equals(BASIC_CONTAINER) ||
                        type.equals(DIRECT_CONTAINER) || type.equals(INDIRECT_CONTAINER)) {
                    return "ldp:" + type.getLocalName();
                } else {
                    LOGGER.info("Invalid interaction model: {}", type);
                    throw new CannotCreateResourceException("Invalid interaction model: " + type);
                }
            }
        }
    } catch (final RuntimeException e) {
        if (e instanceof IllegalArgumentException | e instanceof UriBuilderException) {
            throw new ClientErrorException("Invalid link specified: " + String.join(", ", links), BAD_REQUEST);
        }
        throw e;
    }

    return null;
}
项目:Supervisor    文件:Settings.java   
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getStatisticsIndex(@Context final
UriInfo uriInfo) throws IllegalArgumentException, UriBuilderException, JSONException {

    final JSONObject result = new JSONObject();
    result.put(MAX_RESULTS_PATH, uriInfo.getBaseUriBuilder().path(Settings.class).path(MAX_RESULTS_PATH).build());
    result.put(PAGE_REFRESH_PATH, uriInfo.getBaseUriBuilder().path(Settings.class).path(PAGE_REFRESH_PATH).build());

    return Response.ok(result.toString()).build();
}
项目:freedomotic    文件:HardwareCommandTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    setItem(new Command());
    getItem().setName("TestCmd");
    getItem().setUUID(getUuid());
    getItem().setProperty("prop1", "value1");
    getItem().setReceiver("receiver.channel");
    getItem().setHardwareLevel(true);
    initPath(HardwareCommandResource.class);
    setListType(new GenericType<List<Command>>() {
    });
    setSingleType(new GenericType<Command>() {
    });

}
项目:freedomotic    文件:UserCommandTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    setItem(new Command());
    getItem().setName("TestCmd");
    getItem().setUUID(getUuid());
    getItem().setProperty("prop1", "value1");
    getItem().setReceiver("receiver.channel");
    initPath(UserCommandResource.class);
    setListType(new GenericType<List<Command>>(){});
    setSingleType(new GenericType<Command>(){});

}
项目:freedomotic    文件:RoleTest.java   
@Override
void init() throws UriBuilderException, IllegalArgumentException {
    setItem(role);
    getItem().setName("TestRole");
    getItem().getPermissions().add("read:*");
    initPath(RoleResource.class);
    setListType(new GenericType<List<RoleRepresentation>>(){});
    setSingleType(new GenericType<RoleRepresentation>(){});
}
项目:freedomotic    文件:ThingTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    e.setName("Test env for zone");
    e.setUUID(getUuid());

    el.setPojo(e);
    el.init();
    getApi().environments().create(el);

    setItem(obj);
    getItem().setName("TestObject");
    getItem().setUUID(getUuid());
    getItem().setHierarchy("com.freedomotic.things.impl.ElectricDevice");
    getItem().setType("EnvObject.ElectricDevice");
    getItem().setEnvironmentID(e.getUUID());
    Representation r = new Representation();
    r.setOffset(0, 0);
    r.setTangible(true);
    FreedomPolygon s = new FreedomPolygon();
    s.append(0, 0);
    s.append(0, 1);
    s.append(1, 1);
    s.append(1, 0);
    r.setShape(s);
    getItem().getRepresentations().add(r);
    getItem().setCurrentRepresentation(0);
    BooleanBehavior b = new BooleanBehavior();
    b.setName("powered");
    b.setValue(true);
    getItem().getBehaviors().add(b);
    initPath(ThingResource.class);
    setListType(new GenericType<List<EnvObject>>() {
    });
    setSingleType(new GenericType<EnvObject>() {
    });
}
项目:freedomotic    文件:TriggerTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    setItem(new Trigger());
    getItem().setName("TestTrg");
    getItem().setUUID(getUuid());
    getItem().setChannel("test.trigger.channel");
    initPath(TriggerResource.class);
    setListType(new GenericType<List<Trigger>>() {
    });
    setSingleType(new GenericType<Trigger>() {
    });
}
项目:freedomotic    文件:EnvironmentTest.java   
@Override
public void init() throws UriBuilderException, IllegalArgumentException {
    setItem(env);
    getItem().setName("TestEnv");
    getItem().setUUID(getUuid());
    initPath(EnvironmentResource.class);
    setListType(new GenericType<List<Environment>>(){});
    setSingleType(new GenericType<Environment>(){});
}
项目:freedomotic    文件:UserTest.java   
@Override
void init() throws UriBuilderException, IllegalArgumentException {
    SimpleRole r = new SimpleRole();
    r.setName("admin");
    r.add(new WildcardPermission("*"));
    getApi().getAuth().addRole(r);

    User u = new User("user","password","admin",getApi().getAuth());
    setItem(new UserRepresentation(u));

    initPath(UserResource.class);
    setListType(new GenericType<List<UserRepresentation>>(){});
    setSingleType(new GenericType<UserRepresentation>(){});
    testDELETE = false;
}
项目:hadoop    文件:MockStorageInterface.java   
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  ArrayList<ListBlobItem> ret = new ArrayList<ListBlobItem>();
  URI searchUri = null;
  if (prefix == null) {
    searchUri = uri;
  } else {
    try {
      searchUri = UriBuilder.fromUri(uri).path(prefix).build();
    } catch (UriBuilderException e) {
      throw new AssertionError("Failed to encode path: " + prefix);
    }
  }

  String fullPrefix = convertUriToDecodedString(searchUri);
  boolean includeMetadata = listingDetails.contains(BlobListingDetails.METADATA);
  HashSet<String> addedDirectories = new HashSet<String>();
  for (InMemoryBlockBlobStore.ListBlobEntry current : backingStore.listBlobs(
      fullPrefix, includeMetadata)) {
    int indexOfSlash = current.getKey().indexOf('/', fullPrefix.length());
    if (useFlatBlobListing || indexOfSlash < 0) {
      if (current.isPageBlob()) {
        ret.add(new MockCloudPageBlobWrapper(
            convertKeyToEncodedUri(current.getKey()),
            current.getMetadata(),
            current.getContentLength()));
      } else {
      ret.add(new MockCloudBlockBlobWrapper(
          convertKeyToEncodedUri(current.getKey()),
          current.getMetadata(),
          current.getContentLength()));
      }
    } else {
      String directoryName = current.getKey().substring(0, indexOfSlash);
      if (!addedDirectories.contains(directoryName)) {
        addedDirectories.add(current.getKey());
        ret.add(new MockCloudBlobDirectoryWrapper(new URI(
            directoryName + "/")));
      }
    }
  }
  return ret;
}
项目:mid-tier    文件:ErrorRepresentation.java   
private HALLink createResourceLink(URI uri) throws IllegalArgumentException, UriBuilderException {
    return (new dk.nykredit.jackson.dataformat.hal.HALLink.Builder(uri)).title("Link to failed resource").build();
}
项目:aliyun-oss-hadoop-fs    文件:MockStorageInterface.java   
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  ArrayList<ListBlobItem> ret = new ArrayList<ListBlobItem>();
  URI searchUri = null;
  if (prefix == null) {
    searchUri = uri;
  } else {
    try {
      searchUri = UriBuilder.fromUri(uri).path(prefix).build();
    } catch (UriBuilderException e) {
      throw new AssertionError("Failed to encode path: " + prefix);
    }
  }

  String fullPrefix = convertUriToDecodedString(searchUri);
  boolean includeMetadata = listingDetails.contains(BlobListingDetails.METADATA);
  HashSet<String> addedDirectories = new HashSet<String>();
  for (InMemoryBlockBlobStore.ListBlobEntry current : backingStore.listBlobs(
      fullPrefix, includeMetadata)) {
    int indexOfSlash = current.getKey().indexOf('/', fullPrefix.length());
    if (useFlatBlobListing || indexOfSlash < 0) {
      if (current.isPageBlob()) {
        ret.add(new MockCloudPageBlobWrapper(
            convertKeyToEncodedUri(current.getKey()),
            current.getMetadata(),
            current.getContentLength()));
      } else {
      ret.add(new MockCloudBlockBlobWrapper(
          convertKeyToEncodedUri(current.getKey()),
          current.getMetadata(),
          current.getContentLength()));
      }
    } else {
      String directoryName = current.getKey().substring(0, indexOfSlash);
      if (!addedDirectories.contains(directoryName)) {
        addedDirectories.add(current.getKey());
        ret.add(new MockCloudBlobDirectoryWrapper(new URI(
            directoryName + "/")));
      }
    }
  }
  return ret;
}
项目:ccow    文件:IContextManagementRegistry.java   
Form Locate(String componentName, String version, String descriptiveData, String contextParticipant,
UriInfo uriInfo) throws UnableToLocateException, UnknownPropertyNameException, BadPropertyValueException,
        MalformedURLException, IllegalArgumentException, UriBuilderException;
项目:big-c    文件:MockStorageInterface.java   
@Override
public Iterable<ListBlobItem> listBlobs(String prefix,
    boolean useFlatBlobListing, EnumSet<BlobListingDetails> listingDetails,
    BlobRequestOptions options, OperationContext opContext)
    throws URISyntaxException, StorageException {
  ArrayList<ListBlobItem> ret = new ArrayList<ListBlobItem>();
  URI searchUri = null;
  if (prefix == null) {
    searchUri = uri;
  } else {
    try {
      searchUri = UriBuilder.fromUri(uri).path(prefix).build();
    } catch (UriBuilderException e) {
      throw new AssertionError("Failed to encode path: " + prefix);
    }
  }

  String fullPrefix = convertUriToDecodedString(searchUri);
  boolean includeMetadata = listingDetails.contains(BlobListingDetails.METADATA);
  HashSet<String> addedDirectories = new HashSet<String>();
  for (InMemoryBlockBlobStore.ListBlobEntry current : backingStore.listBlobs(
      fullPrefix, includeMetadata)) {
    int indexOfSlash = current.getKey().indexOf('/', fullPrefix.length());
    if (useFlatBlobListing || indexOfSlash < 0) {
      if (current.isPageBlob()) {
        ret.add(new MockCloudPageBlobWrapper(
            convertKeyToEncodedUri(current.getKey()),
            current.getMetadata(),
            current.getContentLength()));
      } else {
      ret.add(new MockCloudBlockBlobWrapper(
          convertKeyToEncodedUri(current.getKey()),
          current.getMetadata(),
          current.getContentLength()));
      }
    } else {
      String directoryName = current.getKey().substring(0, indexOfSlash);
      if (!addedDirectories.contains(directoryName)) {
        addedDirectories.add(current.getKey());
        ret.add(new MockCloudBlobDirectoryWrapper(new URI(
            directoryName + "/")));
      }
    }
  }
  return ret;
}
项目:emodb    文件:EmoUriBuilder.java   
@Override
public URI buildFromEncodedMap(Map<String, ?> values) throws IllegalArgumentException, UriBuilderException {
    // EMODB-MODIFICATION:  Templates are not supported, so buildFromMap is not supported
    throw new UnsupportedOperationException("Templates not supported");
}