refs #2222: Move infrastructure tests outside of components junit tests
https://support.d4science.org/issues/2222 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@124071 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d82be9431a
commit
4f15d5b3b0
57
pom.xml
57
pom.xml
|
@ -27,73 +27,110 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>document-store-lib</artifactId>
|
||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<version>[2.1.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>document-store-lib-couchbase</artifactId>
|
||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>document-store-lib-couchdb</artifactId>
|
||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.publishing</groupId>
|
||||
<artifactId>document-store-lib-mongodb</artifactId>
|
||||
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-lib</artifactId>
|
||||
<version>[2.1.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-analytics</artifactId>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-analytics-persistence-couchdb</artifactId>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>accounting-analytics-persistence-couchbase</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.vremanagement</groupId>
|
||||
<artifactId>smart-executor-client</artifactId>
|
||||
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.3.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.accounting</groupId>
|
||||
<artifactId>couchdb-cache-se-plugin</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>is-sweeper-se-plugin</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT]</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources</groupId>
|
||||
<artifactId>registry-publisher</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT]</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT]</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.13</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.io.StringWriter;
|
|||
import java.net.URL;
|
||||
|
||||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.testutility.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.Resources;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
|
@ -18,6 +17,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Runtime;
|
|||
import org.gcube.common.resources.gcore.common.Platform;
|
||||
import org.gcube.common.resources.gcore.utils.Group;
|
||||
import org.gcube.documentstore.persistence.PersistenceBackend;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.gcube.documentstore.persistence.PersistenceBackendFactory;
|
|||
import org.gcube.documentstore.persistence.PersistenceCouchBase;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.documentstore.persistence.PersistenceBackendFactory;
|
|||
import org.gcube.documentstore.persistence.PersistenceCouchDB;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.gcube.documentstore.persistence.PersistenceBackendFactory;
|
|||
import org.gcube.documentstore.persistence.PersistenceMongoDB;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -8,11 +8,15 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.testutility.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.documentstore.persistence.FallbackPersistenceBackend;
|
||||
import org.gcube.documentstore.persistence.PersistenceBackend;
|
||||
import org.gcube.documentstore.persistence.PersistenceBackendFactory;
|
||||
import org.gcube.documentstore.persistence.PersistenceBackendMonitor;
|
||||
import org.gcube.utils.StressTestUtility;
|
||||
import org.gcube.utils.TestOperation;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -52,13 +56,13 @@ public class PersistenceBackendMonitorTest {
|
|||
UsageRecord usageRecord = null;
|
||||
switch (i%3) {
|
||||
case 0:
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
break;
|
||||
case 1:
|
||||
usageRecord = TestUsageRecord.createTestStorageUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestStorageUsageRecord();
|
||||
break;
|
||||
case 2:
|
||||
usageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestJobUsageRecord();
|
||||
break;
|
||||
}
|
||||
try {
|
|
@ -9,11 +9,10 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.gcube.accounting.datamodel.BasicUsageRecord;
|
||||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.testutility.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.exception.InvalidValueException;
|
||||
import org.gcube.utils.StressTestUtility;
|
||||
import org.gcube.utils.TestOperation;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -60,13 +59,8 @@ public class PersistenceBackendTest {
|
|||
StressTestUtility.stressTest(new TestOperation() {
|
||||
@Override
|
||||
public void operate(int i) {
|
||||
UsageRecord usageRecord;
|
||||
try {
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecordExplicitScope();
|
||||
persistence.accountValidateAggregate(usageRecord, true, false);
|
||||
} catch (InvalidValueException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
persistence.accountValidateAggregate(usageRecord, true, false);
|
||||
}
|
||||
}, 1);
|
||||
|
||||
|
@ -79,7 +73,7 @@ public class PersistenceBackendTest {
|
|||
StressTestUtility.stressTest(new TestOperation() {
|
||||
@Override
|
||||
public void operate(int i) {
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
persistence.accountValidateAggregate(usageRecord, true, false);
|
||||
}
|
||||
}, 1);
|
||||
|
@ -93,7 +87,7 @@ public class PersistenceBackendTest {
|
|||
StressTestUtility.stressTest(new TestOperation() {
|
||||
@Override
|
||||
public void operate(int i) {
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
persistence.accountValidateAggregate(usageRecord, true, false);
|
||||
}
|
||||
});
|
||||
|
@ -106,7 +100,7 @@ public class PersistenceBackendTest {
|
|||
StressTestUtility.stressTest(new TestOperation() {
|
||||
@Override
|
||||
public void operate(int i) throws Exception {
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
persistence.account(usageRecord);
|
||||
}
|
||||
});
|
|
@ -6,7 +6,6 @@ package org.gcube.documentstore.persistence;
|
|||
import java.net.URL;
|
||||
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.persistence.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -7,9 +7,9 @@ import java.net.URL;
|
|||
|
||||
import org.codehaus.jackson.JsonNode;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.persistence.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.bson.Document;
|
|||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord.OperationType;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.persistence.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.junit.After;
|
||||
|
|
|
@ -10,13 +10,13 @@ import java.util.Map;
|
|||
import org.gcube.accounting.datamodel.UsageRecord;
|
||||
import org.gcube.accounting.datamodel.basetypes.TestUsageRecord;
|
||||
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
|
||||
import org.gcube.accounting.testutility.TestUtility;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.documentstore.persistence.PersistenceExecutor;
|
||||
import org.gcube.documentstore.records.AggregatedRecord;
|
||||
import org.gcube.documentstore.records.Record;
|
||||
import org.gcube.utils.StressTestUtility;
|
||||
import org.gcube.utils.TestOperation;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -78,12 +78,12 @@ public class AggregationSchedulerTest {
|
|||
StressTestUtility.stressTest(new TestOperation() {
|
||||
@Override
|
||||
public void operate(int i) throws Exception {
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
UsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
aggregationScheduler.aggregate(usageRecord, persistenceExecutor);
|
||||
}
|
||||
});
|
||||
List<String> types = new ArrayList<String>();
|
||||
String serviceUsageRecordtype = TestUsageRecord.createTestServiceUsageRecordAutomaticScope().getRecordType();
|
||||
String serviceUsageRecordtype = TestUsageRecord.createTestServiceUsageRecord().getRecordType();
|
||||
types.add(serviceUsageRecordtype);
|
||||
madeAssertion(aggregationScheduler.bufferedRecords, types, 1, StressTestUtility.DEFAULT_NUMBER_OF_RECORDS);
|
||||
aggregationScheduler.flush(persistenceExecutor);
|
||||
|
@ -97,7 +97,7 @@ public class AggregationSchedulerTest {
|
|||
StressTestUtility.stressTest(new TestOperation() {
|
||||
@Override
|
||||
public void operate(int i) throws Exception {
|
||||
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
ServiceUsageRecord usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
if(i%2==0){
|
||||
usageRecord.setServiceClass(ALTERNATIVE_SERVICE_CLASS);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class AggregationSchedulerTest {
|
|||
}
|
||||
});
|
||||
List<String> types = new ArrayList<String>();
|
||||
String serviceUsageRecordtype = TestUsageRecord.createTestServiceUsageRecordAutomaticScope().getRecordType();
|
||||
String serviceUsageRecordtype = TestUsageRecord.createTestServiceUsageRecord().getRecordType();
|
||||
types.add(serviceUsageRecordtype);
|
||||
|
||||
madeAssertion(aggregationScheduler.bufferedRecords, types, 2, StressTestUtility.DEFAULT_NUMBER_OF_RECORDS/2);
|
||||
|
@ -121,17 +121,17 @@ public class AggregationSchedulerTest {
|
|||
public void operate(int i) throws Exception {
|
||||
UsageRecord usageRecord;
|
||||
if(i%2==0){
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
}else{
|
||||
usageRecord = TestUsageRecord.createTestStorageUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestStorageUsageRecord();
|
||||
}
|
||||
aggregationScheduler.aggregate(usageRecord, persistenceExecutor);
|
||||
}
|
||||
});
|
||||
|
||||
List<String> types = new ArrayList<String>();
|
||||
String serviceUsageRecordtype = TestUsageRecord.createTestServiceUsageRecordAutomaticScope().getRecordType();
|
||||
String storageUsageRecordtype = TestUsageRecord.createTestStorageUsageRecordAutomaticScope().getRecordType();
|
||||
String serviceUsageRecordtype = TestUsageRecord.createTestServiceUsageRecord().getRecordType();
|
||||
String storageUsageRecordtype = TestUsageRecord.createTestStorageUsageRecord().getRecordType();
|
||||
types.add(serviceUsageRecordtype);
|
||||
types.add(storageUsageRecordtype);
|
||||
|
||||
|
@ -149,16 +149,16 @@ public class AggregationSchedulerTest {
|
|||
UsageRecord usageRecord;
|
||||
switch (i%3) {
|
||||
case 0:
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestServiceUsageRecord();
|
||||
break;
|
||||
case 1:
|
||||
usageRecord = TestUsageRecord.createTestStorageUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestStorageUsageRecord();
|
||||
break;
|
||||
case 2:
|
||||
usageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestJobUsageRecord();
|
||||
break;
|
||||
default:
|
||||
usageRecord = TestUsageRecord.createTestJobUsageRecordAutomaticScope();
|
||||
usageRecord = TestUsageRecord.createTestJobUsageRecord();
|
||||
}
|
||||
|
||||
aggregationScheduler.aggregate(usageRecord, persistenceExecutor);
|
|
@ -18,7 +18,7 @@ public class StressTestUtility {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(StressTestUtility.class);
|
||||
|
||||
protected final static int DEFAULT_NUMBER_OF_RECORDS = 3000;
|
||||
public final static int DEFAULT_NUMBER_OF_RECORDS = 3000;
|
||||
|
||||
public static void stressTest(TestOperation operation) throws Exception {
|
||||
stressTest(operation, DEFAULT_NUMBER_OF_RECORDS);
|
||||
|
|
|
@ -3,6 +3,19 @@
|
|||
*/
|
||||
package org.gcube.utils;
|
||||
|
||||
import java.io.StringWriter;
|
||||
|
||||
import org.gcube.common.authorization.client.Constants;
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.Resource;
|
||||
import org.gcube.common.resources.gcore.Resources;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.gcube.informationsystem.publisher.exception.RegistryNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
|
@ -11,4 +24,62 @@ public class TestUtility {
|
|||
|
||||
public static final String TOKEN = "";
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
private static Logger logger = LoggerFactory.getLogger(TestUtility.class);
|
||||
|
||||
public static String getScopeFromToken(){
|
||||
String token = SecurityTokenProvider.instance.get();
|
||||
AuthorizationEntry authorizationEntry;
|
||||
try {
|
||||
authorizationEntry = Constants.authorizationService().get(token);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String scope = authorizationEntry.getContext();
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the provided resource on current scope
|
||||
* @param resource to be published
|
||||
* @throws RegistryNotFoundException if the Registry is not found so the
|
||||
* resource has not be published
|
||||
*/
|
||||
public static void publishResource(Resource resource) throws Exception {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
Resources.marshal(resource, stringWriter);
|
||||
|
||||
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
|
||||
|
||||
try {
|
||||
logger.debug("Trying to publish to {}:\n{}", getScopeFromToken(), stringWriter);
|
||||
registryPublisher.create(resource);
|
||||
} catch (Exception e) {
|
||||
logger.error("The resource was not published", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the resource from IS from curretn scope
|
||||
* @param resource to be unpublished
|
||||
* @throws RegistryNotFoundException if the Registry is not found so the
|
||||
* resource has not be published
|
||||
*/
|
||||
public static void unPublishResource(Resource resource) throws Exception {
|
||||
//StringWriter stringWriter = new StringWriter();
|
||||
//Resources.marshal(resource, stringWriter);
|
||||
|
||||
RegistryPublisher registryPublisher = RegistryPublisherFactory.create();
|
||||
|
||||
String id = resource.id();
|
||||
logger.debug("Trying to remove {} with ID {} from {}", resource.getClass().getSimpleName(), id, getScopeFromToken());
|
||||
|
||||
registryPublisher.remove(resource);
|
||||
|
||||
logger.debug("{} with ID {} removed successfully", resource.getClass().getSimpleName(), id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue