Class VcsUtil


  • public class VcsUtil
    extends Object
    Various utility methods for VcsRoot
    Since:
    8.0
    Author:
    kir
    • Constructor Detail

      • VcsUtil

        public VcsUtil()
    • Method Detail

      • areEquivalentRoots

        public static boolean areEquivalentRoots​(@Nullable
                                                 VcsRoot root1,
                                                 @Nullable
                                                 VcsRoot root2)
        Checks whether the specified VCS roots are equivalent. VCS roots are considered equivalent if they both represent same VcsSupport and contain same properties.
        Parameters:
        root1 - VCS root
        root2 - VCS root
        Returns:
        true if roots are equivalent
      • getVcsRootPublicProperties

        @NotNull
        public static Map<String,​String> getVcsRootPublicProperties​(@NotNull
                                                                          VcsRoot root)
        Returns:
        return VcsRoot properties filtering secured once
        Since:
        8.1
      • getVcsRootPropertiesHash

        public static long getVcsRootPropertiesHash​(@NotNull
                                                    VcsRoot root)
        Returns:
        hash of properties of given VcsRoot
        Since:
        8.1
      • getVcsRootPropertiesAsPresentableString

        @NotNull
        public static String getVcsRootPropertiesAsPresentableString​(@NotNull
                                                                     VcsRoot root)
        Returns:
        string presentation for given VCS root
        Since:
        8.2
      • convertVcsRootToString

        @NotNull
        public static String convertVcsRootToString​(@NotNull
                                                    VcsRoot root)
        Serializes VCS root contents without id to string. Secured values are scrambled during conversion. If you need to use encryption please @see #convertVcsRootToString(VcsRoot, Function)
        Parameters:
        root - root to serialize
        Returns:
        string representation
        See Also:
        convertStringToVcsRoot(long, String)
      • convertVcsRootToString

        @NotNull
        public static String convertVcsRootToString​(@NotNull
                                                    VcsRoot root,
                                                    Function<String,​String> encode)
        Serializes VCS root contents without id to string
        Parameters:
        root - root to serialize
        encode - function to transform secured values
        Returns:
        string representation
        Since:
        2020.1
        See Also:
        convertStringToVcsRoot(long, String)
      • getSimplifiedName

        @NotNull
        public static String getSimplifiedName​(@NotNull
                                               VcsRoot vcsRoot)
        Parameters:
        vcsRoot - VcsRoot for which we need normalized name
        Returns:
        symbolic normalized name of the VcsRoot
      • isSecureProperty

        public static boolean isSecureProperty​(@NotNull
                                               String propertyName)
        Returns true if the property is secure, i.e. its value should be scrambled when property persisted.
        Parameters:
        propertyName - property name.
        Returns:
        true if property value should be scrambled.
      • propertiesToString

        @NotNull
        public static String propertiesToString​(@NotNull
                                                Map<String,​String> properties,
                                                boolean scrambleSecureProps)
        Converts properties set to string, with optional scrambling of the secured properties
        Parameters:
        properties - map of properties values.
        scrambleSecureProps - if true, secure properties will be scrambled to avoid their reading in plain text
        Returns:
        string properties presentation.
        See Also:
        stringToProperties(String), VcsRoot.SECURE_PROPERTY_PREFIX
      • propertiesToString

        @NotNull
        public static String propertiesToString​(@NotNull
                                                Map<String,​String> properties)
        Converts properties set to string, without any transformation of the secured properties
        Parameters:
        properties - map of properties values.
        Returns:
        string properties presentation.
        See Also:
        stringToProperties(String)
      • stringToProperties

        @NotNull
        public static Map<String,​String> stringToProperties​(String string)
        Converts string to map of properties.
        Parameters:
        string - original string.
        Returns:
        map of properties.
        See Also:
        VcsUtil#propertiesToStringSecure(java.util.Map, boolean)
      • stringToProperties

        @NotNull
        public static Map<String,​String> stringToProperties​(String string,
                                                                  boolean unscrambleSecureProps)
        Converts string to map of properties.
        Parameters:
        string - original string.
        unscrambleSecureProps - if true, will try to unscramble secure properties
        Returns:
        map of properties.
        Since:
        2018.2
        See Also:
        propertiesToString(java.util.Map, boolean)
      • stringToPropertiesAsIs

        @NotNull
        public static Map<String,​String> stringToPropertiesAsIs​(String string)
        Converts string to map of properties.
        Parameters:
        string - original string.
        Returns:
        map of properties.
        Since:
        2020.1
        See Also:
        VcsUtil#propertiesToStringSecure(java.util.Map, boolean)
      • isSet

        public static boolean isSet​(@NotNull
                                    VcsRoot root,
                                    String propertyName)
        Returns:
        true if property option is set in the VcsRoot
        Since:
        10.0