class DataEngineRESTServices {

    public void addPortsToProcess(String userId, String serverName, String processGUID, List<String> portQualifiedNames, String externalSourceName) throws
                                                                                                                                                    InvalidParameterException,
                                                                                                                                                    PropertyServerException,
                                                                                                                                                    UserNotAuthorizedException {
        final String methodName = "addPortsToProcess";

        if (CollectionUtils.isEmpty(portQualifiedNames)) {
            return;
        }

        ProcessHandler processHandler = instanceHandler.getProcessHandler(userId, serverName, methodName);
        PortHandler portHandler = instanceHandler.getPortHandler(userId, serverName, methodName);

        for (String portQualifiedName : portQualifiedNames) {
            Optional<EntityDetail> portEntity = portHandler.findPortEntity(userId, portQualifiedName);
            if (portEntity.isPresent()) {
                processHandler.addProcessPortRelationship(userId, processGUID, portEntity.get().getGUID(), externalSourceName);
            }
        }
    }

}