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
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/junit-4.12.jar"/>
<classpathentry kind="lib" path="lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="lib/las2peer-bundle-0.7-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="lib/las2peer-bundle-0.7.1.jar"/>
<classpathentry kind="lib" path="lib/jersey-media-json-jackson-2.25.1.jar"/>
<classpathentry kind="output" path="output"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ ivy.jar
!/etc/ivy/ivysettings.xml
*.secret
archiva_credentials.xml
join-example-space.html
/frontend/
9 changes: 9 additions & 0 deletions agent-developer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<las2peer:agent type="user">
<id>f3ef36da93ea0875f840797d34cab1b2063df63107bb206238b46e92420f446453c6bb980b234a60986b3facd663cd6e416bcc49c60adca187922926c2bdf047</id>
<publickey encoding="base64">rO0ABXNyABRqYXZhLnNlY3VyaXR5LktleVJlcL35T7OImqVDAgAETAAJYWxnb3JpdGhtdAASTGphdmEvbGFuZy9TdHJpbmc7WwAHZW5jb2RlZHQAAltCTAAGZm9ybWF0cQB+AAFMAAR0eXBldAAbTGphdmEvc2VjdXJpdHkvS2V5UmVwJFR5cGU7eHB0AANSU0F1cgACW0Ks8xf4BghU4AIAAHhwAAABJjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAIAPE7NS9qdSf9RgZnPd2jCKemrXYNozq1VeQBOdzOOJucRKtnAOKrj+/h7IzYolZvcsra9D/NDewJu4T/luPMPSjnREBp0t/J5arUKyqcg5xbpR7bHEj+PccvlMxXncEuSBGl9eis7+5//eEH66MTDNj3wtdIqFMvSLHYDGZpfKLZ3P40AfRnAJjO8guGZDmBVa5PohdCToWm/isH+/lmqZb0/t2hmVBgG4AR4dN0FeslRfprVfK4b76HFOzxTq8rC41cB35JKVd23R8GL2fpdZBgWdvOFg/5rMxXu8RBHmSibyLf/0XIdEj8nYxHMqqJXDTmQFbmShhHUy7pO5OtkCAwEAAXQABVguNTA5fnIAGWphdmEuc2VjdXJpdHkuS2V5UmVwJFR5cGUAAAAAAAAAABIAAHhyAA5qYXZhLmxhbmcuRW51bQAAAAAAAAAAEgAAeHB0AAZQVUJMSUM=</publickey>
<privatekey encrypted="AES" keygen="PBKDF2WithHmacSHA1">
<salt encoding="base64">OuTHTH6uApSIdPvLyTGsMQ==</salt>
<data encoding="base64">woXeiqUeFhrXyYvFYd+QMlK1rnI5mHIVmRFgshbQO4Sic6byDe/JF2LXpnRnP10G9tJAdQ7/yKzS7siostU08wGOCluACSJQC4Nt9zBDH9+fA8MTDyiaTVXjh78oW3wA0t9KLiY6iuYK9dZt2yMSdSa2eUO7ZtjolP10It9vemtInNTRXDxo1LmBHPoFm7eN0hHgasUflPQs9XfJ0JERGv/5+CfxuXiP3wg9SV7SnfkJUJCfxS8fmLadjGwthuexuNzUJqj/VYdBw2d3XKPQ53cFiC9j7miQOs+u8mlvX87FGO8tFlPwYzY+kfA1qOrdkszddzaCA4AQtD1jL5QzGixVR5C1EQ4I7k5LujHfYmSG2cja5p/Zm49ouTVmwe2mQI8mSoM91d/+RmQP1lYs5lND+dLegOiEfr71rssNHfoXHbqxlt6KT0E7l8ghUSgO6FrltH5J/DiETnSnpkfZ2I94lbEc6XMFojbyzqe7HucR9n926bOUcxwErFro+7NJLMtLMaBSdL5ECaPZjJAeAGq/odbW9hPoS2R9c44O1nXi+BaCJUvQBDetvXp4WS7uhxq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xJ4JlaXIBw76/kMZLOH98npyTDmI6Dx+igRnbXXgd41BuW7RHgbRLIpC6gBuCnOUYuIqz6PAY7JpR1F7W5e3c3NIIUmm83mUmBaHBx9K/0DGau6oCj2zFOi94oAXkNjI9vUkiHIJVIkMxFfOmERtKHjqwGp17t50wXdgdAmMpekadj1yWX20zTHUf9US1r8yge12Dd3RDL9bjgUSY/BySMrnlgTCLKkJ4S6QZixYWUPryCUy8exHUxPIMbKIqZHKvRStUoFgn52B8y8+Pq3K1NCjlRj+pv+Xdo5E000a3stHGc7k8Svp4jdtrVFsSGRNDkUkKGIjW96CgwZZE7dprRoi</data>
</privatekey>
<login>developer</login>
</las2peer:agent>
3 changes: 2 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<project name="Distributed-Noracle-Service" default="jar" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">

