public PortDTO copy(final PortDTO original) { final PortDTO copy = new PortDTO(); copy.setPosition(original.getPosition()); copy.setId(original.getId()); copy.setName(original.getName()); copy.setComments(original.getComments()); copy.setParentGroupId(original.getParentGroupId()); copy.setState(original.getState()); copy.setType(original.getType()); copy.setTransmitting(original.isTransmitting()); copy.setConcurrentlySchedulableTaskCount(original.getConcurrentlySchedulableTaskCount()); copy.setUserAccessControl(copy(original.getUserAccessControl())); copy.setGroupAccessControl(copy(original.getGroupAccessControl())); copy.setValidationErrors(copy(original.getValidationErrors())); copy.setVersionedComponentId(original.getVersionedComponentId()); return copy; }
private List<String> validateProposedConfiguration(PortDTO portDTO) { List<String> validationErrors = new ArrayList<>(); if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) { validationErrors.add("Port name cannot be blank."); } if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) { validationErrors.add("Concurrent tasks must be a positive integer."); } return validationErrors; }
@Override public Port updatePort(PortDTO portDTO) { Port inputPort = locatePort(portDTO.getId()); if (isNotNull(portDTO.getState())) { final ScheduledState purposedScheduledState = ScheduledState.valueOf(portDTO.getState()); if (isNotNull(portDTO.getGroupAccessControl())) { rootPort.setGroupAccessControl(portDTO.getGroupAccessControl()); if (isNotNull(portDTO.getUserAccessControl())) { rootPort.setUserAccessControl(portDTO.getUserAccessControl()); final String name = portDTO.getName(); final String comments = portDTO.getComments(); final Integer concurrentTasks = portDTO.getConcurrentlySchedulableTaskCount(); if (isNotNull(portDTO.getPosition())) { inputPort.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY()));
final PortDTO dto = new PortDTO(); dto.setId(port.getIdentifier()); dto.setPosition(createPositionDto(port.getPosition())); dto.setName(port.getName()); dto.setComments(port.getComments()); dto.setConcurrentlySchedulableTaskCount(port.getMaxConcurrentTasks()); dto.setParentGroupId(port.getProcessGroup().getIdentifier()); dto.setState(port.getScheduledState().toString()); dto.setType(port.getConnectableType().name()); dto.setVersionedComponentId(port.getVersionedComponentId().orElse(null)); dto.setTransmitting(rootGroupPort.isTransmitting()); dto.setGroupAccessControl(rootGroupPort.getGroupAccessControl()); dto.setUserAccessControl(rootGroupPort.getUserAccessControl()); dto.setValidationErrors(errors);
private void verifyUpdate(final Port outputPort, final PortDTO portDTO) { if (isNotNull(portDTO.getState())) { final ScheduledState purposedScheduledState = ScheduledState.valueOf(portDTO.getState()); if (isAnyNotNull(portDTO.getUserAccessControl(), portDTO.getGroupAccessControl(), portDTO.getConcurrentlySchedulableTaskCount(), portDTO.getName(), portDTO.getComments())) {
public static PortDTO getPort(final Element element) { final PortDTO portDTO = new PortDTO(); portDTO.setId(getString(element, "id")); portDTO.setVersionedComponentId(getString(element, "versionedComponentId")); portDTO.setPosition(getPosition(DomUtils.getChild(element, "position"))); portDTO.setName(getString(element, "name")); portDTO.setComments(getString(element, "comments")); final ScheduledState scheduledState = getScheduledState(element); portDTO.setState(scheduledState.toString()); portDTO.setConcurrentlySchedulableTaskCount(Integer.parseInt(maxTasksElements.get(0).getTextContent())); if (userAccessControls != null && !userAccessControls.isEmpty()) { final Set<String> users = new HashSet<>(); portDTO.setUserAccessControl(users); for (final Element userElement : userAccessControls) { users.add(userElement.getTextContent()); if (groupAccessControls != null && !groupAccessControls.isEmpty()) { final Set<String> groups = new HashSet<>(); portDTO.setGroupAccessControl(groups); for (final Element groupElement : groupAccessControls) { groups.add(groupElement.getTextContent());
@Override public Port createPort(String groupId, PortDTO portDTO) { if (isNotNull(portDTO.getParentGroupId()) && !flowController.getFlowManager().areGroupsSame(groupId, portDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the InputPort is being added."); } // ensure the name has been specified if (portDTO.getName() == null) { throw new IllegalArgumentException("Port name must be specified."); } // get the desired group ProcessGroup group = locateProcessGroup(flowController, groupId); // determine if this is the root group Port port; if (group.getParent() == null) { port = flowController.getFlowManager().createRemoteInputPort(portDTO.getId(), portDTO.getName()); } else { port = flowController.getFlowManager().createLocalInputPort(portDTO.getId(), portDTO.getName()); } // ensure we can perform the update before we add the processor to the flow verifyUpdate(port, portDTO); // configure if (portDTO.getPosition() != null) { port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY())); } port.setComments(portDTO.getComments()); // add the port group.addInputPort(port); return port; }
+ "target(portDAO)") public Port updatePortAdvice(ProceedingJoinPoint proceedingJoinPoint, PortDTO portDTO, PortDAO portDAO) throws Throwable { final Port port = portDAO.getPort(portDTO.getId()); final ScheduledState scheduledState = port.getScheduledState(); final String name = port.getName(); if (name != null && portDTO.getName() != null && !name.equals(updatedPort.getName())) { if (comments != null && portDTO.getComments() != null && !comments.equals(updatedPort.getComments())) { if (portDTO.getConcurrentlySchedulableTaskCount() != null && updatedPort.getMaxConcurrentTasks() != maxConcurrentTasks) { if (portDTO.getUserAccessControl() != null) { final Set<String> newUsers = new HashSet<>(portDTO.getUserAccessControl()); newUsers.removeAll(existingUsers); removedUsers.removeAll(portDTO.getUserAccessControl()); configDetails.setValue(StringUtils.join(portDTO.getUserAccessControl(), ", ")); configDetails.setPreviousValue(StringUtils.join(existingUsers, ", ")); if (portDTO.getGroupAccessControl() != null) { final Set<String> newGroups = new HashSet<>(portDTO.getGroupAccessControl()); newGroups.removeAll(existingGroups); removedGroups.removeAll(portDTO.getGroupAccessControl()); configDetails.setValue(StringUtils.join(portDTO.getGroupAccessControl(), ", ")); configDetails.setPreviousValue(StringUtils.join(existingGroups, ", "));
if (portDTO.getType() != null && portDTO.getType().equals("inputPort")) { resource = ResourceFactory.getDataTransferResource(ResourceFactory.getComponentResource(ResourceType.InputPort, portDTO.getId(), portDTO.getName())); } else { resource = ResourceFactory.getDataTransferResource(ResourceFactory.getComponentResource(ResourceType.OutputPort, portDTO.getId(), portDTO.getName())); if (portDTO.getUserAccessControl() != null) { for (String userAccessControl : portDTO.getUserAccessControl()) { if (portDTO.getGroupAccessControl() != null) { for (String groupAccessControl : portDTO.getGroupAccessControl()) { final String legacyGroupName = IdentityMappingUtil.mapIdentity(groupAccessControl, groupMappings);
@Override public void verifyUpdateInputPort(final PortDTO inputPortDTO) { // if connection does not exist, then the update request is likely creating it // so we don't verify since it will fail if (inputPortDAO.hasPort(inputPortDTO.getId())) { inputPortDAO.verifyUpdate(inputPortDTO); } }
for (final PortDTO portDTO : snippetContents.getInputPorts()) { final PortDTO cp = dtoFactory.copy(portDTO); cp.setId(generateId(portDTO.getId(), idGenerationSeed, isCopy)); cp.setParentGroupId(groupId); cp.setState(ScheduledState.STOPPED.toString()); inputPorts.add(cp); connectableMap.put(portDTO.getParentGroupId() + "-" + portDTO.getId(), portConnectable); if (parentConnectableMap != null) { parentConnectableMap.put(portDTO.getParentGroupId() + "-" + portDTO.getId(), portConnectable); ResourceFactory.getComponentResource(ResourceType.InputPort, portDTO.getId(), portDTO.getName()), ResourceFactory.getComponentResource(ResourceType.InputPort, cp.getId(), cp.getName()), idGenerationSeed); for (final PortDTO portDTO : snippetContents.getOutputPorts()) { final PortDTO cp = dtoFactory.copy(portDTO); cp.setId(generateId(portDTO.getId(), idGenerationSeed, isCopy)); cp.setParentGroupId(groupId); cp.setState(ScheduledState.STOPPED.toString()); outputPorts.add(cp); connectableMap.put(portDTO.getParentGroupId() + "-" + portDTO.getId(), portConnectable); if (parentConnectableMap != null) { parentConnectableMap.put(portDTO.getParentGroupId() + "-" + portDTO.getId(), portConnectable); ResourceFactory.getComponentResource(ResourceType.OutputPort, portDTO.getId(), portDTO.getName()), ResourceFactory.getComponentResource(ResourceType.OutputPort, cp.getId(), cp.getName()), idGenerationSeed);
/** * Converts a set of ports into a set of remote process group ports. * * @param ports to convert * @return descriptors of ports */ private Set<RemoteProcessGroupPortDescriptor> convertRemotePort(final Set<PortDTO> ports) { Set<RemoteProcessGroupPortDescriptor> remotePorts = null; if (ports != null) { remotePorts = new LinkedHashSet<>(ports.size()); for (final PortDTO port : ports) { final StandardRemoteProcessGroupPortDescriptor descriptor = new StandardRemoteProcessGroupPortDescriptor(); final ScheduledState scheduledState = ScheduledState.valueOf(port.getState()); descriptor.setId(generatePortId(port.getId())); descriptor.setTargetId(port.getId()); descriptor.setName(port.getName()); descriptor.setComments(port.getComments()); descriptor.setTargetRunning(ScheduledState.RUNNING.equals(scheduledState)); remotePorts.add(descriptor); } } return remotePorts; }
public AffectedComponentEntity createAffectedComponentEntity(final PortEntity portEntity, final String referenceType) { if (portEntity == null) { return null; } final AffectedComponentEntity component = new AffectedComponentEntity(); component.setBulletins(portEntity.getBulletins()); component.setId(portEntity.getId()); component.setPermissions(portEntity.getPermissions()); component.setPosition(portEntity.getPosition()); component.setRevision(portEntity.getRevision()); component.setUri(portEntity.getUri()); final PortDTO portDto = portEntity.getComponent(); final AffectedComponentDTO componentDto = new AffectedComponentDTO(); componentDto.setId(portDto.getId()); componentDto.setName(portDto.getName()); componentDto.setProcessGroupId(portDto.getParentGroupId()); componentDto.setReferenceType(referenceType); componentDto.setState(portDto.getState()); componentDto.setValidationErrors(portDto.getValidationErrors()); component.setComponent(componentDto); return component; }
if (requestPortEntity.getComponent().getId() != null) { throw new IllegalArgumentException("Output port ID cannot be specified."); final PositionDTO proposedPosition = requestPortEntity.getComponent().getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { if (requestPortEntity.getComponent().getParentGroupId() != null && !groupId.equals(requestPortEntity.getComponent().getParentGroupId())) { throw new IllegalArgumentException(String.format("If specified, the parent process group id %s must be the same as specified in the URI %s", requestPortEntity.getComponent().getParentGroupId(), groupId)); requestPortEntity.getComponent().setParentGroupId(groupId); portEntity -> { portEntity.getComponent().setId(generateUuid()); final Revision revision = getRevision(portEntity, portEntity.getComponent().getId()); final PortEntity entity = serviceFacade.createOutputPort(revision, groupId, portEntity.getComponent()); outputPortResource.populateRemainingOutputPortEntityContent(entity);
public ConnectableDTO createConnectableDto(final PortDTO port, final ConnectableType type) { final ConnectableDTO connectable = new ConnectableDTO(); connectable.setGroupId(port.getParentGroupId()); connectable.setId(port.getId()); connectable.setName(port.getName()); connectable.setType(type.name()); connectable.setVersionedComponentId(port.getVersionedComponentId()); return connectable; }
if (!id.equals(requestPortDTO.getId())) { throw new IllegalArgumentException(String.format("The output port id (%s) in the request body does not equal the " + "output port id of the requested resource (%s).", requestPortDTO.getId(), id)); final PositionDTO proposedPosition = requestPortDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) {
public PortEntity createPortEntity(final PortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PermissionsDTO operatePermissions, final PortStatusDTO status, final List<BulletinEntity> bulletins) { final PortEntity entity = new PortEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setOperatePermissions(operatePermissions); entity.setStatus(status); entity.setId(dto.getId()); entity.setPosition(dto.getPosition()); entity.setPortType(dto.getType()); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); entity.setBulletins(bulletins); } } return entity; }
for (final RootGroupPort inputPort : inputPorts) { if (isUserAuthorized(user, inputPort)) { final PortDTO dto = new PortDTO(); dto.setId(inputPort.getIdentifier()); dto.setName(inputPort.getName()); dto.setComments(inputPort.getComments()); dto.setState(inputPort.getScheduledState().toString()); inputPortDtos.add(dto); for (final RootGroupPort outputPort : controllerFacade.getOutputPorts()) { if (isUserAuthorized(user, outputPort)) { final PortDTO dto = new PortDTO(); dto.setId(outputPort.getIdentifier()); dto.setName(outputPort.getName()); dto.setComments(outputPort.getComments()); dto.setState(outputPort.getScheduledState().toString()); outputPortDtos.add(dto);