Class AccessUtil

java.lang.Object
de.espirit.firstspirit.access.AccessUtil

public class AccessUtil extends Object
Utitly class providing methods for Access-API operations like server release, server delete
Since:
2.3.17
  • Constructor Details

    • AccessUtil

      public AccessUtil()
  • Method Details

    • copyStoreElement

      public static <T extends StoreElement> T copyStoreElement(T element, StoreElement parent) throws IOException
      Creates a copy of the given element below the parent.
      Parameters:
      element - The element to copy
      parent - The parent of the new element
      Returns:
      The new StoreElement
      Throws:
      IOException - thrown during temp-file operations.
      Since:
      4.0.17
    • copyStoreElement

      public static <T extends StoreElement> T copyStoreElement(T element, StoreElement parent, boolean checkRules) throws IOException
      Creates a copy of the given element below the parent.
      Parameters:
      element - The element to copy
      parent - The parent of the new element
      checkRules - Whether the rules should be checked when saving or not
      Returns:
      The new StoreElement
      Throws:
      IOException - thrown during temp-file operations.
      Since:
      5.2.210902
    • cleanUpName

      public static String cleanUpName(String name)
      Remove illegal chars from a name.
      Parameters:
      name - The name
      Returns:
      name without illegal chars
      Since:
      3.0.112
    • release

      @Deprecated public static ServerActionHandle<? extends ReleaseProgress,Boolean> release(IDProvider toRelease, boolean checkOnly)
      Deprecated.
      use ReleaseOperation instead ; since 5.2.180606
      Performs the default release on the server for the given IDProvider and following type specific options:
      Parameters:
      toRelease - the startnode of release
      checkOnly - if true release would not be processed
      Returns:
      the handle to the belonging server action which is started on the server
      Throws:
      IllegalArgumentException - if given releaseStartNode doesn't support release
      Since:
      4.0.13
    • release

      @Deprecated public static ServerActionHandle<? extends ReleaseProgress,Boolean> release(IDProvider toRelease, boolean checkOnly, String comment)
      Deprecated.
      use ReleaseOperation instead ; since 5.2.180606
      Performs the default release on the server for the given IDProvider and following type specific options:
      Parameters:
      toRelease - the startnode of release
      checkOnly - if true release would not be processed
      comment - the release comment, may be null
      Returns:
      the handle to the belonging server action which is started on the server
      Throws:
      IllegalArgumentException - if given releaseStartNode doesn't support release
      Since:
      4.0.120
    • release

      @Deprecated public static ServerActionHandle<? extends ReleaseProgress,Boolean> release(IDProvider releaseStartNode, boolean checkOnly, boolean ensureAccessibility, boolean recursive, IDProvider.DependentReleaseType dependentType)
      Deprecated.
      use ReleaseOperation instead ; since 5.2.180606
      Starts the server release action for the given element with the given release options.
      Parameters:
      releaseStartNode - the startnode of the release
      checkOnly - if true release would not be processed
      ensureAccessibility - if true each element on the parent path of the given releaseStartNode will be released which has never been released
      recursive - if true the subtree of given releaseStartNode will be released recursive
      dependentType - the dependent type specifying the behaviour for referenced elements of the given releaseStartNode (see IDProvider.DependentReleaseType for details) if null then IDProvider.DependentReleaseType.NO_DEPENDENT_RELEASE is used
      Returns:
      the handle to the belonging server action which is started on the server
      Throws:
      IllegalArgumentException - if given releaseStartNode doesn't support release
      Since:
      4.0.13
      See Also:
    • release

      @Deprecated public static ServerActionHandle<? extends ReleaseProgress,Boolean> release(IDProvider releaseStartNode, boolean checkOnly, boolean ensureAccessibility, boolean recursive, IDProvider.DependentReleaseType dependentType, String comment)
      Deprecated.
      use ReleaseOperation instead ; since 5.2.180606
      Starts the server release action for the given element with the given release options.
      Parameters:
      releaseStartNode - the startnode of the release
      checkOnly - if true release would not be processed
      ensureAccessibility - if true each element on the parent path of the given releaseStartNode will be released which has never been released
      dependentType - the dependent type specifying the behaviour for referenced elements of the given releaseStartNode (see IDProvider.DependentReleaseType for details) if null then IDProvider.DependentReleaseType.NO_DEPENDENT_RELEASE is used
      comment - the release comment, may be null
      Returns:
      the handle to the belonging server action which is started on the server
      Throws:
      IllegalArgumentException - if given releaseStartNode doesn't support release
      Since:
      4.0.120
      See Also:
    • restore

      public static ServerActionHandle<? extends RestoreProgress,Boolean> restore(@NotNull @NotNull IDProvider newParent, @NotNull @NotNull ElementInfo elementInfo, boolean restoreParentIfNecessary, boolean ignoreMissingReferencedObjects, boolean checkOnlyMode) throws WorkflowLockException
      Starts a restore action on the server, which restores the deleted element specified by the given elementInfo
      Parameters:
      newParent - the parent node, the restored node should be added as child
      checkOnlyMode - use false to test the restore of the element, progress of returned handle will contain infos about the restore test
      Returns:
      a server action handle to the server restore action
      Throws:
      WorkflowLockException
      Since:
      4.0.57
      See Also:
    • revert

      public static ServerActionHandle<? extends RevertProgress,Boolean> revert(IDProvider element, Revision revision, boolean recursive, EnumSet<IDProvider.RevertType> ignoreRevertTypes, boolean ignoreMissingReferencedObjects, boolean checkOnlyMode) throws WorkflowLockException
      Reverts an element of type IDProvider to a specific revision.
      Parameters:
      element - Element to be reverted.
      revision - Revision object that specifies the revision that the element should be reverted to.
      recursive - If true, elements will be reverted recursive. If false, only the given element will be reverted.
      ignoreRevertTypes - Set of IDProvider.RevertType that specifies attributes and elements that should not be reverted. If this set does not contain IDProvider.RevertType.CHILD_LIST, i.e. children should be reverted as well, recursive will be set to true.
      ignoreMissingReferencedObjects - If true the element will be reverted even if a referenced element can not be found. If false, a missing referenced element will cause the revert operation to fail.
      checkOnlyMode - If true, the element will not actually be reverted. Instead only all preconditions will be checked and violations will be reported. If false and all preconditions are met, the element will actually be reverted.
      Returns:
      the handle to the belonging server action which is started on the server.
      Throws:
      WorkflowLockException - if the given element is locked by a workflow
      Since:
      4.0.120
    • delete

      @Deprecated public static ServerActionHandle<? extends DeleteProgress,Boolean> delete(IDProvider element, boolean ignoreIncomingReferences)
      Deprecated.
      use DeleteOperation instead ; since 5.2.1804
      Deletes the subtree specified by the given element on the server. The strategy is to delete as much as possible. Elements which couldn't be deleted because of missing permissions, lock failed, incoming references, etc. will be skipped.
      Parameters:
      element - the element to delete
      ignoreIncomingReferences - use true to delete elements ignoring incoming references, if false elements which are referenced will be skipped
      Returns:
      The action handle.
      Throws:
      IllegalArgumentException - if given element is a Dataset
      Since:
      4.0.120
    • delete

      @Deprecated public static ServerActionHandle<? extends DeleteProgress,Boolean> delete(Collection<IDProvider> elements, boolean ignoreIncomingReferences)
      Deprecated.
      use DeleteOperation instead ; since 5.2.1804
      Deletes all elements on the server. The strategy is to delete as much as possible. Elements which couldn't be deleted because of missing permissions, lock failed, incoming references, etc. will be skipped.
      Parameters:
      elements - the elements to delete
      ignoreIncomingReferences - use true to delete elements ignoring incoming references, if false elements which are referenced will be skipped
      Returns:
      The action handle.
      Throws:
      IllegalArgumentException - if one of the given elements is a Dataset
      Since:
      5.0.34
    • getLanguageForKey

      public static Language getLanguageForKey(Project project, String languageKey)
      Gets a single project language by its unique abbreviation. Returns null if no language with the given abbreviation can be found.
      Parameters:
      project - Languages of this project will be searched for the sought language.
      languageKey - Unique abbreviation of the sought language.
      Returns:
      Project language that corresponds to the given abbreviation or null, if no such language can be found.
      Since:
      4.0.17
    • getLanguageForKeyNotNull

      @NotNull public static @NotNull Language getLanguageForKeyNotNull(Project project, String languageKey)
      Gets a single project language by its unique abbreviation. Throws an IllegalArgumentException if no language with the given abbreviation can be found.
      Parameters:
      project - Languages of this project will be searched for the sought language.
      languageKey - Unique abbreviation of the sought language.
      Returns:
      Project language that corresponds to the given abbreviation.
      Throws:
      IllegalArgumentException - if no language with the given abbreviation can be found.
      Since:
      4.0.41
    • executeProcess

      public static int executeProcess(Writer out, Writer err, String... command) throws IOException
      Execute a programm in a native process.
      Parameters:
      out - the output writer the process will append its output to. Writer will be closed after execution.
      err - the error writer the process will append its error output to. Writer will be closed after execution.
      command - the program and its arguments
      Returns:
      the exit code of the process
      Throws:
      IOException - if process creation fails
      Since:
      4.0.19