<property name="core.version" value="0.7-SNAPSHOT" />
<property name="core.version" value="0.7.1" />

<property name="service.name" value="i5.las2peer.services.noracleService" />
<property name="service.class" value="NoracleService" />
Expand Down Expand Up @@ -63,6 +63,7 @@
<credentials host="role.dbis.rwth-aachen.de:9911/archiva" realm="Repository internal" />
</ivy:settings>
<ivy:retrieve type="jar, bundle" conf="*" pattern="${lib}/[artifact]-[revision].[ext]" />
<get src="https://github.com/rwth-acis/las2peer-FileService/releases/download/2.2.0/i5.las2peer.services.fileService-2.2.0.jar" dest="service/"/>
</target>


Expand Down
4 changes: 4 additions & 0 deletions launcher-configuration.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ service

[commands]
uploadStartupDirectory('example')
uploadServicePackage('service/i5.las2peer.services.fileService-2.2.0.jar', 'agent-developer.xml', 'topsecret')
startService('i5.las2peer.services.fileService.FileService@2.2.0','testtest')
uploadServicePackage('service/i5.las2peer.services.noracleService-0.5.0.jar', 'agent-developer.xml', 'topsecret')
startService('i5.las2peer.services.noracleService.NoracleSpaceService@0.5.0','testtest')
startService('i5.las2peer.services.noracleService.NoracleQuestionService@0.5.0','testtest')
startService('i5.las2peer.services.noracleService.NoracleQuestionRelationService@0.5.0','testtest')
startService('i5.las2peer.services.noracleService.NoracleAgentService@0.5.0','testtest')
startService('i5.las2peer.services.noracleService.NoracleVoteService@0.5.0','testtest')
startService('i5.las2peer.services.noracleService.NoracleService@0.5.0','testtest')
startWebConnector
interactive
Expand Down
47 changes: 39 additions & 8 deletions noracle-generate-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ space_creator_agent_login="noracle-example-smith"
agent_pw="testtest"

num_spaces=5
num_questions_per_space=50
num_relations_per_space=25
num_questions_per_space=25
num_relations_per_space=15

