public RemoteProcessGroupDTO copy(final RemoteProcessGroupDTO original) { final RemoteProcessGroupContentsDTO originalContents = original.getContents(); final RemoteProcessGroupContentsDTO copyContents = new RemoteProcessGroupContentsDTO(); final RemoteProcessGroupDTO copy = new RemoteProcessGroupDTO(); copy.setComments(original.getComments()); copy.setPosition(original.getPosition()); copy.setId(original.getId()); copy.setCommunicationsTimeout(original.getCommunicationsTimeout()); copy.setYieldDuration(original.getYieldDuration()); copy.setName(original.getName()); copy.setInputPortCount(original.getInputPortCount()); copy.setOutputPortCount(original.getOutputPortCount()); copy.setActiveRemoteInputPortCount(original.getActiveRemoteInputPortCount()); copy.setInactiveRemoteInputPortCount(original.getInactiveRemoteInputPortCount()); copy.setActiveRemoteOutputPortCount(original.getActiveRemoteOutputPortCount()); copy.setInactiveRemoteOutputPortCount(original.getInactiveRemoteOutputPortCount()); copy.setParentGroupId(original.getParentGroupId()); copy.setTargetUris(original.getTargetUris()); copy.setTransportProtocol(original.getTransportProtocol()); copy.setProxyHost(original.getProxyHost()); copy.setProxyPort(original.getProxyPort()); copy.setProxyUser(original.getProxyUser()); copy.setProxyPassword(original.getProxyPassword()); copy.setLocalNetworkInterface(original.getLocalNetworkInterface()); copy.setVersionedComponentId(original.getVersionedComponentId()); copy.setContents(copyContents);
public RemoteProcessGroupDTO(final RemoteProcessGroupDTO toCopy) { setId(toCopy.getId()); setPosition(toCopy.getPosition()); targetUri = toCopy.getTargetUri(); name = toCopy.getName(); }
/** * Verifies the specified remote group can be updated, if necessary. */ @SuppressWarnings("unchecked") private void verifyUpdate(RemoteProcessGroup remoteProcessGroup, RemoteProcessGroupDTO remoteProcessGroupDto) { // see if the remote process group can start/stop transmitting if (isNotNull(remoteProcessGroupDto.isTransmitting())) { if (!remoteProcessGroup.isTransmitting() && remoteProcessGroupDto.isTransmitting()) { remoteProcessGroup.verifyCanStartTransmitting(); } else if (remoteProcessGroup.isTransmitting() && !remoteProcessGroupDto.isTransmitting()) { remoteProcessGroup.verifyCanStopTransmitting(); } } // validate the proposed configuration final List<String> requestValidation = validateProposedRemoteProcessGroupConfiguration(remoteProcessGroupDto); // ensure there was no validation errors if (!requestValidation.isEmpty()) { throw new ValidationException(requestValidation); } // if any remote group properties are changing, verify update if (isAnyNotNull(remoteProcessGroupDto.getYieldDuration(), remoteProcessGroupDto.getLocalNetworkInterface(), remoteProcessGroupDto.getCommunicationsTimeout(), remoteProcessGroupDto.getProxyHost(), remoteProcessGroupDto.getProxyPort(), remoteProcessGroupDto.getProxyUser(), remoteProcessGroupDto.getProxyPassword())) { remoteProcessGroup.verifyCanUpdate(); } }
final String targetUris = remoteProcessGroupDTO.getTargetUris(); final String name = remoteProcessGroupDTO.getName(); final String comments = remoteProcessGroupDTO.getComments(); final String communicationsTimeout = remoteProcessGroupDTO.getCommunicationsTimeout(); final String yieldDuration = remoteProcessGroupDTO.getYieldDuration(); final String proxyHost = remoteProcessGroupDTO.getProxyHost(); final Integer proxyPort = remoteProcessGroupDTO.getProxyPort(); final String proxyUser = remoteProcessGroupDTO.getProxyUser(); final String proxyPassword = remoteProcessGroupDTO.getProxyPassword(); final String transportProtocol = remoteProcessGroupDTO.getTransportProtocol(); final String localNetworkInterface = remoteProcessGroupDTO.getLocalNetworkInterface(); remoteProcessGroup.setYieldDuration(yieldDuration); if (isNotNull(remoteProcessGroupDTO.getPosition())) { remoteProcessGroup.setPosition(new Position(remoteProcessGroupDTO.getPosition().getX(), remoteProcessGroupDTO.getPosition().getY())); final Boolean isTransmitting = remoteProcessGroupDTO.isTransmitting(); if (isNotNull(isTransmitting)) {
@Override public RemoteProcessGroupSchema apply(RemoteProcessGroupDTO remoteProcessGroupDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.ID_KEY, remoteProcessGroupDTO.getId()); map.put(CommonPropertyKeys.NAME_KEY, remoteProcessGroupDTO.getName()); final String targetUris = remoteProcessGroupDTO.getTargetUris(); map.put(RemoteProcessGroupSchema.URL_KEY, StringUtils.isNotBlank(targetUris) ? targetUris : remoteProcessGroupDTO.getTargetUri()); RemoteProcessGroupContentsDTO contents = remoteProcessGroupDTO.getContents(); if (contents != null) { Set<RemoteProcessGroupPortDTO> inputPorts = contents.getInputPorts(); map.put(CommonPropertyKeys.COMMENT_KEY, remoteProcessGroupDTO.getComments()); map.put(RemoteProcessGroupSchema.TIMEOUT_KEY, remoteProcessGroupDTO.getCommunicationsTimeout()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, remoteProcessGroupDTO.getYieldDuration()); map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, remoteProcessGroupDTO.getTransportProtocol()); map.put(RemoteProcessGroupSchema.PROXY_HOST_KEY, remoteProcessGroupDTO.getProxyHost()); map.put(RemoteProcessGroupSchema.PROXY_PORT_KEY, remoteProcessGroupDTO.getProxyPort()); map.put(RemoteProcessGroupSchema.PROXY_USER_KEY, remoteProcessGroupDTO.getProxyUser()); map.put(RemoteProcessGroupSchema.PROXY_PASSWORD_KEY, remoteProcessGroupDTO.getProxyPassword()); map.put(RemoteProcessGroupSchema.LOCAL_NETWORK_INTERFACE_KEY, remoteProcessGroupDTO.getLocalNetworkInterface()); return new RemoteProcessGroupSchema(map);
final RemoteProcessGroupContentsDTO remoteProcessGroupContents = clientDto.getContents(); ErrorMerger.mergeErrors(authorizationErrorMap, nodeId, nodeRemoteProcessGroup.getAuthorizationIssues()); ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeRemoteProcessGroup.getValidationErrors()); final Boolean nodeIsTargetSecure = nodeRemoteProcessGroup.isTargetSecure(); if (mergedIsTargetSecure == null) { mergedIsTargetSecure = nodeIsTargetSecure; final RemoteProcessGroupContentsDTO nodeRemoteProcessGroupContentsDto = nodeRemoteProcessGroup.getContents(); if (remoteProcessGroupContents != null && nodeRemoteProcessGroupContentsDto != null) { final Set<RemoteProcessGroupPortDTO> nodeInputPorts = nodeRemoteProcessGroupContentsDto.getInputPorts(); if (mergedInputPorts == null) { remoteProcessGroupContents.setInputPorts(Collections.emptySet()); clientDto.setInputPortCount(0); } else { remoteProcessGroupContents.setInputPorts(mergedInputPorts); clientDto.setInputPortCount(mergedInputPorts.size()); clientDto.setOutputPortCount(0); } else { remoteProcessGroupContents.setOutputPorts(mergedOutputPorts); clientDto.setOutputPortCount(mergedOutputPorts.size()); clientDto.setTargetSecure(mergedIsTargetSecure); clientDto.setAuthorizationIssues(ErrorMerger.normalizedMergedErrors(authorizationErrorMap, dtoMap.size())); clientDto.setValidationErrors(ErrorMerger.normalizedMergedErrors(validationErrorMap, dtoMap.size()));
if (requestRemoteProcessGroupDTO.getId() != null) { throw new IllegalArgumentException("Remote process group ID cannot be specified."); if (requestRemoteProcessGroupDTO.getTargetUri() == null) { throw new IllegalArgumentException("The URI of the process group must be specified."); final PositionDTO proposedPosition = requestRemoteProcessGroupDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { if (requestRemoteProcessGroupDTO.getParentGroupId() != null && !groupId.equals(requestRemoteProcessGroupDTO.getParentGroupId())) { throw new IllegalArgumentException(String.format("If specified, the parent process group id %s must be the same as specified in the URI %s", requestRemoteProcessGroupDTO.getParentGroupId(), groupId)); requestRemoteProcessGroupDTO.setParentGroupId(groupId); remoteProcessGroupDTO.setId(generateUuid()); final String targetUris = remoteProcessGroupDTO.getTargetUris(); SiteToSiteRestApiClient.parseClusterUrls(targetUris); remoteProcessGroupDTO.setTargetUris(targetUris); final Revision revision = getRevision(remoteProcessGroupEntity, remoteProcessGroupDTO.getId()); final RemoteProcessGroupEntity entity = serviceFacade.createRemoteProcessGroup(revision, groupId, remoteProcessGroupDTO); remoteProcessGroupResource.populateRemainingRemoteProcessGroupEntityContent(entity);
final List<String> validationErrors = new ArrayList<>(); if (isNotNull(remoteProcessGroupDTO.getCommunicationsTimeout())) { Matcher yieldMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(remoteProcessGroupDTO.getCommunicationsTimeout()); if (!yieldMatcher.matches()) { validationErrors.add("Communications timeout is not a valid time duration (ie 30 sec, 5 min)"); if (isNotNull(remoteProcessGroupDTO.getYieldDuration())) { Matcher yieldMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(remoteProcessGroupDTO.getYieldDuration()); if (!yieldMatcher.matches()) { validationErrors.add("Yield duration is not a valid time duration (ie 30 sec, 5 min)"); String proxyPassword = remoteProcessGroupDTO.getProxyPassword(); String proxyUser = remoteProcessGroupDTO.getProxyUser(); String proxyHost = remoteProcessGroupDTO.getProxyHost(); if (isNotNull(remoteProcessGroupDTO.getProxyPort())) { if (isEmpty(proxyHost)) { validationErrors.add("Proxy port was specified, but proxy host was empty.");
for (final RemoteProcessGroupDTO remoteGroupDTO : snippetContents.getRemoteProcessGroups()) { final RemoteProcessGroupDTO cp = dtoFactory.copy(remoteGroupDTO); cp.setId(generateId(remoteGroupDTO.getId(), idGenerationSeed, isCopy)); cp.setParentGroupId(groupId); final RemoteProcessGroupContentsDTO contents = cp.getContents(); if (contents != null && contents.getInputPorts() != null) { for (final RemoteProcessGroupPortDTO remotePort : contents.getInputPorts()) { remotePort.setGroupId(cp.getId()); final String originalId = remotePort.getId(); if (remotePort.getTargetId() == null) { connectableMap.put(remoteGroupDTO.getId() + "-" + originalId, dtoFactory.createConnectableDto(remotePort, ConnectableType.REMOTE_INPUT_PORT)); remotePort.setGroupId(cp.getId()); final String originalId = remotePort.getId(); if (remotePort.getTargetId() == null) { connectableMap.put(remoteGroupDTO.getId() + "-" + originalId, dtoFactory.createConnectableDto(remotePort, ConnectableType.REMOTE_OUTPUT_PORT)); ResourceFactory.getComponentResource(ResourceType.RemoteProcessGroup, remoteGroupDTO.getId(), remoteGroupDTO.getName()), ResourceFactory.getComponentResource(ResourceType.RemoteProcessGroup, cp.getId(), cp.getName()), idGenerationSeed);
if (!id.equals(requestRemoteProcessGroup.getId())) { throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the " + "remote process group id of the requested resource (%s).", requestRemoteProcessGroup.getId(), id)); final PositionDTO proposedPosition = requestRemoteProcessGroup.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { if (remoteProcessGroup.getTargetUri() != null) { uri = URI.create(remoteProcessGroup.getTargetUri()); } catch (final IllegalArgumentException e) { throw new IllegalArgumentException("The specified remote process group URL is malformed: " + remoteProcessGroup.getTargetUri()); throw new IllegalArgumentException("The specified remote process group URL is malformed: " + remoteProcessGroup.getTargetUri()); throw new IllegalArgumentException("The specified remote process group URL is invalid because it is not http or https: " + remoteProcessGroup.getTargetUri()); remoteProcessGroup.setTargetUri(controllerUri);
remoteProcessGroupDetails.setUri(remoteProcessGroup.getTargetUri()); final FlowChangeAction action = generateAuditRecord(remoteProcessGroup.getId(), remoteProcessGroup.getName(), Component.RemoteProcessGroup, Operation.Add, timestamp); action.setComponentDetails(remoteProcessGroupDetails); actions.add(action);
@Override public void verifyUpdateRemoteProcessGroup(final RemoteProcessGroupDTO remoteProcessGroupDTO) { // if remote group does not exist, then the update request is likely creating it // so we don't verify since it will fail if (remoteProcessGroupDAO.hasRemoteProcessGroup(remoteProcessGroupDTO.getId())) { remoteProcessGroupDAO.verifyUpdate(remoteProcessGroupDTO); } }
case AffectedComponentDTO.COMPONENT_TYPE_REMOTE_INPUT_PORT: { final RemoteProcessGroupEntity remoteGroupEntity = serviceFacade.getRemoteProcessGroup(componentEntity.getComponent().getProcessGroupId()); final RemoteProcessGroupContentsDTO remoteGroupContents = remoteGroupEntity.getComponent().getContents(); final Optional<RemoteProcessGroupPortDTO> portDtoOption = remoteGroupContents.getInputPorts().stream() .filter(port -> port.getId().equals(componentEntity.getId())) final RemoteProcessGroupContentsDTO remoteGroupContents = remoteGroupEntity.getComponent().getContents(); final Optional<RemoteProcessGroupPortDTO> portDtoOption = remoteGroupContents.getOutputPorts().stream() .filter(port -> port.getId().equals(componentEntity.getId()))
.forEach(id -> identifiers.add(id)); snippet.getRemoteProcessGroups().stream() .map(remoteGroup -> remoteGroup.getId()) .forEach(id -> identifiers.add(id)); snippet.getRemoteProcessGroups().stream() .filter(remoteGroup -> remoteGroup.getContents() != null && remoteGroup.getContents().getInputPorts() != null) .flatMap(remoteGroup -> remoteGroup.getContents().getInputPorts().stream()) .map(remoteInputPort -> remoteInputPort.getId()) .forEach(id -> identifiers.add(id)); snippet.getRemoteProcessGroups().stream() .filter(remoteGroup -> remoteGroup.getContents() != null && remoteGroup.getContents().getOutputPorts() != null) .flatMap(remoteGroup -> remoteGroup.getContents().getOutputPorts().stream()) .map(remoteOutputPort -> remoteOutputPort.getId()) .forEach(id -> identifiers.add(id));
public RemoteProcessGroupEntity createRemoteProcessGroupEntity(final RemoteProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PermissionsDTO operatePermissions, final RemoteProcessGroupStatusDTO status, final List<BulletinEntity> bulletins) { final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity(); entity.setRevision(revision); if (dto != null) { entity.setPermissions(permissions); entity.setOperatePermissions(operatePermissions); entity.setStatus(status); entity.setId(dto.getId()); entity.setPosition(dto.getPosition()); entity.setInputPortCount(dto.getInputPortCount()); entity.setOutputPortCount(dto.getOutputPortCount()); if (permissions != null && permissions.getCanRead()) { entity.setComponent(dto); entity.setBulletins(bulletins); } } return entity; }
/** * Creates a remote process group reference. * * @param remoteProcessGroupDTO The remote process group * @return The remote process group */ @Override public RemoteProcessGroup createRemoteProcessGroup(String groupId, RemoteProcessGroupDTO remoteProcessGroupDTO) { ProcessGroup group = locateProcessGroup(flowController, groupId); if (remoteProcessGroupDTO.getParentGroupId() != null && !flowController.getFlowManager().areGroupsSame(groupId, remoteProcessGroupDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the Remote Process Group is being added."); } final String targetUris = remoteProcessGroupDTO.getTargetUris(); if (targetUris == null || targetUris.length() == 0) { throw new IllegalArgumentException("Cannot add a Remote Process Group without specifying the Target URI(s)"); } // create the remote process group RemoteProcessGroup remoteProcessGroup = flowController.getFlowManager().createRemoteProcessGroup(remoteProcessGroupDTO.getId(), targetUris); remoteProcessGroup.initialize(); // set other properties updateRemoteProcessGroup(remoteProcessGroup, remoteProcessGroupDTO); // get the group to add the remote process group to group.addRemoteProcessGroup(remoteProcessGroup); return remoteProcessGroup; }
final RemoteProcessGroup remoteProcessGroup = remoteProcessGroupDAO.getRemoteProcessGroup(remoteProcessGroupDTO.getId()); remoteProcessGroupDTO.setAuthorizationIssues(Arrays.asList(remoteProcessGroup.getAuthorizationIssue()));
for (final Element remoteProcessGroupElement : remoteProcessGroupNodeList) { final RemoteProcessGroupDTO remoteGroupDto = FlowFromDOMFactory.getRemoteProcessGroup(remoteProcessGroupElement, encryptor); final RemoteProcessGroup remoteGroup = flowManager.createRemoteProcessGroup(remoteGroupDto.getId(), remoteGroupDto.getTargetUris()); remoteGroup.setVersionedComponentId(remoteGroupDto.getVersionedComponentId()); remoteGroup.setComments(remoteGroupDto.getComments()); remoteGroup.setPosition(toPosition(remoteGroupDto.getPosition())); final String name = remoteGroupDto.getName(); if (name != null && !name.trim().isEmpty()) { remoteGroup.setName(name); remoteGroup.setCommunicationsTimeout(remoteGroupDto.getCommunicationsTimeout()); if (remoteGroupDto.getYieldDuration() != null) { remoteGroup.setYieldDuration(remoteGroupDto.getYieldDuration()); final String transportProtocol = remoteGroupDto.getTransportProtocol(); if (transportProtocol != null && !transportProtocol.trim().isEmpty()) { remoteGroup.setTransportProtocol(SiteToSiteTransportProtocol.valueOf(transportProtocol.toUpperCase())); if (remoteGroupDto.getProxyHost() != null) { remoteGroup.setProxyHost(remoteGroupDto.getProxyHost()); if (remoteGroupDto.getProxyPort() != null) { remoteGroup.setProxyPort(remoteGroupDto.getProxyPort()); if (remoteGroupDto.getProxyUser() != null) { remoteGroup.setProxyUser(remoteGroupDto.getProxyUser()); if (remoteGroupDto.getProxyPassword() != null) {
@Override public RemoteProcessGroupSchema apply(RemoteProcessGroupDTO remoteProcessGroupDTO) { Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.ID_KEY, remoteProcessGroupDTO.getId()); map.put(CommonPropertyKeys.NAME_KEY, remoteProcessGroupDTO.getName()); map.put(RemoteProcessGroupSchema.URL_KEY, remoteProcessGroupDTO.getTargetUri()); RemoteProcessGroupContentsDTO contents = remoteProcessGroupDTO.getContents(); if (contents != null) { Set<RemoteProcessGroupPortDTO> inputPorts = contents.getInputPorts(); map.put(CommonPropertyKeys.COMMENT_KEY, remoteProcessGroupDTO.getComments()); map.put(RemoteProcessGroupSchema.TIMEOUT_KEY, remoteProcessGroupDTO.getCommunicationsTimeout()); map.put(CommonPropertyKeys.YIELD_PERIOD_KEY, remoteProcessGroupDTO.getYieldDuration()); map.put(RemoteProcessGroupSchema.TRANSPORT_PROTOCOL_KEY, remoteProcessGroupDTO.getTransportProtocol()); map.put(RemoteProcessGroupSchema.PROXY_HOST_KEY, remoteProcessGroupDTO.getProxyHost()); map.put(RemoteProcessGroupSchema.PROXY_PORT_KEY, remoteProcessGroupDTO.getProxyPort()); map.put(RemoteProcessGroupSchema.PROXY_USER_KEY, remoteProcessGroupDTO.getProxyUser()); map.put(RemoteProcessGroupSchema.PROXY_PASSWORD_KEY, remoteProcessGroupDTO.getProxyPassword()); map.put(RemoteProcessGroupSchema.LOCAL_NETWORK_INTERFACE_KEY, remoteProcessGroupDTO.getLocalNetworkInterface()); return new RemoteProcessGroupSchema(map);