Enforcing fail management
This commit is contained in:
parent
0e26e2c75d
commit
2aac7299a8
|
@ -90,6 +90,7 @@ public class SDIService extends ResourceConfig{
|
|||
registerClasses(Thredds.class);
|
||||
registerClasses(Metadata.class);
|
||||
|
||||
log.warn("Initialization complete");
|
||||
// register(MoxyXmlFeature.class);
|
||||
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@ import lombok.extern.slf4j.Slf4j;
|
|||
public class Metadata {
|
||||
|
||||
@Inject
|
||||
TemplateManager templateManager;
|
||||
private TemplateManager templateManager;
|
||||
@Inject
|
||||
GeoNetworkManager geonetworkManager;
|
||||
private GeoNetworkManager geonetworkManager;
|
||||
@Inject
|
||||
TemporaryPersistence persistence;
|
||||
private TemporaryPersistence persistence;
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
|
@ -85,7 +85,7 @@ public class Metadata {
|
|||
}
|
||||
MetadataReport toReturn=new MetadataReport();
|
||||
Set<TemplateInvocation> metadataEnrichments=new HashSet<>(templateInvocations);
|
||||
|
||||
|
||||
if(metadataEnrichments!=null && !metadataEnrichments.isEmpty()){
|
||||
try{
|
||||
log.debug("Applying invocations...");
|
||||
|
@ -114,10 +114,10 @@ public class Metadata {
|
|||
MetadataReport toReturn=new MetadataReport();
|
||||
File toPublish=persistence.getById(uploadedId);
|
||||
log.debug("Publishing metadata.. ");
|
||||
|
||||
|
||||
GeoNetworkDescriptor desc=geonetworkManager.getSuggestedInstances().get(0);
|
||||
GeoNetworkClient client=geonetworkManager.getClient(desc);
|
||||
|
||||
|
||||
String uuid=new MetadataHandler(toPublish).getUUID();
|
||||
long id=0;
|
||||
try {
|
||||
|
@ -131,8 +131,8 @@ public class Metadata {
|
|||
throw new RuntimeException("Insert Operation failed with unexpected reason (Metadata with uuid "+uuid+" has not been found).",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
toReturn.setPublishedID(id);
|
||||
toReturn.setPublishedUUID(uuid);
|
||||
return toReturn;
|
||||
|
@ -151,10 +151,15 @@ public class Metadata {
|
|||
@Path("/list")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Collection<TemplateDescriptor> getList(){
|
||||
log.debug("Received LIST method");
|
||||
TemplateCollection coll= templateManager.getAvailableMetadataTemplates();
|
||||
log.debug("Gonna respond with {} ",coll);
|
||||
return coll.getAvailableTemplates();
|
||||
try{
|
||||
log.debug("Received LIST method");
|
||||
TemplateCollection coll= templateManager.getAvailableMetadataTemplates();
|
||||
log.debug("Gonna respond with {} ",coll);
|
||||
return coll.getAvailableTemplates();
|
||||
}catch(Throwable e ){
|
||||
log.warn("Unexpected error while getting templates",e);
|
||||
throw new WebApplicationException("Unabel to publish metadata. Cause "+e.getMessage(),Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Thredds {
|
|||
|
||||
|
||||
@Inject
|
||||
ThreddsManager threddsManager;
|
||||
private ThreddsManager threddsManager;
|
||||
|
||||
|
||||
@PUT
|
||||
|
|
Loading…
Reference in New Issue