Search in sources :

Example 16 with Question

use of i5.las2peer.services.noracleService.model.Question in project Distributed-Noracle-Backend by Distributed-Noracle.

the class NoracleQuestionRelationService method linkQuestionRelationToSpace.

public boolean linkQuestionRelationToSpace(String spaceId, String relationId) {
    int relationNumber;
    for (relationNumber = 1; relationNumber < MAX_RELATIONS_PER_SPACE; relationNumber++) {
        try {
            Context.get().requestEnvelope(buildSpaceQuestionRelationNumberId(spaceId, relationNumber));
        } catch (EnvelopeNotFoundException e) {
            // found free question number
            break;
        } catch (Exception e) {
        // XXX logging
        }
    }
    try {
        Envelope spaceQuestionRelationEnv = Context.get().createEnvelope(buildSpaceQuestionRelationNumberId(spaceId, relationNumber));
        spaceQuestionRelationEnv.setPublic();
        spaceQuestionRelationEnv.setContent(relationId);
        Context.get().storeEnvelope(spaceQuestionRelationEnv);
        return true;
    } catch (EnvelopeOperationFailedException | EnvelopeAccessDeniedException e) {
        // TODO exception handling
        e.printStackTrace();
    }
    return false;
}
Also used : EnvelopeOperationFailedException(i5.las2peer.api.persistency.EnvelopeOperationFailedException) EnvelopeNotFoundException(i5.las2peer.api.persistency.EnvelopeNotFoundException) EnvelopeAccessDeniedException(i5.las2peer.api.persistency.EnvelopeAccessDeniedException) Envelope(i5.las2peer.api.persistency.Envelope) EnvelopeAccessDeniedException(i5.las2peer.api.persistency.EnvelopeAccessDeniedException) EnvelopeOperationFailedException(i5.las2peer.api.persistency.EnvelopeOperationFailedException) EnvelopeNotFoundException(i5.las2peer.api.persistency.EnvelopeNotFoundException)

Aggregations

Envelope (i5.las2peer.api.persistency.Envelope)8 EnvelopeAccessDeniedException (i5.las2peer.api.persistency.EnvelopeAccessDeniedException)8 EnvelopeOperationFailedException (i5.las2peer.api.persistency.EnvelopeOperationFailedException)8 ServiceNameVersion (i5.las2peer.api.p2p.ServiceNameVersion)7 EnvelopeNotFoundException (i5.las2peer.api.persistency.EnvelopeNotFoundException)7 Serializable (java.io.Serializable)7 Question (i5.las2peer.services.noracleService.model.Question)6 ApiResponses (io.swagger.annotations.ApiResponses)4 Gson (com.google.gson.Gson)3 ServiceInvocationException (i5.las2peer.api.execution.ServiceInvocationException)3 JSONObject (net.minidev.json.JSONObject)3 JSONParser (net.minidev.json.parser.JSONParser)3 ParseException (net.minidev.json.parser.ParseException)3 InternalServiceException (i5.las2peer.api.execution.InternalServiceException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Instant (java.time.Instant)2 QuestionRelation (i5.las2peer.services.noracleService.model.QuestionRelation)1 Space (i5.las2peer.services.noracleService.model.Space)1 Vote (i5.las2peer.services.noracleService.model.Vote)1