use of org.javaswift.joss.model.StoredObject in project stocator by CODAIT.
the class SwiftAPIClient method rename.
@Override
public boolean rename(String hostName, String srcPath, String dstPath) throws IOException {
LOG.debug("Rename from {} to {}. hostname is {}", srcPath, dstPath, hostName);
String objNameSrc = srcPath.toString();
if (srcPath.toString().startsWith(hostName)) {
objNameSrc = getObjName(hostName, srcPath);
}
String objNameDst = dstPath.toString();
if (objNameDst.toString().startsWith(hostName)) {
objNameDst = getObjName(hostName, dstPath);
}
if (stocatorPath.isTemporaryPathContain(objNameSrc)) {
LOG.debug("Rename on the temp object {}. Return true", objNameSrc);
return true;
}
LOG.debug("Rename modified from {} to {}", objNameSrc, objNameDst);
Container cont = mJossAccount.getAccount().getContainer(container);
StoredObject so = cont.getObject(objNameSrc);
StoredObject soDst = cont.getObject(objNameDst);
so.copyObject(cont, soDst);
return true;
}
use of org.javaswift.joss.model.StoredObject in project stocator by CODAIT.
the class SwiftAPIClient method delete.
@Override
public boolean delete(String hostName, Path path, boolean recursive) throws IOException {
String obj = path.toString();
if (path.toString().startsWith(hostName)) {
obj = getObjName(hostName, path);
}
LOG.debug("Object name to delete {}. Path {}", obj, path.toString());
try {
StoredObject so = mJossAccount.getAccount().getContainer(container).getObject(obj);
if (so.exists()) {
so.delete();
objectCache.remove(obj);
}
} catch (Exception e) {
LOG.warn(e.getMessage());
LOG.warn("Delete on {} resulted in FileNotFound exception", path);
return false;
}
return true;
}
use of org.javaswift.joss.model.StoredObject in project alluxio by Alluxio.
the class SwiftMockOutputStream method close.
@Override
public void close() throws IOException {
if (mClosed) {
return;
}
mOutputStream.close();
try {
Container container = mAccount.getContainer(mContainerName);
StoredObject object = container.getObject(mObjectName);
object.uploadObject(mFile);
} catch (Exception e) {
throw new IOException(e);
}
// Close successful
mClosed = true;
}
use of org.javaswift.joss.model.StoredObject in project alluxio by Alluxio.
the class SwiftUnderFileSystem method deleteObject.
@Override
protected boolean deleteObject(String path) throws IOException {
try {
Container container = mAccount.getContainer(mContainerName);
StoredObject object = container.getObject(path);
if (object != null) {
object.delete();
return true;
}
} catch (CommandException e) {
LOG.debug("Object {} not found", path);
}
return false;
}
use of org.javaswift.joss.model.StoredObject in project alluxio by Alluxio.
the class SwiftUnderFileSystem method createEmptyObject.
@Override
public boolean createEmptyObject(String key) {
try {
Container container = mAccount.getContainer(mContainerName);
StoredObject object = container.getObject(key);
object.uploadObject(new byte[0]);
return true;
} catch (CommandException e) {
LOG.error("Failed to create object: {}", key, e);
return false;
}
}
Aggregations