SDI Interaction Exception is now not rethrown

This commit is contained in:
Fabio Sinibaldi 2020-11-03 15:59:19 +01:00
parent ad39435e96
commit 972b1a3a1e
1 changed files with 21 additions and 21 deletions

View File

@ -17,6 +17,7 @@ import org.gcube.application.geoportal.model.content.PersistedContent;
import org.gcube.application.geoportal.model.content.UploadedImage;
import org.gcube.application.geoportal.model.content.WorkspaceContent;
import org.gcube.application.geoportal.model.fault.PersistenceException;
import org.gcube.application.geoportal.model.fault.SDIInteractionException;
import org.gcube.application.geoportal.model.gis.SDILayerDescriptor;
import org.gcube.application.geoportal.model.report.ValidationReport;
import org.gcube.application.geoportal.utils.Files;
@ -42,11 +43,6 @@ public class ContentHandler {
}
/**
* Register files as to be associated with content
*
@ -86,8 +82,8 @@ public class ContentHandler {
SDIManager sdiManager=null;
if(publish)
sdiManager=new SDIManager();
for(Entry<AssociatedContent,ArrayList<TempFile>> entry:uploadedResources.entrySet()) {
AssociatedContent content=entry.getKey();
ArrayList<PersistedContent> persisted=new ArrayList<PersistedContent>();
@ -95,7 +91,7 @@ public class ContentHandler {
String description=null;
String workspace=null;
log.debug("Storing "+content);
if(content instanceof RelazioneScavo) {
destination= wsManager.getSubFolder("relazione");
description="Relazione di scavo : "+content.getTitolo();
@ -108,27 +104,31 @@ public class ContentHandler {
if(content instanceof LayerConcessione) {
destination= wsManager.getSubFolder("layers/"+content.getTitolo());
description="Layer concessione : "+content.getTitolo();
if(publish) {
//if not present create workspace for current project
if(workspace==null)
workspace=sdiManager.createWorkspace("gna_conc_"+record.getId());
GeoServerContent geoserverPersisted=sdiManager.pushShapeLayerFileSet((SDILayerDescriptor)content, entry.getValue(),workspace);
geoserverPersisted.setAssociated(content);
persisted.add(geoserverPersisted);
try {
//if not present create workspace for current project
if(workspace==null)
workspace=sdiManager.createWorkspace("gna_conc_"+record.getId());
GeoServerContent geoserverPersisted=sdiManager.pushShapeLayerFileSet((SDILayerDescriptor)content, entry.getValue(),workspace);
geoserverPersisted.setAssociated(content);
persisted.add(geoserverPersisted);
}catch(SDIInteractionException e) {
log.warn("Unable to publish layers.",e);
}
}
}else throw new Exception("Invalid SDI Content "+content);
}else if (content instanceof OtherContent ) {
destination= wsManager.getSubFolder("other/"+content.getTitolo());
description= "Other content : "+content.getTitolo();
}else throw new Exception ("Invalid content "+content);
log.debug("Actually Storing files to WS folder "+destination.getId());
for(TempFile theFile : entry.getValue()) {
WorkspaceContent wsContent=wsManager.storeToWS(theFile.getTheFile(), destination, theFile.getOriginalFileName(), description);
wsContent.setAssociated(content);