Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ Additionally, you have to supply the following system properties (via -D) for ru

If your Keycloak URL is different from http://localhost:8080/auth then you need to change configurationserver/resources/keycloak/development/keycloak-adapter.json accordingly.

The realm provides the following users which you can use to login to the configuration server:

1. dev-admin / dev-admin
2. dev-user / dev-user

### MongoDB
```
docker run --name some-mongo -d mongo --auth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import com.mongodb.DBObject;
import com.mongodb.util.JSON;
import io.sls.persistence.IResourceStore;
import io.sls.serialization.JSONSerialization;
import io.sls.serialization.IJsonSerialization;
import io.sls.testing.model.TestCase;
import io.sls.testing.model.TestCaseState;
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
import org.codehaus.jackson.type.TypeReference;

import javax.inject.Inject;
import java.io.IOException;
Expand All @@ -19,22 +19,25 @@
/**
* @author ginccc
*/
@Slf4j
public class TestCaseStore implements ITestCaseStore, IResourceStore<TestCase> {
private static final String TESTCASE_COLLECTION = "testcases";
public static final String TESTCASE_STATE_FIELD = "testCaseState";
private static final String TESTCASE_STATE_FIELD = "testCaseState";
private final DBCollection testcaseCollection;
private IJsonSerialization jsonSerialization;

@Inject
public TestCaseStore(DB database) {
public TestCaseStore(DB database, IJsonSerialization jsonSerialization) {
testcaseCollection = database.getCollection(TESTCASE_COLLECTION);
this.jsonSerialization = jsonSerialization;
}

@Override
public String storeTestCase(String id, TestCase testCase) throws IResourceStore.ResourceStoreException {
try {
testCase.setLastRun(new Date(System.currentTimeMillis()));

String json = JSONSerialization.serialize(testCase);
String json = jsonSerialization.serialize(testCase);
DBObject document = (DBObject) JSON.parse(json);

if (id != null) {
Expand All @@ -45,6 +48,7 @@ public String storeTestCase(String id, TestCase testCase) throws IResourceStore.

return document.get("_id").toString();
} catch (IOException e) {
log.debug(e.getLocalizedMessage(), e);
throw new IResourceStore.ResourceStoreException(e.getLocalizedMessage(), e);
}
}
Expand All @@ -62,11 +66,9 @@ public TestCase loadTestCase(String id) throws IResourceStore.ResourceNotFoundEx

document.removeField("_id");

TestCase testCase = JSONSerialization.deserialize(document.toString(), new TypeReference<TestCase>() {
});

return testCase;
return jsonSerialization.deserialize(document.toString(), TestCase.class);
} catch (IOException e) {
log.debug(e.getLocalizedMessage(), e);
throw new IResourceStore.ResourceStoreException(e.getLocalizedMessage(), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import io.sls.group.IGroupStore;
import io.sls.permission.IPermissionStore;
import io.sls.persistence.impl.DescriptorStore;
import io.sls.serialization.JSONSerialization;
import io.sls.serialization.IDocumentBuilder;
import io.sls.testing.descriptor.ITestCaseDescriptorStore;
import io.sls.testing.descriptor.model.TestCaseDescriptor;
import io.sls.user.IUserStore;
import org.codehaus.jackson.type.TypeReference;

import javax.inject.Inject;

Expand All @@ -17,7 +16,8 @@
*/
public class TestCaseDescriptorStore extends DescriptorStore<TestCaseDescriptor> implements ITestCaseDescriptorStore {
@Inject
public TestCaseDescriptorStore(DB database, IPermissionStore permissionStore, IUserStore userStore, IGroupStore groupStore) {
super(database, permissionStore, userStore, groupStore, doc -> JSONSerialization.deserialize(doc, new TypeReference<TestCaseDescriptor>() {}));
public TestCaseDescriptorStore(DB database, IDocumentBuilder documentBuilder,
IPermissionStore permissionStore, IUserStore userStore, IGroupStore groupStore) {
super(database, permissionStore, userStore, groupStore, documentBuilder, TestCaseDescriptor.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public RestTestCaseStore(@Context HttpResponse httpResponse,
@Override
public List<TestCaseDescriptor> readTestCaseDescriptors(String botId, Integer botVersion, Integer index, Integer limit) {
try {
List<TestCaseDescriptor> retConversationDescriptors = new LinkedList<TestCaseDescriptor>();
List<TestCaseDescriptor> retConversationDescriptors = new LinkedList<>();
List<TestCaseDescriptor> testCaseDescriptors;
do {
testCaseDescriptors = testCaseDescriptorStore.readDescriptors("io.sls.testcases", null, index, limit, false);
Expand Down Expand Up @@ -88,6 +88,7 @@ public List<TestCaseDescriptor> readTestCaseDescriptors(String botId, Integer bo
log.error(e.getMessage(), e);
throw new InternalServerErrorException(e.getMessage(), e);
} catch (IResourceStore.ResourceNotFoundException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NoLogWebApplicationException(e);
}
}
Expand Down Expand Up @@ -116,6 +117,7 @@ public void patchDescriptor(String id, Integer version, PatchInstruction<SimpleT
log.error(e.getLocalizedMessage(), e);
throw new InternalServerErrorException(e.getLocalizedMessage(), e);
} catch (IResourceStore.ResourceNotFoundException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NotFoundException(e.getLocalizedMessage(), e);
}
}
Expand Down Expand Up @@ -151,6 +153,7 @@ public URI createTestCase(String conversationId) {
log.error(e.getLocalizedMessage(), e);
throw new InternalServerErrorException(e);
} catch (IResourceStore.ResourceNotFoundException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NoLogWebApplicationException(Response.Status.NOT_FOUND);
}
}
Expand All @@ -164,8 +167,10 @@ public URI updateTestCase(String id, TestCase testCase) {
log.error(e.getLocalizedMessage(), e);
throw new InternalServerErrorException(e);
} catch (IResourceStore.ResourceNotFoundException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NoLogWebApplicationException(Response.Status.NOT_FOUND);
} catch (IResourceStore.ResourceModifiedException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NoLogWebApplicationException(Response.Status.CONFLICT);
}
}
Expand All @@ -178,8 +183,10 @@ public void deleteTestCase(String id) {
log.error(e.getLocalizedMessage(), e);
throw new InternalServerErrorException(e);
} catch (IResourceStore.ResourceModifiedException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NoLogWebApplicationException(Response.Status.CONFLICT);
} catch (IResourceStore.ResourceNotFoundException e) {
log.debug(e.getLocalizedMessage(), e);
throw new NoLogWebApplicationException(Response.Status.NOT_FOUND);
}
}
Expand Down
20 changes: 19 additions & 1 deletion configurationrepository-definition/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,25 @@
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.0.18.Final</version>
</dependency>
<dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> <version>3.0.18.Final</version> <exclusions> <exclusion> <artifactId>slf4j-simple</artifactId> <groupId>org.slf4j</groupId> </exclusion> <exclusion> <artifactId>jboss-annotations-api_1.1_spec</artifactId> <groupId>org.jboss.spec.javax.annotation</groupId> </exclusion> <exclusion> <artifactId>jcip-annotations</artifactId> <groupId>net.jcip</groupId> </exclusion> </exclusions> </dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.18.Final</version>
<exclusions>
<exclusion>
<artifactId>slf4j-simple</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>jboss-annotations-api_1.1_spec</artifactId>
<groupId>org.jboss.spec.javax.annotation</groupId>
</exclusion>
<exclusion>
<artifactId>jcip-annotations</artifactId>
<groupId>net.jcip</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ai.labs</groupId>
<artifactId>persistencestore-definition</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
* @author ginccc
*/
public interface IRestVersionInfo {
String versionQueryParam = "?version=";

@GET
@Path("/{id}/currentversion")
@Produces(MediaType.TEXT_PLAIN)
Integer getCurrentVersion(@PathParam("id") String id);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package io.sls.resources.rest.behavior.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.LinkedList;
import java.util.List;

/**
* @author ginccc
*/
@JsonIgnoreProperties({"id", "children", "selected", "opened", "editable"})
public class BehaviorGroupConfiguration {
private String name;
private List<BehaviorRuleConfiguration> behaviorRules;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package io.sls.resources.rest.behavior.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
* @author ginccc
*/
@JsonIgnoreProperties({"default", "id", "producesOutput", "selected", "sequenceNumber", "opened"})
public class BehaviorRuleConfiguration {
private String name;
private List<String> actions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.sls.resources.rest.behavior.model;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.HashMap;
Expand All @@ -12,7 +11,6 @@
/**
* @author ginccc
*/
@JsonIgnoreProperties({"id", "behaviorRules", "editable", "opened", "name", "selected"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BehaviorRuleElementConfiguration {
private String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
@Path("/packagestore/packages")
public interface IRestPackageStore extends IRestVersionInfo {
String resourceURI = "resource://io.sls.package/packagestore/packages/";
String versionQueryParam = "?version=";

@GET
@GZIP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@Path("/regulardictionarystore/regulardictionaries")
public interface IRestRegularDictionaryStore extends IRestVersionInfo {
String resourceURI = "resource://io.sls.regulardictionary/regulardictionarystore/regulardictionaries/";
String versionQueryParam = "?version=";

@GET
@GZIP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.sls.resources.rest.regulardictionary.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -34,7 +32,6 @@ public List<PhraseConfiguration> getPhrases() {
return phrases;
}

@JsonIgnoreProperties({"auto_generate_expression", "auto_to_lower"})
public static class WordConfiguration {
private String word;
private String exp;
Expand Down Expand Up @@ -80,7 +77,6 @@ public int hashCode() {
}
}

@JsonIgnoreProperties({"auto_generate_expression", "auto_to_lower"})
public static class PhraseConfiguration {
protected String phrase;
protected String exp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.sls.persistence.impl.bots.mongo.BotStore;
import io.sls.persistence.impl.bots.rest.RestBotStore;
import io.sls.persistence.impl.descriptor.mongo.DocumentDescriptorStore;
import io.sls.persistence.impl.documentdescriptor.rest.RestDocumentDescriptorStore;
import io.sls.persistence.impl.descriptor.rest.RestDocumentDescriptorStore;
import io.sls.persistence.impl.extensions.mongo.ExtensionStore;
import io.sls.persistence.impl.extensions.rest.RestExtensionStore;
import io.sls.persistence.impl.monitor.rest.RestMonitorStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
import io.sls.resources.rest.behavior.model.BehaviorGroupConfiguration;
import io.sls.resources.rest.behavior.model.BehaviorRuleConfiguration;
import io.sls.serialization.IDocumentBuilder;
import io.sls.serialization.JSONSerialization;
import io.sls.utilities.RuntimeUtilities;
import org.codehaus.jackson.type.TypeReference;

import javax.inject.Inject;
import java.io.IOException;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -27,17 +24,13 @@ public class BehaviorStore implements IBehaviorStore {
private final String collectionName = "behaviorrulesets";

@Inject
public BehaviorStore(DB database) {
public BehaviorStore(DB database, IDocumentBuilder documentBuilder) {
RuntimeUtilities.checkNotNull(database, "database");

MongoResourceStorage<BehaviorConfiguration> resourceStorage = new MongoResourceStorage<BehaviorConfiguration>(database, collectionName, new IDocumentBuilder<BehaviorConfiguration>() {
@Override
public BehaviorConfiguration build(String doc) throws IOException {
return JSONSerialization.deserialize(doc, new TypeReference<BehaviorConfiguration>() {});
}
});
MongoResourceStorage<BehaviorConfiguration> resourceStorage =
new MongoResourceStorage<>(database, collectionName, documentBuilder, BehaviorConfiguration.class);

this.behaviorResourceStore = new HistorizedResourceStore<BehaviorConfiguration>(resourceStorage);
this.behaviorResourceStore = new HistorizedResourceStore<>(resourceStorage);
}

@Override
Expand Down Expand Up @@ -75,7 +68,7 @@ public IResourceId getCurrentResourceId(String id) throws ResourceNotFoundExcept

@Override
public List<String> readBehaviorRuleNames(String id, Integer version, String filter, String order, Integer limit) throws ResourceStoreException, ResourceNotFoundException {
List<String> retBehaviorRuleNames = new LinkedList<String>();
List<String> retBehaviorRuleNames = new LinkedList<>();
BehaviorConfiguration behaviorConfiguration = read(id, version);
for (BehaviorGroupConfiguration groupConfiguration : behaviorConfiguration.getBehaviorGroups()) {
List<BehaviorRuleConfiguration> behaviorRules = groupConfiguration.getBehaviorRules();
Expand Down
Loading