public class GatewayCmdUtils extends Object
| Constructor and Description |
|---|
GatewayCmdUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copyFilesToSources(String sourcePath,
String destinationPath)
Copy files to resources directory
|
static void |
copyFolder(String source,
String destination)
This function recursively copy all the sub folder and files from source to destination file paths
|
static void |
createDeploymentConfig(String projectName,
String deploymentConfPath)
Create initial deployment configuration file.
|
static void |
createProjectGWDistribution(String projectName)
Create a micro gateway distribution for the provided project name
|
static void |
createProjectStructure(String projectName)
Create a project structure for a particular project name.
|
static CliLauncherException |
createUsageException(String errorMsg)
Create usage exception
|
static String |
decrypt(String value,
String secret)
Decrypt given value with provided secret
|
static void |
deleteProject(String projectPath)
Delete project folder
|
static String |
encrypt(String value,
String secret)
Encrypt given value with provided secret
|
static String |
getCLIHome()
Get cli home location
|
static String |
getCLILibHashHolderFileLocation()
Get library zip files hash holder file path with in the CLI tool
|
static String |
getCLILibPath()
Get cli library location
|
static CodeGenerationContext |
getCodeGenerationContext() |
static Config |
getConfig() |
static ContainerConfig |
getContainerConfig() |
static APICorsConfigurationDTO |
getDefaultCorsConfig() |
static String |
getDeploymentConfigLocation(String projectName)
Returns location of the deployment configuration file of given project
|
static Etcd |
getEtcd() |
static String |
getFiltersFolderLocation()
Get filters folder location
|
static String |
getLoggingPropertiesFileLocation()
Get resources file directory path
|
static String |
getMainConfigLocation()
Returns location of the main configuration file of given project root
|
static String |
getPoliciesFolderLocation()
Get policies folder location
|
static String |
getProjectDirectoryPath(String projectName)
Returns path to the given project in the current working directory
|
static String |
getProjectGrpcDirectoryPath()
Returns path to the /grpc_service/client of a given project in the current working directory
|
static String |
getProjectGrpcSoloDirectoryPath()
Returns path to the /grpc_service of a given project in the current working directory
|
static String |
getProjectName(List<String> mainArgs)
Validate the list of main args and returns the first element as the project name
|
static String |
getProjectSrcDirectoryPath(String projectName)
Returns path to the /src of a given project in the current working directory
|
static String |
getResourceFolderLocation()
Get resources file directory path
|
static String |
getUnixPath(String path)
Replace backslashes `\` in windows path string with forward slashes `/`
|
static String |
getUserDir()
Returns current user dir
|
static String |
loadStoredResourceHashes(String projectName)
Load the stored resource hash content from the CLI temp folder
|
static String |
makeFirstLetterLowerCase(String s)
Convert first letter to lower case
|
static String |
readFileAsString(String path,
boolean inResource)
Read file as string
|
static Map<String,String> |
readFileToMap(String filePath)
Read the deserialize file content to map
|
static void |
saveConfig(Config config,
String configPath) |
static void |
setCodeGenerationContext(CodeGenerationContext codeGenerationContext) |
static void |
setConfig(Config configFromFile) |
static void |
setContainerConfig(ContainerConfig containerConfig) |
static void |
setEtcd(Etcd etcd) |
static void |
storeResourceHashesFileContent(String content,
String projectName)
Saves the resource hash content to the CLI temp folder
|
static void |
writeMapToFile(Map<String,String> map,
String filePath)
Writes the map after serializing to given path
|
public static Etcd getEtcd()
public static void setEtcd(Etcd etcd)
public static Config getConfig()
public static void setConfig(Config configFromFile)
public static CodeGenerationContext getCodeGenerationContext()
public static void setCodeGenerationContext(CodeGenerationContext codeGenerationContext)
public static String readFileAsString(String path, boolean inResource) throws IOException
path - to the fileinResource - whether file is in resources directory of jar or notIOException - if file read went wrongpublic static CliLauncherException createUsageException(String errorMsg)
errorMsg - error messagepublic static String makeFirstLetterLowerCase(String s)
s - stringpublic static String encrypt(String value, String secret)
value - value to encryptsecret - encryption keypublic static String decrypt(String value, String secret)
value - value to decryptsecret - decryption keypublic static String getUserDir()
public static String getCLIHome()
public static String getCLILibPath()
public static String getResourceFolderLocation()
public static String getLoggingPropertiesFileLocation()
public static String getFiltersFolderLocation()
public static String getPoliciesFolderLocation()
public static void createProjectStructure(String projectName)
projectName - name of the projectpublic static void createProjectGWDistribution(String projectName) throws IOException
projectName - name of the projectIOException - error while creating micro gateway distributionpublic static String loadStoredResourceHashes(String projectName) throws IOException
projectName - name of the projectIOException - error while loading stored resource hash contentpublic static void storeResourceHashesFileContent(String content, String projectName) throws IOException
content - resource hash contentprojectName - name of the projectIOException - error while saving resource hash contentpublic static String getProjectName(List<String> mainArgs)
mainArgs - List of main args provided to the commandpublic static String getCLILibHashHolderFileLocation()
public static String getMainConfigLocation()
public static String getDeploymentConfigLocation(String projectName)
projectName - name of the projectpublic static String getProjectDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectSrcDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectGrpcDirectoryPath()
public static String getProjectGrpcSoloDirectoryPath()
public static void copyFolder(String source, String destination) throws IOException
source - source locationdestination - destination locationIOException - error while copying folder to destinationpublic static void copyFilesToSources(String sourcePath, String destinationPath) throws IOException
sourcePath - source directory pathdestinationPath - destionation directory pathIOException - if file copy went wrongpublic static void createDeploymentConfig(String projectName, String deploymentConfPath) throws IOException
projectName - project namedeploymentConfPath - path to deployment configIOException - if file create went wrongpublic static ContainerConfig getContainerConfig()
public static void setContainerConfig(ContainerConfig containerConfig)
public static APICorsConfigurationDTO getDefaultCorsConfig()
public static String getUnixPath(String path)
path - Location of a resource (file or directory)public static void deleteProject(String projectPath)
projectPath - project pathpublic static void writeMapToFile(Map<String,String> map, String filePath) throws IOException
map - resource hash content
* @param filePath file path the map should be written toIOException - error while saving resource hash contentpublic static Map<String,String> readFileToMap(String filePath) throws IOException, ClassNotFoundException
filePath - file path the map should be written toIOException - error while saving resource hash contentClassNotFoundExceptionCopyright © 2019 WSO2. All rights reserved.