Fixed Layer deletion on multiple GS instances
This commit is contained in:
parent
1ec69d1ad0
commit
d08bb8315a
|
@ -337,6 +337,7 @@ public class SDIManager {
|
|||
//Checking layer
|
||||
publishStyle(Files.getFileFromResources("styles/clustered_points.sld"),style);
|
||||
|
||||
log.info("Creating layer in {} : {} with FTE {} , LE {}",workspace,storeName,fte,layerEncoder);
|
||||
if(currentGeoserver.getReader().getLayer(workspace, name)==null)
|
||||
if(!currentGeoserver.getPublisher().publishDBLayer(workspace, storeName, fte, layerEncoder))
|
||||
throw new SDIInteractionException("Unable to create layer "+name);
|
||||
|
@ -351,13 +352,30 @@ public class SDIManager {
|
|||
|
||||
|
||||
public void deleteContent(GeoServerContent toDelete) throws IllegalArgumentException, MalformedURLException, RemoteServiceException {
|
||||
log.debug("Deleting geoserver layer "+toDelete);
|
||||
log.info("Deleting geoserver layer "+toDelete);
|
||||
|
||||
String geoserverHostName=toDelete.getGeoserverHostName();
|
||||
log.debug("Looking for geoserver {}",geoserverHostName);
|
||||
|
||||
AbstractGeoServerDescriptor geoServerDescriptor=null;
|
||||
|
||||
for(AbstractGeoServerDescriptor gs :gis.getCurrentCacheElements(false)){
|
||||
log.debug("Checking gs {}",gs);
|
||||
if(new URL(gs.getUrl()).getHost().equals(geoserverHostName))
|
||||
geoServerDescriptor=gs;
|
||||
}
|
||||
if(geoServerDescriptor == null) throw new IllegalArgumentException("Unable to find geoserver "+geoserverHostName);
|
||||
|
||||
GeoServerRESTPublisher publisher=geoServerDescriptor.getPublisher();
|
||||
|
||||
//delete layer
|
||||
GeoServerRESTPublisher publisher=currentGeoserver.getPublisher();
|
||||
//delete store
|
||||
log.debug("Removing DS {} : {} ",toDelete.getWorkspace(),toDelete.getStore());
|
||||
publisher.removeDatastore(toDelete.getWorkspace(), toDelete.getStore(), true);
|
||||
|
||||
//delete WS if empty
|
||||
GeoServerRESTReader reader=currentGeoserver.getReader();
|
||||
GeoServerRESTReader reader=geoServerDescriptor.getReader();
|
||||
log.debug("Checking if WS {} is empty",toDelete.getWorkspace());
|
||||
if(reader.getDatastores(toDelete.getWorkspace()).isEmpty()) {
|
||||
log.debug("Deleting emtpy workspace "+toDelete.getWorkspace());
|
||||
publisher.removeWorkspace(toDelete.getWorkspace(), true);
|
||||
|
@ -367,6 +385,7 @@ public class SDIManager {
|
|||
|
||||
// TODO REMOVE HARDCODED PATCH
|
||||
String path=toDelete.getGeoserverPath().replace("/srv/geoserver_data","geoserver");
|
||||
log.info("Deleting files at {} [{}]",path,toDelete.getGeoserverPath());
|
||||
// path=toDelete.getGeoserverPath();
|
||||
dtGeoServer.getWebClient().delete(path);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ConcessioniOverMongo {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
public void deleteById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
@QueryParam("force") Boolean forceOption) {
|
||||
@QueryParam(InterfaceConstants.Parameters.FORCE) Boolean forceOption) {
|
||||
new GuardedMethod<Concessione> () {
|
||||
@Override
|
||||
protected Concessione run() throws Exception, WebApplicationException {
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.gcube.application.geoportal.service.engine.ImplementationProvider;
|
|||
import org.gcube.application.geoportal.service.engine.StorageClientProvider;
|
||||
import org.gcube.application.geoportal.service.engine.cache.MongoClientProvider;
|
||||
import org.gcube.application.geoportal.service.engine.cache.MongoConnectionProvider;
|
||||
import org.gcube.application.geoportal.service.legacy.TokenSetter;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
|||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.application.geoportal.service.legacy.TokenSetter;
|
||||
import org.gcube.application.geoportal.service.utils.Serialization;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -101,6 +100,14 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
|||
check(target.path(published.getMongo_id()).request(MediaType.APPLICATION_JSON).delete(),null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deletePrecise(){
|
||||
WebTarget target=target(PATH);
|
||||
String id="60195d0c02ad3d7fa3614d75";
|
||||
target.path(id).queryParam(InterfaceConstants.Parameters.FORCE,true).request(MediaType.APPLICATION_JSON).delete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getById() throws Exception {
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.application.geoportal.service;
|
|||
|
||||
import org.gcube.application.geoportal.service.engine.SDIManager;
|
||||
import org.gcube.application.geoportal.service.engine.postgis.PostgisIndex;
|
||||
import org.gcube.application.geoportal.service.legacy.TokenSetter;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.SDIInteractionException;
|
||||
import org.junit.Assert;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.geoportal.service.legacy;
|
||||
package org.gcube.application.geoportal.service;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.mongodb.Block;
|
||||
import com.mongodb.MongoClient;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.service.TokenSetter;
|
||||
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
|
||||
import org.gcube.application.geoportal.service.engine.cache.MongoClientProvider;
|
||||
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
|
||||
|
|
Reference in New Issue