use of i5.las2peer.services.noracleService.model.NoracleAgentProfile in project Distributed-Noracle-Backend by Distributed-Noracle.
the class NoracleSpaceService method getSubscribers.
@Override
public SpaceSubscribersList getSubscribers(String spaceId) throws ServiceInvocationException {
if (spaceId == null || spaceId.isEmpty()) {
throw new InvocationBadArgumentException("No space id given");
}
try {
UserAgentImpl inviteAgent = this.getInviteAgent(spaceId);
GroupAgent memberAgent = this.getMemberAgent(spaceId);
memberAgent.unlock(Context.get().getMainAgent());
String[] memberIds = memberAgent.getMemberList();
SpaceSubscribersList subscribers = new SpaceSubscribersList();
for (int i = 0; i < memberIds.length; i++) {
if (!memberIds[i].equals(inviteAgent.getIdentifier())) {
UserAgentImpl agent = (UserAgentImpl) Context.get().fetchAgent(memberIds[i]);
NoracleAgentProfile profile = new NoracleAgentProfile();
profile.setName(agent.getLoginName());
subscribers.add(profile);
}
}
return subscribers;
} catch (Exception e) {
throw new ServiceInvocationException("Could not fetch list", e);
}
}
use of i5.las2peer.services.noracleService.model.NoracleAgentProfile in project Distributed-Noracle-Backend by Distributed-Noracle.
the class NoracleAgentService method updateAgentProfile.
@Override
public NoracleAgentProfile updateAgentProfile(String agentName) throws ServiceInvocationException {
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;
}
Aggregations