Class Utils

java.lang.Object
org.wso2.carbon.server.util.Utils

public class Utils extends Object
  • Field Details

    • JAR_TO_BUNDLE_DIR

      public static final String JAR_TO_BUNDLE_DIR
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • getCarbonRepoPath

      public static String getCarbonRepoPath()
    • getCarbonComponentRepo

      public static File getCarbonComponentRepo()
    • printUsages

      public static void printUsages()
    • searchFor

      public static String searchFor(String target, String start)
    • getArgs

      public static String[] getArgs()
    • getBundleDirectory

      public static File getBundleDirectory(String bundleDir)
      Create invalid input: '&' return the bundle directory
      Parameters:
      bundleDir - The relative path of directory which contains the jars to be made into bundles
      Returns:
      The bundle directory
    • createBundle

      public static void createBundle(File jarFile, File targetDir, Manifest mf, String extensionPrefix) throws IOException
      Create an OSGi bundle out of a JAR file
      Parameters:
      jarFile - The jarfile to be bundled
      targetDir - The directory into which the created OSGi bundle needs to be placed into.
      mf - The bundle manifest file
      extensionPrefix - Prefix, if any, for the bundle
      Throws:
      IOException - If an error occurs while reading the jar or creating the bundle
    • createBundle

      public static void createBundle(File jarFile, File bundle, Manifest manifest) throws IOException
      Create an OSGi bundle out of a JAR file
      Parameters:
      jarFile - The jarfile to be bundled
      bundle - The bundle to be created
      manifest - The manifest file
      Throws:
      IOException - If an error occurs while reading the jar or creating the bundle
    • deleteDir

      public static boolean deleteDir(File dir)
      Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.
    • archiveDir

      public static void archiveDir(String destArchive, String sourceDir) throws IOException
      Archive a directory
      Parameters:
      destArchive -
      sourceDir -
      Throws:
      IOException
    • zipDir

      protected static void zipDir(File zipDir, ZipOutputStream zos, String archiveSourceDir) throws IOException
      Throws:
      IOException
    • getZipEntryPath

      protected static String getZipEntryPath(File f, String archiveSourceDir)
    • copyFileToDir

      public static void copyFileToDir(File src, File dst) throws IOException
      Copies src file to dst directory. If the dst directory does not exist, it is created
      Throws:
      IOException
    • copyFile

      public static void copyFile(File src, File dst) throws IOException
      Copies src file to dst file. If the dst file does not exist, it is created
      Throws:
      IOException
    • extract

      public static void extract(String archive, String extractDir) throws IOException
      Throws:
      IOException
    • extractFromStream

      public static void extractFromStream(InputStream inputStream, String extractDir) throws IOException
      Throws:
      IOException
    • parseJar

      public static String parseJar(File jarFile) throws IOException
      Parameters:
      jarFile - jar file location
      Returns:
      package name list separated by ","
      Throws:
      IOException - IOException
    • getBundleConfigDirectory

      public static File getBundleConfigDirectory()
    • clearPrefixedSystemProperties

      public static void clearPrefixedSystemProperties(String prefix, Map<String,String> targetPropertyMap)
      clearPrefixedSystemProperties clears System Properties by writing null properties in the targetPropertyMap that match a prefix
      Parameters:
      prefix - prefix
      targetPropertyMap - targetPropertyMap
    • loadProperties

      public static Properties loadProperties(String filePath)
      loadProperties is a convenience method to load properties from a servlet context resource
      Parameters:
      filePath - - path to load properties from
      Returns:
      the properties