diff --git a/nifi-api/src/main/java/org/apache/nifi/action/Operation.java b/nifi-api/src/main/java/org/apache/nifi/action/Operation.java index 0d5072c832..99b9495573 100644 --- a/nifi-api/src/main/java/org/apache/nifi/action/Operation.java +++ b/nifi-api/src/main/java/org/apache/nifi/action/Operation.java @@ -21,18 +21,34 @@ package org.apache.nifi.action; */ public enum Operation { - Add, - Remove, - Paste, - Configure, - Move, - Disconnect, - Connect, - Start, - Stop, - Enable, - Disable, - Batch, - Purge, - ClearState; + Add("Add"), + Remove("Remove"), + Paste("Paste"), + Configure("Configure"), + Move("Move"), + Disconnect("Disconnect"), + Connect("Connect"), + Start("Start"), + Stop("Stop"), + Enable("Enable"), + Disable("Disable"), + Batch("Batch"), + Purge("Purge"), + ClearState("Clear State"), + StartVersionControl("Start Version Control"), + StopVersionControl("Stop Version Control"), + CommitLocalChanges("Commit Local Changes"), + RevertLocalChanges("Revert Local Changes"), + ChangeVersion("Change Version"); + + private final String label; + + Operation(String label) { + this.label = label; + } + + @Override + public String toString() { + return label; + } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java index df1774c5be..1b79b18a28 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/dao/impl/StandardActionDAO.java @@ -219,8 +219,8 @@ public class StandardActionDAO implements ActionDAO { statement.setString(1, StringUtils.left(action.getUserIdentity(), 4096)); statement.setString(2, action.getSourceId()); statement.setString(3, StringUtils.left(action.getSourceName(), 1000)); - statement.setString(4, action.getSourceType().toString()); - statement.setString(5, action.getOperation().toString()); + statement.setString(4, action.getSourceType().name()); + statement.setString(5, action.getOperation().name()); statement.setTimestamp(6, new java.sql.Timestamp(action.getTimestamp().getTime())); // insert the action diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BucketEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BucketEntity.java index 3d99308dc7..486fdf7884 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BucketEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/BucketEntity.java @@ -17,6 +17,7 @@ package org.apache.nifi.web.api.entity; import org.apache.nifi.web.api.dto.BucketDTO; +import org.apache.nifi.web.api.dto.PermissionsDTO; import javax.xml.bind.annotation.XmlRootElement; @@ -26,8 +27,17 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "bucketEntity") public class BucketEntity extends Entity { + private String id; private BucketDTO bucket; + private PermissionsDTO permissions; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } public BucketDTO getBucket() { return bucket; @@ -36,4 +46,12 @@ public class BucketEntity extends Entity { public void setBucket(BucketDTO bucket) { this.bucket = bucket; } + + public PermissionsDTO getPermissions() { + return permissions; + } + + public void setPermissions(PermissionsDTO permissions) { + this.permissions = permissions; + } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistriesEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistriesEntity.java index 6705c7a20a..26754bdfe0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistriesEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistriesEntity.java @@ -22,13 +22,13 @@ import java.util.Set; /** * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a set of RegistryEntity's. */ -@XmlRootElement(name = "registriesEntity") +@XmlRootElement(name = "registryClientsEntity") public class RegistriesEntity extends Entity { private Set registries; /** - * @return collection of LabelEntity's that are being serialized + * @return collection of RegistryEntity's that are being serialized */ public Set getRegistries() { return registries; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryClientEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryClientEntity.java new file mode 100644 index 0000000000..3b16067914 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryClientEntity.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.entity; + +import org.apache.nifi.web.api.dto.RegistryDTO; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a RegistryDTO. + */ +@XmlRootElement(name = "registryClientEntity") +public class RegistryClientEntity extends ComponentEntity { + + private RegistryDTO component; + + public RegistryDTO getComponent() { + return component; + } + + public void setComponent(RegistryDTO component) { + this.component = component; + } +} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryClientsEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryClientsEntity.java new file mode 100644 index 0000000000..9d6b849bc2 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryClientsEntity.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.entity; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.Set; + +/** + * A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a set of RegistryClientEntity's. + */ +@XmlRootElement(name = "registryClientsEntity") +public class RegistryClientsEntity extends Entity { + + private Set registries; + + /** + * @return collection of RegistryClientEntity's that are being serialized + */ + public Set getRegistries() { + return registries; + } + + public void setRegistries(Set registries) { + this.registries = registries; + } + +} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryEntity.java index 59685797ec..33ac3b1fe9 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/RegistryEntity.java @@ -24,16 +24,15 @@ import javax.xml.bind.annotation.XmlRootElement; * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a RegistryDTO. */ @XmlRootElement(name = "registryEntity") -public class RegistryEntity extends ComponentEntity { +public class RegistryEntity { - private RegistryDTO component; + private RegistryDTO registry; - - public RegistryDTO getComponent() { - return component; + public RegistryDTO getRegistry() { + return registry; } - public void setComponent(RegistryDTO component) { - this.component = component; + public void setRegistry(RegistryDTO registry) { + this.registry = registry; } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java index 22ad122254..363e049177 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java @@ -28,7 +28,10 @@ import org.apache.nifi.authorization.user.NiFiUserUtils; import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.controller.service.ControllerServiceState; import org.apache.nifi.groups.ProcessGroup; +import org.apache.nifi.registry.flow.VersionControlInformation; import org.apache.nifi.web.api.dto.ProcessGroupDTO; +import org.apache.nifi.web.api.dto.VariableRegistryDTO; +import org.apache.nifi.web.api.dto.VersionControlInformationDTO; import org.apache.nifi.web.dao.ProcessGroupDAO; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -39,6 +42,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.concurrent.Future; /** * Audits process group creation/removal and configuration changes. @@ -173,10 +177,13 @@ public class ProcessGroupAuditor extends NiFiAuditor { * @throws Throwable ex */ @Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && " - + "execution(void scheduleComponents(java.lang.String, org.apache.nifi.controller.ScheduledState, java.util.Set)) && " + + "execution(java.util.concurrent.Future scheduleComponents(java.lang.String, org.apache.nifi.controller.ScheduledState, java.util.Set)) && " + "args(groupId, state)") - public void scheduleComponentsAdvice(ProceedingJoinPoint proceedingJoinPoint, String groupId, ScheduledState state) throws Throwable { + public Future scheduleComponentsAdvice(ProceedingJoinPoint proceedingJoinPoint, String groupId, ScheduledState state) throws Throwable { final Operation operation; + + final Future result = (Future) proceedingJoinPoint.proceed(); + // determine the running state if (ScheduledState.RUNNING.equals(state)) { operation = Operation.Start; @@ -184,7 +191,9 @@ public class ProcessGroupAuditor extends NiFiAuditor { operation = Operation.Stop; } - saveUpdateAction(proceedingJoinPoint, groupId, operation); + saveUpdateAction(NiFiUserUtils.getNiFiUser(), groupId, operation); + + return result; } @@ -193,52 +202,118 @@ public class ProcessGroupAuditor extends NiFiAuditor { * * @param proceedingJoinPoint join point * @param groupId group id - * @param state controller serivce state state + * @param state controller service state * @throws Throwable ex */ @Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && " - + "execution(java.util.concurrent.Future activateControllerServices(java.lang.String, org.apache.nifi.controller.service.ControllerServiceState, java.util.Set)) && " + + "execution(java.util.concurrent.Future activateControllerServices(java.lang.String, org.apache.nifi.controller.service.ControllerServiceState, java.util.Set)) && " + "args(groupId, state)") - public void activateControllerServicesAdvice(ProceedingJoinPoint proceedingJoinPoint, String groupId, ControllerServiceState state) throws Throwable { + public Future activateControllerServicesAdvice(ProceedingJoinPoint proceedingJoinPoint, String groupId, ControllerServiceState state) throws Throwable { + final Operation operation; + + final Future result = (Future) proceedingJoinPoint.proceed(); // determine the service state - final Operation operation; if (ControllerServiceState.ENABLED.equals(state)) { operation = Operation.Enable; } else { operation = Operation.Disable; } - saveUpdateAction(proceedingJoinPoint, groupId, operation); + saveUpdateAction(NiFiUserUtils.getNiFiUser(), groupId, operation); + + return result; } /** * Audits the update of process group variable registry. * * @param proceedingJoinPoint join point - * @param groupId group id + * @param user the user performing the action + * @param variableRegistry variable registry * @throws Throwable ex */ @Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && " - + "execution(org.apache.nifi.groups.ProcessGroup updateVariableRegistry(org.apache.nifi.web.api.dto.VariableRegistryDTO)) && " - + "args(groupId)") - public void updateVariableRegistryAdvice(ProceedingJoinPoint proceedingJoinPoint, String groupId) throws Throwable { - final Operation operation = Operation.Configure; - saveUpdateAction(proceedingJoinPoint, groupId, operation); + + "execution(org.apache.nifi.groups.ProcessGroup updateVariableRegistry(org.apache.nifi.authorization.user.NiFiUser, org.apache.nifi.web.api.dto.VariableRegistryDTO)) && " + + "args(user, variableRegistry)") + public ProcessGroup updateVariableRegistryAdvice(final ProceedingJoinPoint proceedingJoinPoint, final NiFiUser user, final VariableRegistryDTO variableRegistry) throws Throwable { + final ProcessGroup updatedProcessGroup = (ProcessGroup) proceedingJoinPoint.proceed(); + + saveUpdateAction(user, variableRegistry.getProcessGroupId(), Operation.Configure); + + return updatedProcessGroup; } + @Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && " + + "execution(org.apache.nifi.groups.ProcessGroup updateProcessGroupFlow(..))") + public ProcessGroup updateProcessGroupFlowAdvice(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + final Object[] args = proceedingJoinPoint.getArgs(); + final String groupId = (String) args[0]; + final NiFiUser user = (NiFiUser) args[1]; + final ProcessGroupDAO processGroupDAO = getProcessGroupDAO(); + final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); + final VersionControlInformation vci = processGroup.getVersionControlInformation(); - private void saveUpdateAction(final ProceedingJoinPoint proceedingJoinPoint, final String groupId, final Operation operation) throws Throwable { + final ProcessGroup updatedProcessGroup = (ProcessGroup) proceedingJoinPoint.proceed(); + final VersionControlInformation updatedVci = updatedProcessGroup.getVersionControlInformation(); + + final Operation operation; + if (vci == null) { + operation = Operation.StartVersionControl; + } else { + if (updatedVci == null) { + operation = Operation.StopVersionControl; + } else if (vci.getVersion() == updatedVci.getVersion()) { + operation = Operation.RevertLocalChanges; + } else { + operation = Operation.ChangeVersion; + } + } + + saveUpdateAction(user, groupId, operation); + + return updatedProcessGroup; + } + + @Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && " + + "execution(org.apache.nifi.groups.ProcessGroup updateVersionControlInformation(..))") + public ProcessGroup updateVersionControlInformationAdvice(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { + final VersionControlInformationDTO vciDto = (VersionControlInformationDTO) proceedingJoinPoint.getArgs()[0]; + + final ProcessGroupDAO processGroupDAO = getProcessGroupDAO(); + final ProcessGroup processGroup = processGroupDAO.getProcessGroup(vciDto.getGroupId()); + final VersionControlInformation vci = processGroup.getVersionControlInformation(); + + final ProcessGroup updatedProcessGroup = (ProcessGroup) proceedingJoinPoint.proceed(); + + final Operation operation; + if (vci == null) { + operation = Operation.StartVersionControl; + } else { + operation = Operation.CommitLocalChanges; + } + + saveUpdateAction(NiFiUserUtils.getNiFiUser(), vciDto.getGroupId(), operation); + + return updatedProcessGroup; + } + + @Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && " + + "execution(org.apache.nifi.groups.ProcessGroup disconnectVersionControl(java.lang.String)) && " + + "args(groupId)") + public ProcessGroup disconnectVersionControlAdvice(final ProceedingJoinPoint proceedingJoinPoint, final String groupId) throws Throwable { + final ProcessGroup updatedProcessGroup = (ProcessGroup) proceedingJoinPoint.proceed(); + + saveUpdateAction(NiFiUserUtils.getNiFiUser(), groupId, Operation.StopVersionControl); + + return updatedProcessGroup; + } + + private void saveUpdateAction(final NiFiUser user, final String groupId, final Operation operation) throws Throwable { ProcessGroupDAO processGroupDAO = getProcessGroupDAO(); ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); - // perform the action - proceedingJoinPoint.proceed(); - - // get the current user - NiFiUser user = NiFiUserUtils.getNiFiUser(); - // if the user was starting/stopping this process group FlowChangeAction action = new FlowChangeAction(); action.setUserIdentity(user.getIdentity()); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java index be77d106dd..78335f4f29 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java @@ -16,14 +16,6 @@ */ package org.apache.nifi.web; -import java.io.IOException; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.function.Function; - import org.apache.nifi.authorization.AuthorizeAccess; import org.apache.nifi.authorization.RequestAction; import org.apache.nifi.authorization.user.NiFiUser; @@ -106,6 +98,7 @@ import org.apache.nifi.web.api.entity.ProcessGroupFlowEntity; import org.apache.nifi.web.api.entity.ProcessGroupStatusEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ProcessorStatusEntity; +import org.apache.nifi.web.api.entity.RegistryClientEntity; import org.apache.nifi.web.api.entity.RegistryEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity; @@ -124,6 +117,14 @@ import org.apache.nifi.web.api.entity.VersionControlInformationEntity; import org.apache.nifi.web.api.entity.VersionedFlowEntity; import org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity; +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; + /** * Defines the NiFiServiceFacade interface. */ @@ -1929,7 +1930,7 @@ public interface NiFiServiceFacade { * @param registryDTO The registry DTO * @return The reporting task DTO */ - RegistryEntity createRegistryClient(Revision revision, RegistryDTO registryDTO); + RegistryClientEntity createRegistryClient(Revision revision, RegistryDTO registryDTO); /** * Gets a registry with the specified id. @@ -1937,14 +1938,14 @@ public interface NiFiServiceFacade { * @param registryId id * @return entity */ - RegistryEntity getRegistryClient(String registryId); + RegistryClientEntity getRegistryClient(String registryId); /** * Returns all registry clients. * * @return registry clients */ - Set getRegistryClients(); + Set getRegistryClients(); /** * Gets all registries for the current user. @@ -1991,7 +1992,7 @@ public interface NiFiServiceFacade { * @param registryDTO the registry dto * @return the updated registry registry entity */ - RegistryEntity updateRegistryClient(Revision revision, RegistryDTO registryDTO); + RegistryClientEntity updateRegistryClient(Revision revision, RegistryDTO registryDTO); /** * Deletes the specified registry using the specified revision. @@ -2000,7 +2001,7 @@ public interface NiFiServiceFacade { * @param registryId id * @return the deleted registry entity */ - RegistryEntity deleteRegistryClient(Revision revision, String registryId); + RegistryClientEntity deleteRegistryClient(Revision revision, String registryId); /** * Verifies the specified registry can be removed. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index 4adb85b0ce..ae89ef0af0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -220,6 +220,7 @@ import org.apache.nifi.web.api.entity.ProcessGroupStatusEntity; import org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ProcessorStatusEntity; +import org.apache.nifi.web.api.entity.RegistryClientEntity; import org.apache.nifi.web.api.entity.RegistryEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity; @@ -927,7 +928,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final ProcessGroup processGroupNode = processGroupDAO.getProcessGroup(variableRegistryDto.getProcessGroupId()); final RevisionUpdate snapshot = updateComponent(user, revision, processGroupNode, - () -> processGroupDAO.updateVariableRegistry(variableRegistryDto), + () -> processGroupDAO.updateVariableRegistry(user, variableRegistryDto), processGroup -> dtoFactory.createVariableRegistryDto(processGroup, revisionManager)); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroupNode); @@ -2301,10 +2302,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { @Override - public RegistryEntity createRegistryClient(Revision revision, RegistryDTO registryDTO) { + public RegistryClientEntity createRegistryClient(Revision revision, RegistryDTO registryDTO) { final NiFiUser user = NiFiUserUtils.getNiFiUser(); - // read lock on the containing group // request claim for component to be created... revision already verified (version == 0) final RevisionClaim claim = new StandardRevisionClaim(revision); @@ -2321,52 +2321,25 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { }); final FlowRegistry registry = revisionUpdate.getComponent(); - return createRegistryEntity(registry); + return createRegistryClientEntity(registry); } @Override - public RegistryEntity getRegistryClient(final String registryId) { + public RegistryClientEntity getRegistryClient(final String registryId) { final FlowRegistry registry = registryDAO.getFlowRegistry(registryId); - return createRegistryEntity(registry); + return createRegistryClientEntity(registry); } - private RegistryEntity createRegistryEntity(final FlowRegistry flowRegistry) { + private RegistryClientEntity createRegistryClientEntity(final FlowRegistry flowRegistry) { if (flowRegistry == null) { return null; } + final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(flowRegistry.getIdentifier())); + final PermissionsDTO permissions = dtoFactory.createPermissionsDto(authorizableLookup.getController()); final RegistryDTO dto = dtoFactory.createRegistryDto(flowRegistry); - final Revision revision = revisionManager.getRevision(dto.getId()); - final RegistryEntity entity = new RegistryEntity(); - entity.setComponent(dto); - entity.setRevision(dtoFactory.createRevisionDTO(revision)); - entity.setId(dto.getId()); - - // User who created it can read/write it. - final PermissionsDTO permissions = new PermissionsDTO(); - permissions.setCanRead(true); - permissions.setCanWrite(true); - entity.setPermissions(permissions); - - return entity; - } - - private BucketEntity createBucketEntity(final Bucket bucket) { - if (bucket == null) { - return null; - } - - final BucketDTO dto = new BucketDTO(); - dto.setId(bucket.getIdentifier()); - dto.setName(bucket.getName()); - dto.setDescription(bucket.getDescription()); - dto.setCreated(bucket.getCreatedTimestamp()); - - final BucketEntity entity = new BucketEntity(); - entity.setBucket(dto); - - return entity; + return entityFactory.createRegistryClientEntity(dto, revision, permissions); } private VersionedFlowEntity createVersionedFlowEntity(final String registryId, final VersionedFlow versionedFlow) { @@ -2400,23 +2373,40 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public Set getRegistryClients() { + public Set getRegistryClients() { return registryDAO.getFlowRegistries().stream() - .map(this::createRegistryEntity) + .map(this::createRegistryClientEntity) .collect(Collectors.toSet()); } @Override public Set getRegistriesForUser(final NiFiUser user) { return registryDAO.getFlowRegistriesForUser(user).stream() - .map(this::createRegistryEntity) + .map(flowRegistry -> entityFactory.createRegistryEntity(dtoFactory.createRegistryDto(flowRegistry))) .collect(Collectors.toSet()); } @Override public Set getBucketsForUser(final String registryId, final NiFiUser user) { return registryDAO.getBucketsForUser(registryId, user).stream() - .map(this::createBucketEntity) + .map(bucket -> { + if (bucket == null) { + return null; + } + + final BucketDTO dto = new BucketDTO(); + dto.setId(bucket.getIdentifier()); + dto.setName(bucket.getName()); + dto.setDescription(bucket.getDescription()); + dto.setCreated(bucket.getCreatedTimestamp()); + + final Set authorizedActions = bucket.getAuthorizedActions(); + final PermissionsDTO permissions = new PermissionsDTO(); + permissions.setCanRead(authorizedActions.contains("read")); + permissions.setCanWrite(authorizedActions.contains("write")); + + return entityFactory.createBucketEntity(dto, permissions); + }) .collect(Collectors.toSet()); } @@ -2435,7 +2425,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public RegistryEntity updateRegistryClient(Revision revision, RegistryDTO registryDTO) { + public RegistryClientEntity updateRegistryClient(Revision revision, RegistryDTO registryDTO) { final RevisionClaim revisionClaim = new StandardRevisionClaim(revision); final NiFiUser user = NiFiUserUtils.getNiFiUser(); @@ -2454,7 +2444,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { }); final FlowRegistry updatedReg = revisionUpdate.getComponent(); - return createRegistryEntity(updatedReg); + return createRegistryClientEntity(updatedReg); } @Override @@ -2463,7 +2453,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public RegistryEntity deleteRegistryClient(final Revision revision, final String registryId) { + public RegistryClientEntity deleteRegistryClient(final Revision revision, final String registryId) { final RevisionClaim claim = new StandardRevisionClaim(revision); final NiFiUser user = NiFiUserUtils.getNiFiUser(); @@ -2473,7 +2463,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { return reg; }); - return createRegistryEntity(registry); + return createRegistryClientEntity(registry); } @Override @@ -3695,10 +3685,9 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { // add first snapshot to the flow in the registry registeredSnapshot = registerVersionedFlowSnapshot(registryId, registeredFlow, versionedProcessGroup, versionedFlowDto.getComments(), expectedVersion); } catch (final NiFiRegistryException e) { - throw new IllegalArgumentException(e); + throw new IllegalArgumentException(e.getLocalizedMessage()); } catch (final IOException ioe) { - // will result in a 500: Internal Server Error - throw new RuntimeException("Failed to communicate with Flow Registry when attempting to " + action); + throw new IllegalStateException("Failed to communicate with Flow Registry when attempting to " + action); } final Bucket bucket = registeredSnapshot.getBucket(); @@ -4105,7 +4094,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final ProcessGroup processGroupNode = processGroupDAO.getProcessGroup(groupId); final RevisionUpdate snapshot = updateComponent(user, revision, processGroupNode, - () -> processGroupDAO.updateProcessGroupFlow(groupId, proposedFlowSnapshot, versionControlInfo, componentIdSeed, verifyNotModified, updateSettings, updateDescendantVersionedFlows), + () -> processGroupDAO.updateProcessGroupFlow(groupId, user, proposedFlowSnapshot, versionControlInfo, componentIdSeed, verifyNotModified, updateSettings, updateDescendantVersionedFlows), processGroup -> dtoFactory.createProcessGroupDto(processGroup)); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroupNode); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java index 356d23143d..04c0efa137 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java @@ -46,8 +46,8 @@ import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.Entity; import org.apache.nifi.web.api.entity.HistoryEntity; import org.apache.nifi.web.api.entity.NodeEntity; -import org.apache.nifi.web.api.entity.RegistriesEntity; -import org.apache.nifi.web.api.entity.RegistryEntity; +import org.apache.nifi.web.api.entity.RegistryClientsEntity; +import org.apache.nifi.web.api.entity.RegistryClientEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.request.ClientIdParameter; import org.apache.nifi.web.api.request.DateTimeParameter; @@ -91,12 +91,12 @@ public class ControllerResource extends ApplicationResource { /** * Populate the uri's for the specified registry. * - * @param registryEntity registry + * @param registryClientEntity registry * @return dtos */ - public RegistryEntity populateRemainingRegistryEntityContent(final RegistryEntity registryEntity) { - registryEntity.setUri(generateResourceUri("controller", "registry-clients", registryEntity.getId())); - return registryEntity; + public RegistryClientEntity populateRemainingRegistryEntityContent(final RegistryClientEntity registryClientEntity) { + registryClientEntity.setUri(generateResourceUri("controller", "registry-clients", registryClientEntity.getId())); + return registryClientEntity; } /** @@ -316,7 +316,7 @@ public class ControllerResource extends ApplicationResource { @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @Path("registry-clients") - @ApiOperation(value = "Gets the listing of available registry clients", response = RegistriesEntity.class, authorizations = { + @ApiOperation(value = "Gets the listing of available registry clients", response = RegistryClientsEntity.class, authorizations = { @Authorization(value = "Read - /flow") }) @ApiResponses(value = { @@ -333,10 +333,10 @@ public class ControllerResource extends ApplicationResource { return replicate(HttpMethod.GET); } - final Set registries = serviceFacade.getRegistryClients(); + final Set registries = serviceFacade.getRegistryClients(); registries.forEach(registry -> populateRemainingRegistryEntityContent(registry)); - final RegistriesEntity registryEntities = new RegistriesEntity(); + final RegistryClientsEntity registryEntities = new RegistryClientsEntity(); registryEntities.setRegistries(registries); return generateOkResponse(registryEntities).build(); @@ -346,8 +346,8 @@ public class ControllerResource extends ApplicationResource { * Creates a new Registry. * * @param httpServletRequest request - * @param requestRegistryEntity A registryEntity. - * @return A registryEntity. + * @param requestRegistryClientEntity A registryClientEntity. + * @return A registryClientEntity. */ @POST @Consumes(MediaType.APPLICATION_JSON) @@ -355,7 +355,7 @@ public class ControllerResource extends ApplicationResource { @Path("registry-clients") @ApiOperation( value = "Creates a new registry client", - response = RegistryEntity.class, + response = RegistryClientEntity.class, authorizations = { @Authorization(value = "Write - /controller") } @@ -373,28 +373,28 @@ public class ControllerResource extends ApplicationResource { @ApiParam( value = "The registry configuration details.", required = true - ) final RegistryEntity requestRegistryEntity) { + ) final RegistryClientEntity requestRegistryClientEntity) { - if (requestRegistryEntity == null || requestRegistryEntity.getComponent() == null) { + if (requestRegistryClientEntity == null || requestRegistryClientEntity.getComponent() == null) { throw new IllegalArgumentException("Registry details must be specified."); } - if (requestRegistryEntity.getRevision() == null || (requestRegistryEntity.getRevision().getVersion() == null || requestRegistryEntity.getRevision().getVersion() != 0)) { + if (requestRegistryClientEntity.getRevision() == null || (requestRegistryClientEntity.getRevision().getVersion() == null || requestRegistryClientEntity.getRevision().getVersion() != 0)) { throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Registry."); } - final RegistryDTO requestReportingTask = requestRegistryEntity.getComponent(); + final RegistryDTO requestReportingTask = requestRegistryClientEntity.getComponent(); if (requestReportingTask.getId() != null) { throw new IllegalArgumentException("Registry ID cannot be specified."); } if (isReplicateRequest()) { - return replicate(HttpMethod.POST, requestRegistryEntity); + return replicate(HttpMethod.POST, requestRegistryClientEntity); } return withWriteLock( serviceFacade, - requestRegistryEntity, + requestRegistryClientEntity, lookup -> { authorizeController(RequestAction.WRITE); }, @@ -407,7 +407,7 @@ public class ControllerResource extends ApplicationResource { // create the reporting task and generate the json final Revision revision = getRevision(registryEntity, registry.getId()); - final RegistryEntity entity = serviceFacade.createRegistryClient(revision, registry); + final RegistryClientEntity entity = serviceFacade.createRegistryClient(revision, registry); populateRemainingRegistryEntityContent(entity); // build the response @@ -420,7 +420,7 @@ public class ControllerResource extends ApplicationResource { * Retrieves the specified registry. * * @param id The id of the registry to retrieve - * @return A registryEntity. + * @return A registryClientEntity. */ @GET @Consumes(MediaType.WILDCARD) @@ -428,7 +428,7 @@ public class ControllerResource extends ApplicationResource { @Path("/registry-clients/{id}") @ApiOperation( value = "Gets a registry client", - response = RegistryEntity.class, + response = RegistryClientEntity.class, authorizations = { @Authorization(value = "Read - /controller") } @@ -442,7 +442,7 @@ public class ControllerResource extends ApplicationResource { @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") } ) - public Response getRegistry( + public Response getRegistryClient( @ApiParam( value = "The registry id.", required = true @@ -457,7 +457,7 @@ public class ControllerResource extends ApplicationResource { authorizeController(RequestAction.READ); // get the registry - final RegistryEntity entity = serviceFacade.getRegistryClient(id); + final RegistryClientEntity entity = serviceFacade.getRegistryClient(id); populateRemainingRegistryEntityContent(entity); return generateOkResponse(entity).build(); @@ -477,7 +477,7 @@ public class ControllerResource extends ApplicationResource { @Path("/registry-clients/{id}") @ApiOperation( value = "Updates a registry client", - response = RegistryEntity.class, + response = RegistryClientEntity.class, authorizations = { @Authorization(value = "Write - /controller") } @@ -501,7 +501,7 @@ public class ControllerResource extends ApplicationResource { @ApiParam( value = "The registry configuration details.", required = true - ) final RegistryEntity requestRegsitryEntity) { + ) final RegistryClientEntity requestRegsitryEntity) { if (requestRegsitryEntity == null || requestRegsitryEntity.getComponent() == null) { throw new IllegalArgumentException("Registry details must be specified."); @@ -536,7 +536,7 @@ public class ControllerResource extends ApplicationResource { final RegistryDTO registry = registryEntity.getComponent(); // update the controller service - final RegistryEntity entity = serviceFacade.updateRegistryClient(revision, registry); + final RegistryClientEntity entity = serviceFacade.updateRegistryClient(revision, registry); populateRemainingRegistryEntityContent(entity); return generateOkResponse(entity).build(); @@ -562,7 +562,7 @@ public class ControllerResource extends ApplicationResource { @Path("/registry-clients/{id}") @ApiOperation( value = "Deletes a registry client", - response = RegistryEntity.class, + response = RegistryClientEntity.class, authorizations = { @Authorization(value = "Write - /controller") } @@ -598,14 +598,14 @@ public class ControllerResource extends ApplicationResource { return replicate(HttpMethod.DELETE); } - final RegistryEntity requestRegistryEntity = new RegistryEntity(); - requestRegistryEntity.setId(id); + final RegistryClientEntity requestRegistryClientEntity = new RegistryClientEntity(); + requestRegistryClientEntity.setId(id); // handle expects request (usually from the cluster manager) final Revision requestRevision = new Revision(version == null ? null : version.getLong(), clientId.getClientId(), id); return withWriteLock( serviceFacade, - requestRegistryEntity, + requestRegistryClientEntity, requestRevision, lookup -> { authorizeController(RequestAction.WRITE); @@ -613,7 +613,7 @@ public class ControllerResource extends ApplicationResource { () -> serviceFacade.verifyDeleteRegistry(id), (revision, registryEntity) -> { // delete the specified registry - final RegistryEntity entity = serviceFacade.deleteRegistryClient(revision, registryEntity.getId()); + final RegistryClientEntity entity = serviceFacade.deleteRegistryClient(revision, registryEntity.getId()); return generateOkResponse(entity).build(); } ); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java index 0ae5864734..dad8039bfc 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java @@ -88,6 +88,7 @@ import org.apache.nifi.web.api.entity.ProcessGroupStatusEntity; import org.apache.nifi.web.api.entity.ProcessorStatusEntity; import org.apache.nifi.web.api.entity.ProcessorTypesEntity; import org.apache.nifi.web.api.entity.RegistriesEntity; +import org.apache.nifi.web.api.entity.RegistryClientsEntity; import org.apache.nifi.web.api.entity.RegistryEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; @@ -1316,7 +1317,7 @@ public class FlowResource extends ApplicationResource { @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @Path("registries") - @ApiOperation(value = "Gets the listing of available registries", response = RegistriesEntity.class, authorizations = { + @ApiOperation(value = "Gets the listing of available registries", response = RegistryClientsEntity.class, authorizations = { @Authorization(value = "Read - /flow") }) @ApiResponses(value = { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java index 6dd641b677..5dc732538d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java @@ -183,7 +183,7 @@ public class VersionsResource extends ApplicationResource { @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") }) public Response createVersionControlRequest( - @ApiParam(value = "The versioned flow details.", required = true) final CreateActiveRequestEntity requestEntity) throws InterruptedException { + @ApiParam(value = "The versioned flow details.", required = true) final CreateActiveRequestEntity requestEntity) { if (isReplicateRequest()) { return replicate(HttpMethod.POST); @@ -412,7 +412,7 @@ public class VersionsResource extends ApplicationResource { }) public Response saveToFlowRegistry( @ApiParam("The process group id.") @PathParam("id") final String groupId, - @ApiParam(value = "The versioned flow details.", required = true) final StartVersionControlRequestEntity requestEntity) throws IOException { + @ApiParam(value = "The versioned flow details.", required = true) final StartVersionControlRequestEntity requestEntity) { // Verify the request final RevisionDTO revisionDto = requestEntity.getProcessGroupRevision(); @@ -569,8 +569,9 @@ public class VersionsResource extends ApplicationResource { return requestId; } - private void replicateVersionControlMapping(final VersionControlComponentMappingEntity mappingEntity, final StartVersionControlRequestEntity requestEntity, final URI requestUri, - final String groupId) { + private void replicateVersionControlMapping(final VersionControlComponentMappingEntity mappingEntity, final StartVersionControlRequestEntity requestEntity, + final URI requestUri, final String groupId) { + final Map headers = new HashMap<>(); headers.put("content-type", MediaType.APPLICATION_JSON); @@ -652,7 +653,7 @@ public class VersionsResource extends ApplicationResource { value = "If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.", required = false) @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) final ClientIdParameter clientId, - @ApiParam("The process group id.") @PathParam("id") final String groupId) throws IOException { + @ApiParam("The process group id.") @PathParam("id") final String groupId) { if (isReplicateRequest()) { return replicate(HttpMethod.DELETE); @@ -705,7 +706,7 @@ public class VersionsResource extends ApplicationResource { @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") }) public Response updateFlowVersion(@ApiParam("The process group id.") @PathParam("id") final String groupId, - @ApiParam(value = "The controller service configuration details.", required = true) final VersionedFlowSnapshotEntity requestEntity) throws IOException, LifecycleManagementException { + @ApiParam(value = "The controller service configuration details.", required = true) final VersionedFlowSnapshotEntity requestEntity) { // Verify the request final RevisionDTO revisionDto = requestEntity.getProcessGroupRevision(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 7a1442d630..ca781a4021 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -272,10 +272,10 @@ public final class DtoFactory { actionDto.setId(action.getId()); actionDto.setSourceId(action.getSourceId()); actionDto.setSourceName(action.getSourceName()); - actionDto.setSourceType(action.getSourceType().name()); + actionDto.setSourceType(action.getSourceType().toString()); actionDto.setTimestamp(action.getTimestamp()); actionDto.setUserIdentity(action.getUserIdentity()); - actionDto.setOperation(action.getOperation().name()); + actionDto.setOperation(action.getOperation().toString()); actionDto.setActionDetails(createActionDetailsDto(action.getActionDetails())); actionDto.setComponentDetails(createComponentDetailsDto(action.getComponentDetails())); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java index 1e6167cdde..34f4997457 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java @@ -35,6 +35,7 @@ import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity; import org.apache.nifi.web.api.entity.ActionEntity; import org.apache.nifi.web.api.entity.AffectedComponentEntity; import org.apache.nifi.web.api.entity.AllowableValueEntity; +import org.apache.nifi.web.api.entity.BucketEntity; import org.apache.nifi.web.api.entity.BulletinEntity; import org.apache.nifi.web.api.entity.ComponentReferenceEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; @@ -56,6 +57,8 @@ import org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ProcessorStatusEntity; import org.apache.nifi.web.api.entity.ProcessorStatusSnapshotEntity; +import org.apache.nifi.web.api.entity.RegistryClientEntity; +import org.apache.nifi.web.api.entity.RegistryEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupPortEntity; import org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity; @@ -546,4 +549,43 @@ public final class EntityFactory { entity.setProcessGroupRevision(processGroupRevision); return entity; } + + public RegistryClientEntity createRegistryClientEntity(final RegistryDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) { + final RegistryClientEntity entity = new RegistryClientEntity(); + entity.setRevision(revision); + entity.setPermissions(permissions); + + if (dto != null) { + entity.setId(dto.getId()); + + if (permissions != null && permissions.getCanRead()) { + entity.setComponent(dto); + } + } + + return entity; + } + + public RegistryEntity createRegistryEntity(final RegistryDTO dto) { + final RegistryEntity entity = new RegistryEntity(); + + if (dto != null) { + entity.setRegistry(dto); + } + + return entity; + } + + public BucketEntity createBucketEntity(final BucketDTO dto, final PermissionsDTO permissions) { + final BucketEntity entity = new BucketEntity(); + entity.setId(dto.getId()); + entity.setPermissions(permissions); + + if (permissions != null && permissions.getCanRead()) { + entity.setBucket(dto); + } + + return entity; + } + } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java index 9259bf4c4f..459acfc67f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.dao; +import org.apache.nifi.authorization.user.NiFiUser; import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.controller.service.ControllerServiceState; import org.apache.nifi.groups.ProcessGroup; @@ -118,8 +119,8 @@ public interface ProcessGroupDAO { * update the contents of that Process Group * @return the process group */ - ProcessGroup updateProcessGroupFlow(String groupId, VersionedFlowSnapshot proposedSnapshot, VersionControlInformationDTO versionControlInformation, String componentIdSeed, - boolean verifyNotModified, boolean updateSettings, boolean updateDescendantVersionedFlows); + ProcessGroup updateProcessGroupFlow(String groupId, NiFiUser user, VersionedFlowSnapshot proposedSnapshot, VersionControlInformationDTO versionControlInformation, String componentIdSeed, + boolean verifyNotModified, boolean updateSettings, boolean updateDescendantVersionedFlows); /** * Applies the given Version Control Information to the Process Group @@ -141,10 +142,11 @@ public interface ProcessGroupDAO { /** * Updates the specified variable registry * + * @param user the user performing the update * @param variableRegistry the Variable Registry * @return the Process Group that was updated */ - ProcessGroup updateVariableRegistry(VariableRegistryDTO variableRegistry); + ProcessGroup updateVariableRegistry(NiFiUser user, VariableRegistryDTO variableRegistry); /** * Verifies that the specified updates to a current Process Group can be applied at this time diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java index 4f5af74243..7d3b567231 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java @@ -17,11 +17,6 @@ package org.apache.nifi.web.dao.impl; -import java.io.IOException; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; - import org.apache.nifi.authorization.user.NiFiUser; import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.client.NiFiRegistryException; @@ -36,6 +31,7 @@ import org.apache.nifi.web.dao.RegistryDAO; import java.io.IOException; import java.util.Set; +import java.util.TreeSet; import java.util.stream.Collectors; public class FlowRegistryDAO implements RegistryDAO { @@ -65,7 +61,6 @@ public class FlowRegistryDAO implements RegistryDAO { @Override public Set getFlowRegistriesForUser(final NiFiUser user) { - // TODO - implement to be user specific return getFlowRegistries(); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java index 1aaf4cc5a3..d25f294dfc 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.web.dao.impl; +import org.apache.nifi.authorization.user.NiFiUser; import org.apache.nifi.connectable.Connectable; import org.apache.nifi.connectable.Port; import org.apache.nifi.connectable.Position; @@ -143,7 +144,7 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou } @Override - public CompletableFuture scheduleComponents(final String groupId, final ScheduledState state, final Set componentIds) { + public Future scheduleComponents(final String groupId, final ScheduledState state, final Set componentIds) { final ProcessGroup group = locateProcessGroup(flowController, groupId); CompletableFuture future = CompletableFuture.completedFuture(null); @@ -275,8 +276,9 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou } @Override - public ProcessGroup updateProcessGroupFlow(final String groupId, final VersionedFlowSnapshot proposedSnapshot, final VersionControlInformationDTO versionControlInformation, - final String componentIdSeed, final boolean verifyNotModified, final boolean updateSettings, final boolean updateDescendantVersionedFlows) { + public ProcessGroup updateProcessGroupFlow(final String groupId, final NiFiUser user, final VersionedFlowSnapshot proposedSnapshot, final VersionControlInformationDTO versionControlInformation, + final String componentIdSeed, final boolean verifyNotModified, final boolean updateSettings, final boolean updateDescendantVersionedFlows) { + final ProcessGroup group = locateProcessGroup(flowController, groupId); group.updateFlow(proposedSnapshot, componentIdSeed, verifyNotModified, updateSettings, updateDescendantVersionedFlows); @@ -291,7 +293,7 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou } @Override - public ProcessGroup updateVariableRegistry(final VariableRegistryDTO variableRegistry) { + public ProcessGroup updateVariableRegistry(final NiFiUser user, final VariableRegistryDTO variableRegistry) { final ProcessGroup group = locateProcessGroup(flowController, variableRegistry.getProcessGroupId()); if (group == null) { throw new ResourceNotFoundException("Could not find Process Group with ID " + variableRegistry.getProcessGroupId()); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/variable-configuration.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/variable-configuration.jsp index f26c2ebbdc..4bbd9c8109 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/variable-configuration.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/variable-configuration.jsp @@ -80,6 +80,7 @@ +
Variables do not support sensitive values and will be included when versioning a Process Group.