Search in sources :

Example 1 with OwnerApplication

use of won.protocol.model.OwnerApplication in project webofneeds by researchstudio-sat.

the class OwnerProtocolOutgoingMessagesProcessor method convertToQueueName.

private List<String> convertToQueueName(List<String> ownerApplications, String methodName, Exchange exchange) {
    List<String> ownerApplicationQueueNames = new ArrayList<>();
    for (int i = 0; i < ownerApplications.size(); i++) {
        OwnerApplication ownerApplication = ownerApplicationRepository.findByOwnerApplicationId(ownerApplications.get(i)).get(i);
        logger.debug(queueManagementService.getEndpointsForOwnerApplication(ownerApplication.getOwnerApplicationId(), exchange).get(0));
        logger.debug("ownerApplicationID: " + ownerApplications.get(i));
        ownerApplicationQueueNames.add(i, queueManagementService.getEndpointForMessage(methodName, ownerApplication.getOwnerApplicationId()));
    }
    return ownerApplicationQueueNames;
}
Also used : OwnerApplication(won.protocol.model.OwnerApplication) ArrayList(java.util.ArrayList)

Example 2 with OwnerApplication

use of won.protocol.model.OwnerApplication in project webofneeds by researchstudio-sat.

the class QueueManagementServiceImpl method getEndpointForMessage.

@Override
public String getEndpointForMessage(String methodName, String ownerApplicationID) {
    OwnerApplication ownerApplication = ownerApplicationRepository.findByOwnerApplicationId(ownerApplicationID).get(0);
    List<String> queueNames = ownerApplication.getQueueNames();
    String endpoint = "";
    for (int i = 0; i < queueNames.size(); i++) {
        endpoint = queueNames.get(i);
        if (queueNames.get(i).contains(methodName)) {
            break;
        }
    }
    return endpoint;
}
Also used : OwnerApplication(won.protocol.model.OwnerApplication)

Example 3 with OwnerApplication

use of won.protocol.model.OwnerApplication in project webofneeds by researchstudio-sat.

the class AbstractCamelProcessor method sendMessageToOwner.

protected void sendMessageToOwner(WonMessage message, URI needURI, String fallbackOwnerApplicationId) {
    Need need = needRepository.findOneByNeedURI(needURI);
    List<OwnerApplication> ownerApplications = need != null ? need.getAuthorizedApplications() : Collections.EMPTY_LIST;
    List<String> ownerApplicationIds = toStringIds(ownerApplications);
    // if no owner application ids are authorized, we use the fallback specified (if any)
    if (ownerApplicationIds.isEmpty() && fallbackOwnerApplicationId != null) {
        ownerApplicationIds.add(fallbackOwnerApplicationId);
    }
    Map headerMap = new HashMap<String, Object>();
    headerMap.put(WonCamelConstants.OWNER_APPLICATIONS, ownerApplicationIds);
    messagingService.sendInOnlyMessage(null, headerMap, RdfUtils.writeDatasetToString(message.getCompleteDataset(), WonCamelConstants.RDF_LANGUAGE_FOR_MESSAGE), "seda:OwnerProtocolOut");
}
Also used : Need(won.protocol.model.Need) OwnerApplication(won.protocol.model.OwnerApplication)

Example 4 with OwnerApplication

use of won.protocol.model.OwnerApplication in project webofneeds by researchstudio-sat.

the class OwnerManagementServiceImpl method registerOwnerApplication.

@Override
public String registerOwnerApplication(String ownerApplicationId) {
    logger.debug("ownerApplicationId: " + ownerApplicationId.toString());
    if (ownerApplicatonRepository.findByOwnerApplicationIdForUpdate(ownerApplicationId).isEmpty()) {
        logger.info("Registering owner application for the first time with id: {}", ownerApplicationId);
        OwnerApplication ownerApplication = new OwnerApplication();
        ownerApplication.setOwnerApplicationId(ownerApplicationId.toString());
        ownerApplication = ownerApplicatonRepository.save(ownerApplication);
        List<String> queueNames = queueManagementService.generateQueueNamesForOwnerApplication(ownerApplication);
        ownerApplication.setQueueNames(queueNames);
        ownerApplication = ownerApplicatonRepository.save(ownerApplication);
        return ownerApplicationId;
    } else {
        logger.info("Registering already known owner application with id: {}", ownerApplicationId);
        return ownerApplicationId;
    }
}
Also used : OwnerApplication(won.protocol.model.OwnerApplication)

Aggregations

OwnerApplication (won.protocol.model.OwnerApplication)4 ArrayList (java.util.ArrayList)1 Need (won.protocol.model.Need)1