Java Code Examples for org.apache.hadoop.fs.swift.util.SwiftObjectPath#getObject()

The following examples show how to use org.apache.hadoop.fs.swift.util.SwiftObjectPath#getObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwiftRestClient.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Find objects in a directory
 *
 * @param path path prefix
 * @param requestHeaders optional request headers
 * @return byte[] file data or null if the object was not found
 * @throws IOException on IO Faults
 * @throws FileNotFoundException if nothing is at the end of the URI -that is,
 * the directory is empty
 */
public byte[] listDeepObjectsInDirectory(SwiftObjectPath path,
                                         boolean listDeep,
                                     final Header... requestHeaders)
        throws IOException {
  preRemoteCommand("listDeepObjectsInDirectory");

  String endpoint = getEndpointURI().toString();
  StringBuilder dataLocationURI = new StringBuilder();
  dataLocationURI.append(endpoint);
  String object = path.getObject();
  if (object.startsWith("/")) {
    object = object.substring(1);
  }
  if (!object.endsWith("/")) {
    object = object.concat("/");
  }

  if (object.equals("/")) {
    object = "";
  }

  dataLocationURI = dataLocationURI.append("/")
          .append(path.getContainer())
          .append("/?prefix=")
          .append(object)
          .append("&format=json");

  //in listing deep set param to false
  if (listDeep == false) {
      dataLocationURI.append("&delimiter=/");
  }

  return findObjects(dataLocationURI.toString(), requestHeaders);
}
 
Example 2
Source File: SwiftNativeFileSystemStore.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a hadoop-Path from a swift path, inserting the URI authority
 * of this FS instance
 * @param path swift object path
 * @return Hadoop path
 * @throws SwiftException if the URI couldn't be created.
 */
private Path getCorrectSwiftPath(SwiftObjectPath path) throws
        SwiftException {
  try {
    final URI fullUri = new URI(uri.getScheme(),
            uri.getAuthority(),
            path.getObject(),
            null,
            null);

    return new Path(fullUri);
  } catch (URISyntaxException e) {
    throw new SwiftException("Specified path " + path + " is incorrect", e);
  }
}
 
Example 3
Source File: SwiftRestClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Find objects in a directory
 *
 * @param path path prefix
 * @param requestHeaders optional request headers
 * @return byte[] file data or null if the object was not found
 * @throws IOException on IO Faults
 * @throws FileNotFoundException if nothing is at the end of the URI -that is,
 * the directory is empty
 */
public byte[] listDeepObjectsInDirectory(SwiftObjectPath path,
                                         boolean listDeep,
                                     final Header... requestHeaders)
        throws IOException {
  preRemoteCommand("listDeepObjectsInDirectory");

  String endpoint = getEndpointURI().toString();
  StringBuilder dataLocationURI = new StringBuilder();
  dataLocationURI.append(endpoint);
  String object = path.getObject();
  if (object.startsWith("/")) {
    object = object.substring(1);
  }
  if (!object.endsWith("/")) {
    object = object.concat("/");
  }

  if (object.equals("/")) {
    object = "";
  }

  dataLocationURI = dataLocationURI.append("/")
          .append(path.getContainer())
          .append("/?prefix=")
          .append(object)
          .append("&format=json");

  //in listing deep set param to false
  if (listDeep == false) {
      dataLocationURI.append("&delimiter=/");
  }

  return findObjects(dataLocationURI.toString(), requestHeaders);
}
 
Example 4
Source File: SwiftNativeFileSystemStore.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a hadoop-Path from a swift path, inserting the URI authority
 * of this FS instance
 * @param path swift object path
 * @return Hadoop path
 * @throws SwiftException if the URI couldn't be created.
 */
private Path getCorrectSwiftPath(SwiftObjectPath path) throws
        SwiftException {
  try {
    final URI fullUri = new URI(uri.getScheme(),
            uri.getAuthority(),
            path.getObject(),
            null,
            null);

    return new Path(fullUri);
  } catch (URISyntaxException e) {
    throw new SwiftException("Specified path " + path + " is incorrect", e);
  }
}
 
Example 5
Source File: SwiftRestClient.java    From sahara-extra with Apache License 2.0 5 votes vote down vote up
/**
 * Find objects in a directory
 *
 * @param path path prefix
 * @param addTrailingSlash should a trailing slash be added if there isn't one
 * @param requestHeaders optional request headers
 * @return byte[] file data or null if the object was not found
 * @throws IOException on IO Faults
 * @throws FileNotFoundException if nothing is at the end of the URI -that is,
 * the directory is empty
 */
public byte[] listDeepObjectsInDirectory(SwiftObjectPath path,
                                         boolean listDeep,
                                         boolean addTrailingSlash,
                                     final Header... requestHeaders)
        throws IOException {
  preRemoteCommand("listDeepObjectsInDirectory");

  String endpoint = getEndpointURI().toString();
  StringBuilder dataLocationURI = new StringBuilder();
  dataLocationURI.append(endpoint);
  String object = path.getObject();
  if (object.startsWith("/")) {
    object = object.substring(1);
  }
  if (addTrailingSlash && !object.endsWith("/")) {
    object = object.concat("/");
  }

  if (object.equals("/")) {
    object = "";
  }

  dataLocationURI = dataLocationURI.append("/")
          .append(path.getContainer())
          .append("/?prefix=")
          .append(object)
          .append("&format=json");

  //in listing deep set param to false
  if (listDeep == false) {
      dataLocationURI.append("&delimiter=/");
  }

  return findObjects(dataLocationURI.toString(), requestHeaders);
}
 
Example 6
Source File: SwiftNativeFileSystemStore.java    From sahara-extra with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a hadoop-Path from a swift path, inserting the URI authority
 * of this FS instance
 * @param path swift object path
 * @return Hadoop path
 * @throws SwiftException if the URI couldn't be created.
 */
private Path getCorrectSwiftPath(SwiftObjectPath path) throws
        SwiftException {
  try {
    final URI fullUri = new URI(uri.getScheme(),
            uri.getAuthority(),
            path.getObject(),
            null,
            null);

    return new Path(fullUri);
  } catch (URISyntaxException e) {
    throw new SwiftException("Specified path " + path + " is incorrect", e);
  }
}