added some logs

This commit is contained in:
Francesco Mangiacrapa 2024-10-02 16:08:48 +02:00
parent e83c814fb6
commit d4189e0c98
9 changed files with 172 additions and 166 deletions

View File

@ -24,7 +24,6 @@ public class WorkspaceManager {
private static final String APP_FOLDER = ".GNA_RECORDS";
private StorageHubClient sgClient = null;
@Getter
private FolderContainer appBase = null;
@ -54,7 +53,6 @@ public class WorkspaceManager {
private FolderContainer parent;
// Added by Francesco, see #28150
private Long size;
}
public Archive getConfiguration() {
@ -90,7 +88,6 @@ public class WorkspaceManager {
return getSubFolder(parentFolder, path, "");
}
/**
* Returns sub folder. Creates it if missing
*
@ -99,7 +96,8 @@ public class WorkspaceManager {
* @return
* @throws StorageHubException
*/
public FolderContainer getSubFolder(FolderContainer parentFolder,String path, String description) throws StorageHubException {
public FolderContainer getSubFolder(FolderContainer parentFolder, String path, String description)
throws StorageHubException {
try {
return parentFolder.openByRelativePath(path).asFolder();
} catch (StorageHubException e) {
@ -118,7 +116,6 @@ public class WorkspaceManager {
}
}
// public WorkspaceContent storeToWS(FileOptions opts) throws FileNotFoundException, StorageHubException {
// FileContainer item=createFileRoutine(opts);
// item=sgClient.open(item.getId()).asFile();
@ -138,7 +135,6 @@ public class WorkspaceManager {
RegisteredFile file = new RegisteredFile();
file.setLink(item.getPublicLink().toString());
file.setMimetype(item.get().getContent().getMimeType());
file.setStorageID(item.getId());
@ -147,7 +143,6 @@ public class WorkspaceManager {
}
// public void deleteFromWS(WorkspaceContent toDelete) throws StorageHubException {
// sgClient.open(toDelete.getStorageID()).asFile().forceDelete();
// }
@ -180,8 +175,8 @@ public class WorkspaceManager {
@Synchronized
private static FileContainer createFileRoutine(FileOptions opts) throws StorageHubException {
// Updated by Francesco, see #28150
log.info("Uploading file name: {}, in the parent folder id: {}, filesize is: {}", opts.getFileName(),
opts.getParent().getId(), opts.getSize());
log.info("Uploading file name: {}, in the parent folder id: {}, filesize is: " + opts.getSize(),
opts.getFileName(), opts.getParent().getId());
opts.setFileName(Files.fixFilename(opts.getFileName()));
if (opts.getSize() == null)
return opts.getParent().uploadFile(opts.getIs(), opts.getFileName(), opts.getFileDescription());

View File

@ -11,9 +11,9 @@ import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
import org.gcube.application.geoportal.common.model.rest.CreateRelationshipRequest;
import org.gcube.application.geoportal.common.model.rest.DeleteRelationshipRequest;
import org.gcube.application.geoportal.common.model.rest.PerformStepRequest;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
import org.gcube.application.geoportal.common.model.rest.PerformStepRequest;
public interface Projects<P extends Project> {

View File

@ -13,6 +13,9 @@ import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
import org.gcube.application.geoportal.common.model.rest.TempFile;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FileSets {
public static class RequestBuilder {
@ -24,6 +27,7 @@ public class FileSets {
theRequest.getStreams().addAll(toAdd);
return this;
}
public RequestBuilder add(TempFile... f) {
if (theRequest.getStreams() == null)
theRequest.setStreams(new ArrayList<TempFile>());
@ -68,7 +72,8 @@ public class FileSets {
if (theRequest.getClashOption() == null)
// default Clash Policy
setClashPolicy(RegisterFileSetRequest.ClashOptions.REPLACE_EXISTING);
return theRequest;}
return theRequest;
}
public RequestBuilder setAccess(Access access) {
theRequest.setToSetAccess(access);
@ -77,28 +82,30 @@ public class FileSets {
}
public static RequestBuilder build(String parent, String fieldName, String fieldDefinition) {
return new RequestBuilder().setParentPath(parent).setFieldDefinitionPath(fieldDefinition).setFieldName(fieldName);
return new RequestBuilder().setParentPath(parent).setFieldDefinitionPath(fieldDefinition)
.setFieldName(fieldName);
}
public static RequestBuilder build(String parent, String fieldName, String fieldDefinition, TempFile... files) {
return build(parent, fieldName, fieldDefinition).add(files);
}
public static TempFile asTemp(StorageUtils storage,InputStreamDescriptor descriptor) throws RemoteBackendException, FileNotFoundException {
public static TempFile asTemp(StorageUtils storage, InputStreamDescriptor descriptor)
throws RemoteBackendException, FileNotFoundException {
return storage.putOntoStorage(descriptor.getStream(), descriptor.getFilename());
}
public static TempFile[] asTemp(StorageUtils storage,InputStreamDescriptor... descriptors) throws RemoteBackendException, FileNotFoundException {
public static TempFile[] asTemp(StorageUtils storage, InputStreamDescriptor... descriptors)
throws RemoteBackendException, FileNotFoundException {
ArrayList<TempFile> toReturn = new ArrayList<TempFile>();
for (InputStreamDescriptor desc : descriptors)
toReturn.add(storage.putOntoStorage(desc.getStream(), desc.getFilename()));
return toReturn.toArray(new TempFile[toReturn.size()]);
}
public static RegisterFileSetRequest prepareRequestFromFolder(StorageUtils storage,
String parentPath,String fieldName,String fieldDefinition, File directory) throws FileNotFoundException {
public static RegisterFileSetRequest prepareRequestFromFolder(StorageUtils storage, String parentPath,
String fieldName, String fieldDefinition, File directory) throws FileNotFoundException {
File[] children = directory.listFiles();
InputStreamDescriptor[] iss = new InputStreamDescriptor[children.length];
@ -106,15 +113,18 @@ public class FileSets {
}
public static RegisterFileSetRequest prepareRequest(StorageUtils storage,
String parentPath,String fieldName,String fieldDefinition, File... toUpload) throws FileNotFoundException {
public static RegisterFileSetRequest prepareRequest(StorageUtils storage, String parentPath, String fieldName,
String fieldDefinition, File... toUpload) throws FileNotFoundException {
FileSets.RequestBuilder builder = FileSets.build(parentPath, fieldName, fieldDefinition);
for (File f : toUpload) {
if (!f.isDirectory()) {
TempFile file = FileSets.asTemp(storage, new InputStreamDescriptor(new FileInputStream(f), f.getName()));
long fileSize = f.length();
TempFile file = FileSets.asTemp(storage,
new InputStreamDescriptor(new FileInputStream(f), f.getName()));
// Added by Francesco, see #28150
file.setSize(f.length());
log.info("PrepareRequest for tempfile name " + file.getFilename() + " size: " + file.getSize());
file.setSize(fileSize);
builder.add(file);
}
}

View File

@ -1,8 +1,6 @@
package org.gcube.application.geoportal.common;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.common.utils.Files;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
@ -11,7 +9,9 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertTrue;
import org.gcube.application.geoportal.common.utils.Files;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FilesTests {

View File

@ -1,5 +1,8 @@
package org.gcube.application.geoportal.common;
import java.util.EnumSet;
import java.util.Set;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
@ -7,9 +10,6 @@ import com.jayway.jsonpath.spi.json.JsonProvider;
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
import com.jayway.jsonpath.spi.mapper.MappingProvider;
import java.util.EnumSet;
import java.util.Set;
public class JacksonProvider implements JSONSerializationProvider {

View File

@ -1,16 +1,6 @@
package org.gcube.application.geoportal.common;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.utils.ContextUtils;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assume.assumeTrue;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -22,7 +12,16 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import static org.junit.Assume.assumeTrue;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.utils.ContextUtils;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StorageUtilsTest {

View File

@ -1,10 +1,11 @@
package org.gcube.application.geoportal.common;
import lombok.extern.slf4j.Slf4j;
import java.util.Properties;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import java.util.Properties;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TokenSetter {

View File

@ -1,13 +1,12 @@
package org.gcube.application.geoportal.common.legacy;
import static org.junit.Assert.assertEquals;
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class DefaultsTests {

View File

@ -1,12 +1,8 @@
package org.gcube.application.geoportal.common.model;
import com.jayway.jsonpath.JsonPath;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.document.lifecycle.TriggeredEvents;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.utils.Files;
import org.junit.Test;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertTrue;
import java.io.File;
import java.io.IOException;
@ -15,7 +11,13 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import static junit.framework.TestCase.*;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.document.lifecycle.TriggeredEvents;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.utils.Files;
import com.jayway.jsonpath.JsonPath;
public class JSONPathTests {