Search in sources :

Example 11 with InvocationBadArgumentException

use of i5.las2peer.api.execution.InvocationBadArgumentException in project Distributed-Noracle-Backend by Distributed-Noracle.

the class NoracleSpaceService method joinSpace.

public void joinSpace(String spaceId, String spaceSecret) throws ServiceInvocationException {
    if (spaceId == null || spaceId.isEmpty()) {
        throw new InvocationBadArgumentException("No space id given");
    } else if (spaceSecret == null || spaceSecret.isEmpty()) {
        throw new ServiceAccessDeniedException("No space secret given");
    }
    try {
        UserAgentImpl inviteAgent = this.getInviteAgent(spaceId);
        inviteAgent.unlock(spaceSecret);
        GroupAgent memberAgent = this.getMemberAgent(spaceId);
        memberAgent.unlock(inviteAgent);
        memberAgent.addMember(Context.get().getMainAgent());
        Context.get().storeAgent(memberAgent);
    } catch (AgentAccessDeniedException e) {
        throw new ServiceAccessDeniedException("Could not unlock agent", e);
    } catch (Exception e) {
        throw new ServiceInvocationException("Could not join space", e);
    }
}
Also used : UserAgentImpl(i5.las2peer.security.UserAgentImpl) EnvelopeAccessDeniedException(i5.las2peer.api.persistency.EnvelopeAccessDeniedException) CryptoException(i5.las2peer.tools.CryptoException) EnvelopeOperationFailedException(i5.las2peer.api.persistency.EnvelopeOperationFailedException) SerializationException(i5.las2peer.serialization.SerializationException) EnvelopeNotFoundException(i5.las2peer.api.persistency.EnvelopeNotFoundException)

Example 12 with InvocationBadArgumentException

use of i5.las2peer.api.execution.InvocationBadArgumentException in project Distributed-Noracle-Backend by Distributed-Noracle.

the class NoracleSpaceService method getSpace.

@Override
public Space getSpace(String spaceId) throws ServiceInvocationException {
    if (spaceId == null || spaceId.isEmpty()) {
        throw new InvocationBadArgumentException("No space id given");
    }
    Envelope env;
    try {
        env = Context.get().requestEnvelope(getSpaceEnvelopeIdentifier(spaceId));
    } catch (EnvelopeAccessDeniedException e) {
        throw new ServiceAccessDeniedException("Access Denied", e);
    } catch (EnvelopeNotFoundException e) {
        throw new ResourceNotFoundException("Space Not Found", e);
    } catch (EnvelopeOperationFailedException e) {
        throw new InternalServiceException("Could not deserialize space object", e);
    }
    Space space = (Space) env.getContent();
    return space;
}
Also used : Space(i5.las2peer.services.noracleService.model.Space) EnvelopeOperationFailedException(i5.las2peer.api.persistency.EnvelopeOperationFailedException) EnvelopeNotFoundException(i5.las2peer.api.persistency.EnvelopeNotFoundException) EnvelopeAccessDeniedException(i5.las2peer.api.persistency.EnvelopeAccessDeniedException) Envelope(i5.las2peer.api.persistency.Envelope)

Example 13 with InvocationBadArgumentException

use of i5.las2peer.api.execution.InvocationBadArgumentException in project Distributed-Noracle-Backend by Distributed-Noracle.

the class NoracleQuestionRelationService method getQuestionRelation.

@Override
public QuestionRelation getQuestionRelation(String relationId) throws ServiceInvocationException {
    if (relationId == null || relationId.isEmpty()) {
        throw new InvocationBadArgumentException("No relation id given");
    }
    Envelope env;
    try {
        env = Context.get().requestEnvelope(getQuestionRelationEnvelopeIdentifier(relationId));
    } catch (EnvelopeAccessDeniedException e) {
        throw new ServiceAccessDeniedException("Envelope Access Denied");
    } catch (EnvelopeOperationFailedException e) {
        throw new InternalServiceException("Could not fetch relation envelope", e);
    } catch (EnvelopeNotFoundException e) {
        throw new ResourceNotFoundException("Relation Not Found");
    }
    QuestionRelation relation = (QuestionRelation) env.getContent();
    return relation;
}
Also used : EnvelopeOperationFailedException(i5.las2peer.api.persistency.EnvelopeOperationFailedException) EnvelopeNotFoundException(i5.las2peer.api.persistency.EnvelopeNotFoundException) QuestionRelation(i5.las2peer.services.noracleService.model.QuestionRelation) EnvelopeAccessDeniedException(i5.las2peer.api.persistency.EnvelopeAccessDeniedException) Envelope(i5.las2peer.api.persistency.Envelope)

Aggregations

EnvelopeAccessDeniedException (i5.las2peer.api.persistency.EnvelopeAccessDeniedException)13 EnvelopeOperationFailedException (i5.las2peer.api.persistency.EnvelopeOperationFailedException)13 EnvelopeNotFoundException (i5.las2peer.api.persistency.EnvelopeNotFoundException)12 Envelope (i5.las2peer.api.persistency.Envelope)11 Question (i5.las2peer.services.noracleService.model.Question)4 Agent (i5.las2peer.api.security.Agent)3 AnonymousAgent (i5.las2peer.api.security.AnonymousAgent)3 ServiceNameVersion (i5.las2peer.api.p2p.ServiceNameVersion)2 UserAgentImpl (i5.las2peer.security.UserAgentImpl)2 SerializationException (i5.las2peer.serialization.SerializationException)2 QuestionRelation (i5.las2peer.services.noracleService.model.QuestionRelation)2 Space (i5.las2peer.services.noracleService.model.Space)2 SpaceSubscription (i5.las2peer.services.noracleService.model.SpaceSubscription)2 SpaceSubscriptionList (i5.las2peer.services.noracleService.model.SpaceSubscriptionList)2 CryptoException (i5.las2peer.tools.CryptoException)2 InternalServiceException (i5.las2peer.api.execution.InternalServiceException)1 InvocationBadArgumentException (i5.las2peer.api.execution.InvocationBadArgumentException)1 ServiceAccessDeniedException (i5.las2peer.api.execution.ServiceAccessDeniedException)1 ServiceInvocationException (i5.las2peer.api.execution.ServiceInvocationException)1 NoracleAgentProfile (i5.las2peer.services.noracleService.model.NoracleAgentProfile)1