2018-10-02 12:05:43 +02:00
|
|
|
package org.gcube.contentmanagement.blobstorage.service.operation;
|
|
|
|
|
2020-12-22 17:57:44 +01:00
|
|
|
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
|
2018-10-02 12:05:43 +02:00
|
|
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.BucketCoding;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.service.directoryOperation.DirectoryBucket;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManager;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.TransportManagerFactory;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
|
|
|
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
public class GetFolderCount extends Operation {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logger for this class
|
|
|
|
*/
|
|
|
|
final Logger logger=LoggerFactory.getLogger(GetSize.class);
|
|
|
|
|
|
|
|
public GetFolderCount(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);
|
|
|
|
}
|
|
|
|
|
2020-12-22 17:57:44 +01:00
|
|
|
public String doIt(RequestObject myFile) throws RemoteBackendException{
|
2020-11-12 18:11:07 +01:00
|
|
|
// TransportManagerFactory tmf= new TransportManagerFactory(server, user, password);
|
|
|
|
// TransportManager tm=tmf.getTransport(backendType, myFile.getGcubeMemoryType(), dbNames, myFile.getWriteConcern(), myFile.getReadPreference());
|
|
|
|
TransportManager tm=getTransport(myFile);
|
2018-10-02 12:05:43 +02:00
|
|
|
long dim=0;
|
|
|
|
try {
|
|
|
|
dim = tm.getFolderTotalItems(bucket);
|
|
|
|
} catch (Exception e) {
|
|
|
|
tm.close();
|
|
|
|
throw new RemoteBackendException(" Error in getFolderTotalItems operation ", e.getCause()); }
|
|
|
|
if (logger.isDebugEnabled()) {
|
|
|
|
logger.debug(" PATH " + bucket);
|
|
|
|
}
|
|
|
|
return ""+dim;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-12-22 17:57:44 +01:00
|
|
|
public String initOperation(RequestObject file, String remotePath,
|
2018-10-02 12:05:43 +02:00
|
|
|
String author, String[] server, String rootArea, boolean replaceOption) {
|
|
|
|
if(logger.isDebugEnabled())
|
|
|
|
logger.debug("remotePath: "+remotePath);
|
|
|
|
String buck=null;
|
|
|
|
BucketCoding bc=new BucketCoding();
|
|
|
|
buck=bc.bucketFileCoding(remotePath, rootArea);
|
|
|
|
if(!Costants.CLIENT_TYPE.equalsIgnoreCase("mongo")){
|
|
|
|
buck=buck.replaceAll(Costants.FILE_SEPARATOR, Costants.SEPARATOR);
|
|
|
|
//remove directory bucket
|
|
|
|
DirectoryBucket dirBuc=new DirectoryBucket(server,user, password, remotePath, author);
|
|
|
|
dirBuc.removeKeysOnDirBucket(file, buck, rootArea, backendType, dbNames);
|
|
|
|
}
|
|
|
|
return bucket=buck;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-12-22 17:57:44 +01:00
|
|
|
public String initOperation(RequestObject resource, String RemotePath,
|
2018-10-02 12:05:43 +02:00
|
|
|
String author, String[] server, String rootArea) {
|
|
|
|
throw new IllegalArgumentException("Input/Output stream is not compatible with getSize operation");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|