relation_types=()
relation_types+=("\"name\": \"Similarity\", \"directed\": \"false\"")
Expand All @@ -27,18 +27,24 @@ random_lengthLorem() {

# create example spaces

for num in {1..${num_spaces}}; do
curl -s -D - --user noracle-example-smith:${agent_pw} -X POST --header 'Content-Type: application/json' -d '{ "name": "example-space-'"${num}"'" }' "${endpoint}"'/spaces' --insecure
for (( num=1; num<=${num_spaces}; num++ )); do
curl -s -D - --user noracle-example-smith:${agent_pw} -X POST --header 'Content-Type: application/json' -d '{ "name": "example-space-'"${num}"'" }' "${endpoint}"'/spaces' --insecure &
done
# wait till all requests terminated
wait


# get all subscribed spaces for agent smith
example_space_ids=()
out="$( { curl -s --user noracle-example-smith:${agent_pw} -X GET --header 'Accept: application/json' "${endpoint}"'/agents/'"${space_creator_agent_id}"'/spacesubscriptions' --insecure ; } 2>&1 )"
while read spaceId ; do
example_space_ids+=("${spaceId}")
done < <(echo "${out}" | jq -r '.[].spaceId')

out="$( { curl -s --user noracle-example-smith:${agent_pw} -X GET --header 'Accept: application/json' "${endpoint}"'/agents/'"${space_creator_agent_id}"'/spacesubscriptions' --insecure ; } )"
echo "${out}" | jq -r '.[].spaceId' | while read spaceId ; do
for spaceId in "${example_space_ids[@]}" ; do
# create questions inside space
question_ids=()
for num in {1..${num_questions_per_space}}; do
for (( num=1; num<=${num_questions_per_space}; num++ )); do
random=$(random_lengthLorem)
out="$( { curl -s -D - --user noracle-example-smith:"${agent_pw}" -X POST --header 'Content-Type: application/json' -d '{ "text": "'"${random}"'" }' "${endpoint}"'/spaces/'"${spaceId}"'/questions' --insecure ; } 2>&1 )"
echo "${out}"
Expand All @@ -54,7 +60,7 @@ echo "${out}" | jq -r '.[].spaceId' | while read spaceId ; do
question_ids+=(${question_id})
done
# create random relations between questions
for num in {1..${num_relations_per_space}}; do
for (( num=1; num<=${num_relations_per_space}; num++ )); do
relation_type=${relation_types[$RANDOM % ${#relation_types[@]} ]}
first_question_id=${question_ids[$RANDOM % ${#question_ids[@]} ]}
second_question_id=${question_ids[$RANDOM % ${#question_ids[@]} ]}
Expand All @@ -63,3 +69,28 @@ echo "${out}" | jq -r '.[].spaceId' | while read spaceId ; do
done
done

# generate join links
space_join_links=""
for spaceId in "${example_space_ids[@]}" ; do
out="$( { curl -s -D - --user noracle-example-smith:${agent_pw} -X GET --header 'Accept: application/json' "${endpoint}"'/spaces/'"${spaceId}" --insecure ; } 2>&1 )"
while read spaceSecret ; do
space_join_links="${space_join_links}<div><a href=\"http://dbis.rwth-aachen.de/noracle/spaces/${spaceId}?pw=${spaceSecret}\">Click here to join example space ${spaceId}</a></div>"
done < <(echo "${out}" | jq -r '.spaceSecret')
done

# write invitation links to file
read -d '' join_space_file_content <<- EOF
<html>
<head>
<title>Join A Noracle Example Space</title>
</head>
<body>
<p>Please click on a link below to join the appropriate Noracle example space</p>
${space_join_links}
</body>
</html>

EOF

echo "${join_space_file_content}" > "join-example-space.html"

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
/**
* Noracle Agents Service
*
* This service is used to handle agents metadata in a distributed Noracle system.
* This service is used to handle agents metadata in a distributed Noracle
* system.
*
*/
public class NoracleAgentService extends Service implements INoracleAgentService {
Expand Down Expand Up @@ -124,10 +125,6 @@ public SpaceSubscriptionList getSpaceSubscriptions(String agentId) throws Servic
}
}

private String buildSubscriptionId(String agentId) {
return "spacesubscriptions-" + agentId;
}

@Override
public SpaceSubscription updateSpaceSubscription(String agentId, String spaceId, String[] selectedQuestions)
throws ServiceInvocationException {
Expand Down Expand Up @@ -162,8 +159,58 @@ public SpaceSubscription updateSpaceSubscription(String agentId, String spaceId,

@Override
public NoracleAgentProfile updateAgentProfile(String agentName) throws ServiceInvocationException {
// TODO Implement (create or update should both be done here)
return null;
Agent mainAgent = Context.get().getMainAgent();
String envIdentifier = buildAgentProfileId(mainAgent.getIdentifier());
Envelope env;
NoracleAgentProfile profile;
// look for existing profile, otherwise create one
try {
try {
env = Context.get().requestEnvelope(envIdentifier);
profile = (NoracleAgentProfile) env.getContent();
} catch (EnvelopeNotFoundException e) {
env = Context.get().createEnvelope(envIdentifier);
profile = new NoracleAgentProfile();
}
} catch (EnvelopeAccessDeniedException e) {
throw new ServiceAccessDeniedException("Envelope access denied");
} catch (EnvelopeOperationFailedException e) {
throw new InternalServiceException("Could not create new envelope for noracle agent profile", e);
}
profile.setName(agentName);
env.setContent(profile);
env.setPublic();
try {
Context.get().storeEnvelope(env, mainAgent);
} catch (EnvelopeAccessDeniedException e) {
throw new ServiceAccessDeniedException("Envelope access denied");
} catch (EnvelopeOperationFailedException e) {
throw new InternalServiceException("Storing envelope with noracle agent profile failed", e);
}
return profile;
}

@Override
public NoracleAgentProfile getAgentProfile(String agentId) throws ServiceInvocationException {
String envIdentifier = buildAgentProfileId(agentId);
try {
Envelope env = Context.get().requestEnvelope(envIdentifier);
return (NoracleAgentProfile) env.getContent();
} catch (EnvelopeAccessDeniedException e) {
throw new ServiceAccessDeniedException("Envelope access denied");
} catch (EnvelopeOperationFailedException e) {
throw new InternalServiceException("Could not fetch agent profile", e);
} catch (EnvelopeNotFoundException e) {
return new NoracleAgentProfile();
}
}

private String buildSubscriptionId(String agentId) {
return "spacesubscriptions-" + agentId;
}

private String buildAgentProfileId(String agentId) {
return "noracleagentprofile-" + agentId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@
import io.swagger.annotations.SwaggerDefinition;

@Api
@SwaggerDefinition(
info = @Info(
title = "Noracle Service",
version = NoracleService.API_VERSION,
description = "A bundle service for the distributed Noracle system",
license = @License(
name = "BSD-3",
url = "https://github.com/rwth-acis/Noracle-Bundle-Service/blob/master/LICENSE")))
@SwaggerDefinition(info = @Info(title = "Noracle Service", version = NoracleService.API_VERSION, description = "A bundle service for the distributed Noracle system", license = @License(name = "BSD-3", url = "https://github.com/Distributed-Noracle/Distributed-Noracle-Backend/blob/master/LICENSE.txt")))
@ServicePath("/" + NoracleService.RESOURCE_NAME)
public class NoracleService extends RESTService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NoracleVoteService extends Service implements INoracleVoteService {
private static final int MAX_VOTES_PER_OBJECT = 1000000;

@Override
public void setVote(String agentId, String objectId, int vote) throws ServiceInvocationException {
public Vote setVote(String agentId, String objectId, int vote) throws ServiceInvocationException {
Agent mainAgent = Context.get().getMainAgent();
if (objectId == null || objectId.isEmpty()) {
throw new InvocationBadArgumentException("No object id given");
Expand All @@ -41,6 +41,7 @@ public void setVote(String agentId, String objectId, int vote) throws ServiceInv
voteEntry.setVote(pubVote);
persEnv.setContent(voteEntry);
Context.get().storeEnvelope(persEnv);
return pubVote;
} catch (EnvelopeNotFoundException e) {
Envelope persEnv = Context.get().createEnvelope(persEnvId);
String pubEnvId = null;
Expand All @@ -66,6 +67,7 @@ public void setVote(String agentId, String objectId, int vote) throws ServiceInv
VoteEntry voteEntry = new VoteEntry(objectId, pubIndex, pubVote);
persEnv.setContent(voteEntry);
Context.get().storeEnvelope(persEnv);
return pubVote;
}
} catch (EnvelopeAccessDeniedException e) {
throw new ServiceAccessDeniedException("Envelope Access Denied");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public interface INoracleAgentService {

public NoracleAgentProfile updateAgentProfile(String agentName) throws ServiceInvocationException;

public NoracleAgentProfile getAgentProfile(String agentId) throws ServiceInvocationException;

public SpaceSubscription subscribeToSpace(String spaceId, String spaceSecret) throws ServiceInvocationException;

public void unsubscribeFromSpace(String spaceId) throws ServiceInvocationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface INoracleVoteService {

public void setVote(String agentId, String objectId, int value) throws ServiceInvocationException;
public Vote setVote(String agentId, String objectId, int value) throws ServiceInvocationException;

public Vote getAgentVote(String objectId, String agentId) throws ServiceInvocationException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package i5.las2peer.services.noracleService.model;

public class NoracleAgentProfile {
import java.io.Serializable;

public class NoracleAgentProfile implements Serializable {

private static final long serialVersionUID = 1L;
private String name;

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package i5.las2peer.services.noracleService.pojo;

public class CreateProfilePojo {
public class ChangeProfilePojo {
private String agentName;

public String getAgentName() {
Expand Down
Loading