Skip to content

Commit 25f813f

Browse files
committed
Merge branch 'develop'
Conflicts: src/main/i5/las2peer/services/noracleService/NoracleSpaceService.java
2 parents 3a5ac3a + 20f34bd commit 25f813f

File tree

11 files changed

+72
-28
lines changed

11 files changed

+72
-28
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<property name="service.name" value="i5.las2peer.services.noracleService" />
66
<property name="service.class" value="NoracleService" />
7-
<property name="service.version" value="0.5.0" />
7+
<property name="service.version" value="0.6.0" />
88

99
<property name="src.main" location="src/main" />
1010
<property name="src.junit" location="src/test" />

launcher-configuration.ini

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ service
1111
uploadStartupDirectory('example')
1212
uploadServicePackage('service/i5.las2peer.services.fileService-2.2.5.jar', 'agent-developer.xml', 'topsecret')
1313
startService('i5.las2peer.services.fileService.FileService@2.2.5','testtest')
14-
uploadServicePackage('service/i5.las2peer.services.noracleService-0.5.0.jar', 'agent-developer.xml', 'topsecret')
15-
startService('i5.las2peer.services.noracleService.NoracleSpaceService@0.5.0','testtest')
16-
startService('i5.las2peer.services.noracleService.NoracleQuestionService@0.5.0','testtest')
17-
startService('i5.las2peer.services.noracleService.NoracleQuestionRelationService@0.5.0','testtest')
18-
startService('i5.las2peer.services.noracleService.NoracleAgentService@0.5.0','testtest')
19-
startService('i5.las2peer.services.noracleService.NoracleVoteService@0.5.0','testtest')
20-
startService('i5.las2peer.services.noracleService.NoracleService@0.5.0','testtest')
14+
uploadServicePackage('service/i5.las2peer.services.noracleService-0.6.0.jar', 'agent-developer.xml', 'topsecret')
15+
startService('i5.las2peer.services.noracleService.NoracleSpaceService@0.6.0','testtest')
16+
startService('i5.las2peer.services.noracleService.NoracleQuestionService@0.6.0','testtest')
17+
startService('i5.las2peer.services.noracleService.NoracleQuestionRelationService@0.6.0','testtest')
18+
startService('i5.las2peer.services.noracleService.NoracleAgentService@0.6.0','testtest')
19+
startService('i5.las2peer.services.noracleService.NoracleVoteService@0.6.0','testtest')
20+
startService('i5.las2peer.services.noracleService.NoracleService@0.6.0','testtest')
2121
startWebConnector
2222
interactive

noracle-generate-examples.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
endpoint="https://steen.informatik.rwth-aachen.de:9082/distributed-noracle/v0.5.0"
3+
endpoint="https://steen.informatik.rwth-aachen.de:9082/distributed-noracle/v0.6.0"
44

55
space_creator_agent_id="762a164ba8eb06d3d110eeeb0321cb75f2624ab311f9c0c4d0e91bdc854a02f389b91573d6c29d70d3071a8a1738cd20fac87d638777dbfcef4ded8be71e2656"
66
space_creator_agent_login="noracle-example-smith"

