Class FolderService

java.lang.Object
org.qubership.atp.itf.lite.backend.service.CrudService<Folder>
org.qubership.atp.itf.lite.backend.service.FolderService
All Implemented Interfaces:
EntityHistoryService, IdentifiedService

@Service public class FolderService extends CrudService<Folder> implements EntityHistoryService
  • Constructor Details

    • FolderService

      public FolderService()
  • Method Details

    • repository

      protected org.springframework.data.jpa.repository.JpaRepository<Folder,UUID> repository()
      Specified by:
      repository in class CrudService<Folder>
    • save

      public Folder save(Folder folder)
      Save folder (and update folder children).
      Overrides:
      save in class CrudService<Folder>
      Parameters:
      folder - folder to save
      Returns:
      saved folder
    • saveAll

      public List<Folder> saveAll(List<Folder> folders)
      Save folders (and update folder children).
      Overrides:
      saveAll in class CrudService<Folder>
      Parameters:
      folders - folders to save
      Returns:
      saved folders
    • getFolder

      public Folder getFolder(UUID folderId)
      Get folder by specified identifier.
      Parameters:
      folderId - folder identifier
      Returns:
      folder
    • getSettings

      public Settings getSettings(UUID folderId)
      Get folder by specified identifier.
      Parameters:
      folderId - folder identifier
      Returns:
      folder
    • getPermissionFolderIdsByFolderIds

      public Set<UUID> getPermissionFolderIdsByFolderIds(Set<UUID> folderIds)
      Collects set of permission ids from folders. Need for PreAuthorize checks
      Parameters:
      folderIds - set of folder ids
      Returns:
      set of permission folder ids
    • getFolderByIdAndName

      public List<Folder> getFolderByIdAndName(UUID folderId, String folderName)
    • getFoldersByIds

      public List<Folder> getFoldersByIds(Set<UUID> folderIds)
    • getAllFolders

      public Collection<Folder> getAllFolders(UUID projectId)
      Get all folders by specified project identifier.
      Parameters:
      projectId - project identifier
      Returns:
      collection of folders
    • getAllByProjectIdAndParentId

      public List<Folder> getAllByProjectIdAndParentId(UUID projectId, UUID parentFolderId)
      Gets all folders by specified project id and parent folder id.
      Parameters:
      projectId - project id
      parentFolderId - parent folder id
      Returns:
      list of found folders
    • getFolderRequestsTree

      public GroupResponse getFolderRequestsTree(Boolean onlyFolders, FolderTreeSearchRequest request)
      Get tree for folders and requests by specified search request.
      Parameters:
      request - search request
      Returns:
      tree root nodes
    • getRequestTreeByParentFolderId

      public GroupResponse getRequestTreeByParentFolderId(UUID parentFolderId)
      Get request tree.
    • restore

      public AbstractNamedEntity restore(AbstractNamedEntity entity)
      Specified by:
      restore in interface EntityHistoryService
    • createFolder

      @Transactional public Folder createFolder(FolderUpsetRequest request) throws Exception
      Create folder.
      Parameters:
      request - creation request
      Returns:
      created folder
      Throws:
      Exception
    • setOrder

      public void setOrder(Folder folder)
      Calculate and set order for the folder.
    • createFolders

      public List<Folder> createFolders(List<Folder> folders)
      Create folders from list.
      Parameters:
      folders - list of folders to save
      Returns:
      list of saved folders
    • editFolder

      @Transactional public Folder editFolder(UUID folderId, FolderEditRequest request) throws Exception
      Update folder.
      Parameters:
      folderId - folder identifier
      request - update folder request
      Throws:
      Exception
    • updateAuthorizationFolderId

      public void updateAuthorizationFolderId(Request request)
      Updates InheritAuthorizationRequest.
      Parameters:
      request - request to update
    • updateAuthorizationFolderId

      public void updateAuthorizationFolderId(Folder folder)
      Updates InheritAuthorizationRequest.
      Parameters:
      folder - folder to update
    • updateAuthorizationFolderId

      public void updateAuthorizationFolderId(@Nullable RequestAuthorization authorization, @Nullable UUID parentFolderId)
      Updates InheritAuthorizationRequest.
      Parameters:
      authorization - authorization to update
      parentFolderId - parent folder id for entity with passed authorization
    • copyFolders

      @Transactional public void copyFolders(FolderCopyRequest request)
      Copy folder.
      Parameters:
      request - copy folder request
    • addPostfixIfFolderNameInDestinationIsTaken

      public void addPostfixIfFolderNameInDestinationIsTaken(List<Folder> destinationFolders, Folder folder)
      Add postfix "Copy" if folder with the same name already exists in destination folder.
      Parameters:
      destinationFolders - list of folders destination under folder
      folder - folder
    • moveFolders

      @Transactional public void moveFolders(FolderMoveRequest request)
      Move folder.
      Parameters:
      request - move folder request
    • deleteFolders

      @Transactional public void deleteFolders(FolderDeleteRequest request)
      Delete folders.
      Parameters:
      request - delete folders request
    • checkThatAccessGranted

      public void checkThatAccessGranted(UUID projectId, Set<UUID> folderPermissionsIds, org.qubership.atp.auth.springbootstarter.entities.Operation operation)
      Check that access granted for operation.
      Parameters:
      projectId - project id.
      folderPermissionsIds - folder permissions.
      operation - operation for which permissions are required (CREATE,READ,UPDATE,DELETE,EXECUTE,LOCK,UNLOCK).
      Throws:
      ItfLiteAccessDeniedException - if no access granted.
    • countFolderHeirs

      public long countFolderHeirs(FolderDeleteRequest request)
      Find folders heirs.
      Parameters:
      request - count folders heirs in delete request
    • order

      public void order(UUID folderId, FolderOrderChangeRequest request)
      Change folder order.
    • getByProjectIdAndSourceId

      public Folder getByProjectIdAndSourceId(UUID projectId, UUID sourceId)
      Get Folder by project ID and source ID.
      Parameters:
      projectId - project ID
      sourceId - source ID
      Returns:
      Folder
    • getIdByFoldersPath

      public UUID getIdByFoldersPath(UUID projectId, List<String> path)
      Get ids by folder's path.
    • getParentAuth

      public ParentRequestAuthorization getParentAuth(@Nullable UUID parentFolderId)
      Get parent auth for folder or request with specified parent folder id.
      Parameters:
      parentFolderId - paren folder id
      Returns:
      parent auth
    • updateParentFolderChildren

      public Folder updateParentFolderChildren(UUID folderId)
      Update folder children (for parent folder): child folders and child request. Need for history.
      Parameters:
      folderId - folder ID of entity
      Returns:
      updated folder or NULL folder not found
    • updateParentFolderChildren

      public Folder updateParentFolderChildren(Folder folder)
      Update folder children (for parent folder): child folders and child request. Need for history.
      Parameters:
      folder - folder entity
      Returns:
      updated folder
    • updateParentFolderChildren

      public List<Folder> updateParentFolderChildren(List<Folder> folders)
      Update folders children (for parent folder): child folders and child request. Need for history.
      Parameters:
      folders - folder entity
      Returns:
      updated folder
    • updateFolderChildren

      public Folder updateFolderChildren(UUID folderId)
      Update folder children: child folders and child request. Need for history.
      Parameters:
      folderId - folder ID of entity
      Returns:
      updated folder or NULL if folderId = NULL or folder not found
    • updateFolderChildren

      public Folder updateFolderChildren(Folder folder)
      Update folder children: child folders and child request. Need for history.
      Parameters:
      folder - folder entity
      Returns:
      updated folder
    • updateFoldersChildren

      public List<Folder> updateFoldersChildren(List<Folder> folders)
      Update folders children: child folders and child request. Need for history.
      Parameters:
      folders - folder entity
      Returns:
      updated folder