git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-access/sh-fuse-integration/1.0@181088 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bfb4fabd69
commit
c7be9c9c9c
|
@ -11,6 +11,7 @@ import org.cache2k.Cache;
|
|||
import org.cache2k.Cache2kBuilder;
|
||||
import org.gcube.common.authorization.library.AuthorizedTasks;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.gxrest.response.outbound.ErrorCode;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.storagehub.client.dsl.ContainerType;
|
||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
|
@ -83,7 +84,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
|
||||
logger.trace(Thread.currentThread().getName()+" ) calling write "+ size+" "+offset);
|
||||
SHFile file = tempFiles.get(path);
|
||||
|
||||
|
||||
return file.write(buf, size, offset);
|
||||
}
|
||||
|
||||
|
@ -114,13 +115,13 @@ public class StorageHubFS extends FuseStubFS {
|
|||
if (pathUtils.getPath(path) != null) {
|
||||
return -ErrorCodes.EEXIST();
|
||||
}
|
||||
|
||||
uploadFile(path);
|
||||
return 0;
|
||||
|
||||
|
||||
return uploadFile(path);
|
||||
}
|
||||
|
||||
|
||||
private void uploadFile(String path) {
|
||||
|
||||
private int uploadFile(String path) {
|
||||
final ItemContainer<? extends Item> parentContainer;
|
||||
|
||||
if (path.substring(1).contains("/")) {
|
||||
|
@ -128,6 +129,13 @@ public class StorageHubFS extends FuseStubFS {
|
|||
parentContainer= pathUtils.getPath(parentPath);
|
||||
} else parentContainer = rootDirectory;
|
||||
|
||||
try {
|
||||
if (!((FolderContainer) parentContainer).canWrite())
|
||||
return -ErrorCodes.EACCES();
|
||||
}catch (Exception e) {
|
||||
return -ErrorCodes.EIO();
|
||||
}
|
||||
|
||||
final FSInputStream stream = new FSInputStream();
|
||||
|
||||
FileUpload fileUpload = new FileUpload(stream);
|
||||
|
@ -146,8 +154,9 @@ public class StorageHubFS extends FuseStubFS {
|
|||
cache.remove(path);
|
||||
}
|
||||
})).start();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized int getattr(String path, FileStat stat) {
|
||||
|
@ -180,7 +189,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void getAttrSHItem(ItemContainer<? extends Item> container, FileStat stat) throws IllegalArgumentException{
|
||||
if (container.getType()==ContainerType.FILE) {
|
||||
|
@ -221,9 +230,6 @@ public class StorageHubFS extends FuseStubFS {
|
|||
SecurityTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace(Thread.currentThread().getName()+" ) calling mkdir");
|
||||
if (pathUtils.getPath(path) != null) {
|
||||
return -ErrorCodes.EEXIST();
|
||||
}
|
||||
|
||||
ItemContainer<? extends Item> parentContainer;
|
||||
|
||||
|
@ -252,11 +258,11 @@ public class StorageHubFS extends FuseStubFS {
|
|||
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
|
||||
|
||||
logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address());
|
||||
|
||||
SHFile fileDownload = null;
|
||||
|
||||
|
||||
boolean loop =false;
|
||||
do {
|
||||
synchronized (tempFiles) {
|
||||
|
@ -268,15 +274,15 @@ public class StorageHubFS extends FuseStubFS {
|
|||
loop=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
|
||||
}
|
||||
}while(loop);
|
||||
|
||||
|
||||
|
||||
|
||||
synchronized (tempFiles) {
|
||||
|
||||
if (tempFiles.containsKey(path) && tempFiles.get(path) instanceof FileDownload) {
|
||||
|
@ -301,11 +307,11 @@ public class StorageHubFS extends FuseStubFS {
|
|||
tempFiles.put(path, fileDownload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int toReturn = fileDownload.read(buf, size, offset);
|
||||
|
||||
|
||||
logger.trace("!!! read ---- returning {}",toReturn);
|
||||
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
@ -515,14 +521,14 @@ public class StorageHubFS extends FuseStubFS {
|
|||
public int readlink(String path, Pointer buf, @size_t long size) {
|
||||
logger.info("readlink called {}",path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int open(String path, FuseFileInfo fi) {
|
||||
logger.info("open called {} {}",path, fi.fh.getMemory().address());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int release(String path, FuseFileInfo fi) {
|
||||
logger.info("release called {} {}",path, fi.fh.getMemory().address());
|
||||
|
@ -532,14 +538,14 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public int truncate(String path, long size) {
|
||||
logger.info("truncate called {} ",path);
|
||||
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
cache.remove(path);
|
||||
uploadFile(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int access(String path, int mask) {
|
||||
|
@ -552,7 +558,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
logger.trace("utimens called "+path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="org.gcube.data.access.storagehub.fs" level="WARN" />
|
||||
<logger name="org.gcube" level="WARN" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue