61 lines
2.1 KiB
Java
61 lines
2.1 KiB
Java
package org.gcube.contentmanagement.blobstorage.service.operation;
|
|
|
|
import org.bson.types.ObjectId;
|
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.BucketCoding;
|
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
public class SetMetaInfo extends Operation {
|
|
|
|
/**
|
|
* Logger for this class
|
|
*/
|
|
final Logger logger=LoggerFactory.getLogger(GetSize.class);
|
|
|
|
public SetMetaInfo(String[] server, String user, String pwd, String bucket, Monitor monitor, boolean isChunk, String backendType, String[] dbs) {
|
|
super(server, user, pwd, bucket, monitor, isChunk, backendType, dbs);
|
|
}
|
|
|
|
public String doIt(RequestObject requestObject) throws RemoteBackendException{
|
|
TransportManager tm=getTransport(requestObject);
|
|
try {
|
|
tm.setFileProperty(bucket, requestObject.getGenericPropertyField(), requestObject.getGenericPropertyValue());
|
|
} catch (Exception e) {
|
|
tm.close();
|
|
e.printStackTrace();
|
|
logger.error("Problem setting file property", e);
|
|
throw new RemoteBackendException(" Error in SetMetaInfo operation ", e); }
|
|
if (logger.isDebugEnabled()) {
|
|
logger.debug(" PATH " + bucket);
|
|
}
|
|
return "1";
|
|
}
|
|
|
|
@Override
|
|
public String initOperation(RequestObject file, String remotePath,
|
|
String author, String[] server, String rootArea, boolean replaceOption) {
|
|
if(logger.isDebugEnabled())
|
|
logger.debug("remotePath: "+remotePath);
|
|
String buck=null;
|
|
boolean isId=ObjectId.isValid(remotePath);
|
|
if(!isId){
|
|
buck = new BucketCoding().bucketFileCoding(remotePath, rootArea);
|
|
return bucket=buck;
|
|
}else{
|
|
return bucket=remotePath;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
public String initOperation(RequestObject resource, String RemotePath,
|
|
String author, String[] server, String rootArea) {
|
|
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
|
}
|
|
|
|
|
|
}
|