src/main/i5/las2peer/services/noracleService/NoracleService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class NoracleService extends RESTService {
2020

2121
public static final String RESOURCE_NAME = "distributed-noracle";
22-
public static final String API_VERSION = "0.5";
22+
public static final String API_VERSION = "0.6";
2323

2424
@Override
2525
protected void initResources() {

src/main/i5/las2peer/services/noracleService/NoracleSpaceService.java

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@
1919
import i5.las2peer.api.security.AgentAccessDeniedException;
2020
import i5.las2peer.api.security.AgentAlreadyExistsException;
2121
import i5.las2peer.api.security.AgentLockedException;
22+
import i5.las2peer.api.security.AgentNotFoundException;
2223
import i5.las2peer.api.security.AgentOperationFailedException;
2324
import i5.las2peer.api.security.AnonymousAgent;
2425
import i5.las2peer.api.security.GroupAgent;
2526
import i5.las2peer.security.GroupAgentImpl;
2627
import i5.las2peer.security.UserAgentImpl;
2728
import i5.las2peer.serialization.SerializationException;
2829
import i5.las2peer.services.noracleService.api.INoracleSpaceService;
30+
import i5.las2peer.services.noracleService.model.NoracleAgentProfile;
2931
import i5.las2peer.services.noracleService.model.Space;
3032
import i5.las2peer.services.noracleService.model.SpaceInviteAgent;
33+
import i5.las2peer.services.noracleService.model.SpaceSubscribersList;
3134
import i5.las2peer.tools.CryptoException;
3235

3336
/**
@@ -126,6 +129,31 @@ public Space getSpace(String spaceId) throws ServiceInvocationException {
126129
Space space = (Space) env.getContent();
127130
return space;
128131
}
132+
133+
@Override
134+
public SpaceSubscribersList getSubscribers(String spaceId) throws ServiceInvocationException {
135+
if (spaceId == null || spaceId.isEmpty()) {
136+
throw new InvocationBadArgumentException("No space id given");
137+
}
138+
try {
139+
UserAgentImpl inviteAgent = this.getInviteAgent(spaceId);
140+
GroupAgent memberAgent = this.getMemberAgent(spaceId);
141+
memberAgent.unlock(Context.get().getMainAgent());
142+
String[] memberIds = memberAgent.getMemberList();
143+
SpaceSubscribersList subscribers = new SpaceSubscribersList();
144+
for (int i = 0; i < memberIds.length; i++) {
145+
if (!memberIds[i].equals(inviteAgent.getIdentifier())) {
146+
UserAgentImpl agent = (UserAgentImpl) Context.get().fetchAgent(memberIds[i]);
147+
NoracleAgentProfile profile = new NoracleAgentProfile();
148+
profile.setName(agent.getLoginName());
149+
subscribers.add(profile);
150+
}
151+
}
152+
return subscribers;
153+
} catch (Exception e) {
154+
throw new ServiceInvocationException("Could not fetch list", e);
155+
}
156+
}
129157

130158
public void joinSpace(String spaceId, String spaceSecret) throws ServiceInvocationException {
131159
if (spaceId == null || spaceId.isEmpty()) {
@@ -134,15 +162,9 @@ public void joinSpace(String spaceId, String spaceSecret) throws ServiceInvocati
134162
throw new ServiceAccessDeniedException("No space secret given");
135163
}
136164
try {
137-
String inviteAgentEnvelopeId = getInviteMappingIdentifier(spaceId);
138-
Envelope inviteAgentMapping = Context.get().requestEnvelope(inviteAgentEnvelopeId);
139-
String inviteAgentId = (String) inviteAgentMapping.getContent();
140-
UserAgentImpl inviteAgent = (UserAgentImpl) Context.get().fetchAgent(inviteAgentId);
165+
UserAgentImpl inviteAgent = this.getInviteAgent(spaceId);
141166
inviteAgent.unlock(spaceSecret);
142-
String memberAgentEnvelopeId = getMemberMappingIdentifier(spaceId);
143-
Envelope memberAgentMapping = Context.get().requestEnvelope(memberAgentEnvelopeId);
144-
String memberAgentId = (String) memberAgentMapping.getContent();
145-
GroupAgent memberAgent = (GroupAgent) Context.get().fetchAgent(memberAgentId);
167+
GroupAgent memberAgent = this.getMemberAgent(spaceId);
146168
memberAgent.unlock(inviteAgent);
147169
memberAgent.addMember(Context.get().getMainAgent());
148170
Context.get().storeAgent(memberAgent);
@@ -152,6 +174,22 @@ public void joinSpace(String spaceId, String spaceSecret) throws ServiceInvocati
152174
throw new ServiceInvocationException("Could not join space", e);
153175
}
154176
}
177+
178+
private UserAgentImpl getInviteAgent(String spaceId) throws AgentNotFoundException, AgentOperationFailedException, EnvelopeAccessDeniedException, EnvelopeNotFoundException, EnvelopeOperationFailedException {
179+
String inviteAgentEnvelopeId = getInviteMappingIdentifier(spaceId);
180+
Envelope inviteAgentMapping = Context.get().requestEnvelope(inviteAgentEnvelopeId);
181+
String inviteAgentId = (String) inviteAgentMapping.getContent();
182+
UserAgentImpl inviteAgent = (UserAgentImpl) Context.get().fetchAgent(inviteAgentId);
183+
return inviteAgent;
184+
}
185+
186+
private GroupAgent getMemberAgent(String spaceId) throws EnvelopeAccessDeniedException, EnvelopeNotFoundException, EnvelopeOperationFailedException, AgentNotFoundException, AgentOperationFailedException {
187+
String memberAgentEnvelopeId = getMemberMappingIdentifier(spaceId);
188+
Envelope memberAgentMapping = Context.get().requestEnvelope(memberAgentEnvelopeId);
189+
String memberAgentId = (String) memberAgentMapping.getContent();
190+
GroupAgent memberAgent = (GroupAgent) Context.get().fetchAgent(memberAgentId);
191+
return memberAgent;
192+
}
155193

156194
private String buildSpaceId() {
157195
String result = "";

src/main/i5/las2peer/services/noracleService/resources/AgentsResource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import i5.las2peer.services.noracleService.pojo.SubscribeSpacePojo;
3434
import i5.las2peer.services.noracleService.pojo.UpdateSelectedQuestionsPojo;
3535
import io.swagger.annotations.Api;
36+
import io.swagger.annotations.ApiParam;
3637
import io.swagger.annotations.ApiResponse;
3738
import io.swagger.annotations.ApiResponses;
3839

@@ -51,7 +52,7 @@ public class AgentsResource implements INoracleAgentService {
5152
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "You can only subscribe yourself to a space", response = ExceptionEntity.class),
5253
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal Server Error", response = ExceptionEntity.class) })
5354
@Path("/" + SUBSCRIPTIONS_RESOURCE_NAME)
54-
public Response subscribeToSpace(@PathParam("agentid") String agentId, SubscribeSpacePojo subscribeSpacePojo)
55+
public Response subscribeToSpace(@PathParam("agentid") String agentId, @ApiParam(required=true) SubscribeSpacePojo subscribeSpacePojo)
5556
throws ServiceInvocationException {
5657
if (!Context.get().getMainAgent().getIdentifier().equals(agentId)) {
5758
throw new ForbiddenException("You can only subscribe yourself to a space");
@@ -88,7 +89,7 @@ public SpaceSubscription subscribeToSpace(String spaceId, String spaceSecret) th
8889
@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "You can only update your own profile", response = ExceptionEntity.class),
8990
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal Server Error", response = ExceptionEntity.class) })
9091
public NoracleAgentProfile updateAgentProfile(@PathParam("agentid") String agentId,
91-
ChangeProfilePojo createProfilePojo) throws ServiceInvocationException {
92+
@ApiParam(required=true) ChangeProfilePojo createProfilePojo) throws ServiceInvocationException {
9293
if (!Context.get().getMainAgent().getIdentifier().equals(agentId)) {
9394
throw new ForbiddenException("Only update your own profile");
9495
}
@@ -195,13 +196,13 @@ public SpaceSubscriptionList getSpaceSubscriptions(@PathParam("agentid") String
195196
@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal Server Error", response = ExceptionEntity.class) })
196197
@Path("/" + SUBSCRIPTIONS_RESOURCE_NAME + "/{spaceId}/selectedQuestions")
197198
public SpaceSubscription updateSelectedQuestions(@PathParam("agentid") String agentId,
198-
@PathParam("spaceId") String spaceId, UpdateSelectedQuestionsPojo updateSelectedQuestionsPojo)
199+
@PathParam("spaceId") String spaceId, @ApiParam(required=true) UpdateSelectedQuestionsPojo updateSelectedQuestionsPojo)
199200
throws ServiceInvocationException {
200201
return updateSpaceSubscription(agentId, spaceId, updateSelectedQuestionsPojo.getSelectedQuestions());
201202
}
202203

203204
@Override
204-
public SpaceSubscription updateSpaceSubscription(String agentId, String spaceId, String[] selectedQuestions)
205+
public SpaceSubscription updateSpaceSubscription(String agentId, String spaceId, @ApiParam(required=true) String[] selectedQuestions)
205206
throws ServiceInvocationException {
206207
Serializable rmiResult = Context.get().invoke(
207208
new ServiceNameVersion(NoracleAgentService.class.getCanonicalName(), NoracleService.API_VERSION),

src/main/i5/las2peer/services/noracleService/resources/QuestionRelationsResource.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import i5.las2peer.services.noracleService.model.QuestionRelationList;
3232
import i5.las2peer.services.noracleService.pojo.ChangeQuestionRelationPojo;
3333
import i5.las2peer.services.noracleService.pojo.CreateRelationPojo;
34+
import io.swagger.annotations.ApiParam;
3435
import io.swagger.annotations.ApiResponse;
3536
import io.swagger.annotations.ApiResponses;
3637

@@ -52,7 +53,7 @@ public class QuestionRelationsResource implements INoracleQuestionRelationServic
5253
code = HttpURLConnection.HTTP_INTERNAL_ERROR,
5354
message = "Internal Server Error",
5455
response = ExceptionEntity.class) })
55-
public Response createQuestionRelation(@PathParam("spaceId") String spaceId, CreateRelationPojo createRelationPojo)
56+
public Response createQuestionRelation(@PathParam("spaceId") String spaceId, @ApiParam(required=true) CreateRelationPojo createRelationPojo)
5657
throws ServiceInvocationException {
5758
QuestionRelation rel = createQuestionRelation(spaceId, createRelationPojo.getName(),
5859
createRelationPojo.getFirstQuestionId(), createRelationPojo.getSecondQuestionId(),
@@ -209,7 +210,7 @@ public QuestionRelationList getQuestionRelations(String spaceId, String order, I
209210
message = "Internal Server Error",
210211
response = ExceptionEntity.class) })
211212
public QuestionRelation changeQuestionRelation(@PathParam("relationId") String relationId,
212-
ChangeQuestionRelationPojo changeQuestionRelationPojo) throws ServiceInvocationException {
213+
@ApiParam(required=true) ChangeQuestionRelationPojo changeQuestionRelationPojo) throws ServiceInvocationException {
213214
return changeQuestionRelation(relationId, changeQuestionRelationPojo.getName(),
214215
changeQuestionRelationPojo.getQuestionId1(), changeQuestionRelationPojo.getQuestionId2(),
215216
changeQuestionRelationPojo.getDirected());

src/main/i5/las2peer/services/noracleService/resources/QuestionVotesResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import i5.las2peer.services.noracleService.model.VoteList;
2525
import i5.las2peer.services.noracleService.pojo.SetVotePojo;
2626
import io.swagger.annotations.Api;
27+
import io.swagger.annotations.ApiParam;
2728
import io.swagger.annotations.ApiResponse;
2829
import io.swagger.annotations.ApiResponses;
2930

@@ -49,7 +50,7 @@ public class QuestionVotesResource implements INoracleVoteService {
4950
message = "Internal Server Error",
5051
response = ExceptionEntity.class) })
5152
public Vote putSetVote(@PathParam("spaceId") String spaceId, @PathParam("questionId") String questionId,
52-
@PathParam("agentId") String agentId, SetVotePojo setVotePojo) throws ServiceInvocationException {
53+
@PathParam("agentId") String agentId, @ApiParam(required=true) SetVotePojo setVotePojo) throws ServiceInvocationException {
5354
String objectId = buildObjectId(spaceId, questionId);
5455
return setVote(agentId, objectId, setVotePojo.getValue());
5556
}

src/main/i5/las2peer/services/noracleService/resources/QuestionsResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import i5.las2peer.services.noracleService.model.QuestionList;
3232
import i5.las2peer.services.noracleService.pojo.ChangeQuestionPojo;
3333
import i5.las2peer.services.noracleService.pojo.CreateQuestionPojo;
34+
import io.swagger.annotations.ApiParam;
3435
import io.swagger.annotations.ApiResponse;
3536
import io.swagger.annotations.ApiResponses;
3637

@@ -56,7 +57,7 @@ public class QuestionsResource implements INoracleQuestionService {
5657
code = HttpURLConnection.HTTP_INTERNAL_ERROR,
5758
message = "Internal Server Error",
5859
response = ExceptionEntity.class) })
59-
public Response createQuestion(@PathParam("spaceId") String questionSpaceId, CreateQuestionPojo createQuestionPojo)
60+
public Response createQuestion(@PathParam("spaceId") String questionSpaceId, @ApiParam(required=true) CreateQuestionPojo createQuestionPojo)
6061
throws ServiceInvocationException {
6162
Question question = createQuestion(questionSpaceId, createQuestionPojo.getText());
6263
try {

src/main/i5/las2peer/services/noracleService/resources/RelationVotesResource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import i5.las2peer.services.noracleService.model.VoteList;
2525
import i5.las2peer.services.noracleService.pojo.SetVotePojo;
2626
import io.swagger.annotations.Api;
27+
import io.swagger.annotations.ApiParam;
2728
import io.swagger.annotations.ApiResponse;
2829
import io.swagger.annotations.ApiResponses;
2930

@@ -49,7 +50,7 @@ public class RelationVotesResource implements INoracleVoteService {
4950
message = "Internal Server Error",
5051
response = ExceptionEntity.class) })
5152
public Vote putSetVote(@PathParam("spaceId") String spaceId, @PathParam("relationId") String relationId,
52-
@PathParam("agentId") String agentId, SetVotePojo setVotePojo) throws ServiceInvocationException {
53+
@PathParam("agentId") String agentId, @ApiParam(required=true) SetVotePojo setVotePojo) throws ServiceInvocationException {
5354
String objectId = buildObjectId(spaceId, relationId);
5455
return setVote(agentId, objectId, setVotePojo.getValue());
5556
}

0 commit comments

Comments
 (0)