/** * Check the parameters that are being attached to this subscription. */ private List<Parameter> checkInputParameters(final SubscriptionEditionVo vo) { final List<Parameter> acceptedParameters = nodeResource.checkInputParameters(vo); // Check all mandatory parameters for the current subscription mode vo.setParameters(ObjectUtils.defaultIfNull(vo.getParameters(), new ArrayList<>())); checkMandatoryParameters(vo.getParameters(), acceptedParameters, vo.getMode()); return acceptedParameters; }
final Project project = checkVisibleProject(vo.getProject()); checkManagedProject(vo.getProject()); final Node node = checkManagedNodeForSubscription(vo.getNode()); final List<Parameter> acceptedParameters = checkInputParameters(vo); parameterValueResource.create(vo.getParameters(), entity); checkMandatoryParameters(vo.getParameters(), acceptedParameters, SubscriptionMode.CREATE); log.info("Subscription of project {} to service {}", vo.getProject(), vo.getNode());
/** * Delegates the creation to the hierarchy of the related plug-in, and starting from the related plug-in. <br> * Exception appearing there causes to roll-back the previous persists. * * @throws Exception * When the link/create fails. Managed at upper level. */ private void delegateToPlugin(final SubscriptionEditionVo vo, final Subscription entity) throws Exception { for (ServicePlugin p = locator.getResource(vo.getNode()); p != null; p = locator .getResource(locator.getParent(p.getKey()))) { if (vo.getMode() == SubscriptionMode.CREATE) { // Create mode p.create(entity.getId()); } else { // Link mode p.link(entity.getId()); } } }
/** * {@link SubscriptionEditionVo} to JPA entity transformer. * * @param vo * The object to convert. * @param project * The related project. * @param node * The related node. * @return The mapped entity. */ public static Subscription toEntity(final SubscriptionEditionVo vo, final Project project, final Node node) { final Subscription entity = new Subscription(); entity.setProject(project); entity.setId(vo.getId()); entity.setNode(node); return entity; }