kevdoran commented on a change in pull request #230: NIFIREG-321 Integrate revision concept into UI, REST API, and service… URL: https://github.com/apache/nifi-registry/pull/230#discussion_r334153793
########## File path: nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/service/StandardServiceFacade.java ########## @@ -0,0 +1,1099 @@ +/* + * 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.registry.web.service; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.registry.RegistryConfiguration; +import org.apache.nifi.registry.authorization.AccessPolicy; +import org.apache.nifi.registry.authorization.CurrentUser; +import org.apache.nifi.registry.authorization.Resource; +import org.apache.nifi.registry.authorization.User; +import org.apache.nifi.registry.authorization.UserGroup; +import org.apache.nifi.registry.bucket.Bucket; +import org.apache.nifi.registry.bucket.BucketItem; +import org.apache.nifi.registry.diff.VersionedFlowDifference; +import org.apache.nifi.registry.extension.bundle.Bundle; +import org.apache.nifi.registry.extension.bundle.BundleFilterParams; +import org.apache.nifi.registry.extension.bundle.BundleType; +import org.apache.nifi.registry.extension.bundle.BundleVersion; +import org.apache.nifi.registry.extension.bundle.BundleVersionFilterParams; +import org.apache.nifi.registry.extension.bundle.BundleVersionMetadata; +import org.apache.nifi.registry.extension.component.ExtensionFilterParams; +import org.apache.nifi.registry.extension.component.ExtensionMetadata; +import org.apache.nifi.registry.extension.component.TagCount; +import org.apache.nifi.registry.extension.component.manifest.Extension; +import org.apache.nifi.registry.extension.component.manifest.ProvidedServiceAPI; +import org.apache.nifi.registry.extension.repo.ExtensionRepoArtifact; +import org.apache.nifi.registry.extension.repo.ExtensionRepoBucket; +import org.apache.nifi.registry.extension.repo.ExtensionRepoExtensionMetadata; +import org.apache.nifi.registry.extension.repo.ExtensionRepoGroup; +import org.apache.nifi.registry.extension.repo.ExtensionRepoVersion; +import org.apache.nifi.registry.extension.repo.ExtensionRepoVersionSummary; +import org.apache.nifi.registry.flow.VersionedFlow; +import org.apache.nifi.registry.flow.VersionedFlowSnapshot; +import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; +import org.apache.nifi.registry.revision.entity.RevisableEntity; +import org.apache.nifi.registry.revision.entity.RevisableEntityService; +import org.apache.nifi.registry.revision.entity.RevisionInfo; +import org.apache.nifi.registry.security.authorization.AuthorizableLookup; +import org.apache.nifi.registry.security.authorization.RequestAction; +import org.apache.nifi.registry.security.authorization.exception.AccessDeniedException; +import org.apache.nifi.registry.security.authorization.resource.Authorizable; +import org.apache.nifi.registry.security.authorization.resource.ResourceType; +import org.apache.nifi.registry.security.authorization.user.NiFiUserUtils; +import org.apache.nifi.registry.service.AuthorizationService; +import org.apache.nifi.registry.service.RegistryService; +import org.apache.nifi.registry.service.extension.ExtensionService; +import org.apache.nifi.registry.web.link.LinkService; +import org.apache.nifi.registry.web.security.PermissionsService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Transactional; + +import javax.ws.rs.core.Link; +import javax.ws.rs.core.StreamingOutput; +import javax.ws.rs.core.UriBuilder; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.SortedSet; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * A wrapper around the service layer that applies validation, authorization, and revision management to all services. + * + * All REST resources should access the service layer through this facade. + */ +@Service +@Transactional(isolation = Isolation.READ_COMMITTED, rollbackFor = Throwable.class) +public class StandardServiceFacade implements ServiceFacade { + + public static final String USER_GROUP_ENTITY_TYPE = "User Group"; + public static final String USER_ENTITY_TYPE = "User"; + public static final String ACCESS_POLICY_ENTITY_TYPE = "Access Policy"; + public static final String VERSIONED_FLOW_ENTITY_TYPE = "Versioned Flow"; + public static final String BUCKET_ENTITY_TYPE = "Bucket"; + private final RegistryService registryService; + private final ExtensionService extensionService; + private final AuthorizationService authorizationService; + private final AuthorizableLookup authorizableLookup; + private final RevisableEntityService entityService; + private final PermissionsService permissionsService; + private final LinkService linkService; + + public StandardServiceFacade(final RegistryService registryService, Review comment: Again, very minor. I know it is no longer required by Spring, but we have generally been explicit in our use of the `@Autowired` annotation on constructors. Just pointing it out in case in case you meant to include it, but also fine with it as is or if we would like to change our convention to allowing implicit autowiring going forward. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
