public class GatewayCmdUtils extends Object
| Constructor and Description |
|---|
GatewayCmdUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
copyAndReplaceFolder(String source,
String destination)
This function deletes the existing destination folder and recursively copy all the sub folder and files from
source to destination file paths.
|
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 File |
createDirectory(String path,
boolean overwrite)
Creates a new folder if not exists
|
static File |
createFile(String path,
String fileName,
boolean overwrite)
Create new file in a given location.
|
static void |
createGenDirectoryStructure(String genDirPath)
Create directory structure for projects /gen directory.
|
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 |
getCLILibPath()
Get cli library location
|
static CodeGenerationContext |
getCodeGenerationContext() |
static Config |
getConfig() |
static ContainerConfig |
getContainerConfig() |
static APICorsConfigurationDTO |
getDefaultCorsConfig() |
static String |
getDefinitionsLocation()
Get filters folder location
|
static String |
getDeploymentConfigLocation(String projectName)
Returns location of the deployment configuration file of given project
|
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 |
getProjectAPIFilesDirectoryPath(String projectName)
Returns path to the /API-Files of a given project in the current working directory
|
static String |
getProjectDirectoryPath(String projectName)
Returns path to the given project in the current working directory
|
static String |
getProjectExtensionsDirectoryPath(String projectName)
Returns path to the /extensions of a given project in the current working directory
|
static String |
getProjectGenAPIDefinitionPath(String projectName)
Returns path to the /gen/api-definition of a given project in the current working directory
|
static String |
getProjectGenDirectoryPath(String projectName)
Returns path to the /gen of a given project in the current working directory
|
static String |
getProjectGenSrcDirectoryPath(String projectName)
Returns path to the /gen/src of a given project in the current working directory
|
static String |
getProjectGenSrcInterceptorsDirectoryPath(String projectName)
Returns path to the /gen/src/interceptors of a given project in the current working directory
|
static String |
getProjectGenSwaggerPath(String projectName,
String apiId)
Returns path to the /gen/api-definition of a given project in the current working directory
|
static String |
getProjectGenSwaggerPath(String projectName,
String apiId,
String extensionType)
Returns path to the /gen/api-definition of a 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 |
getProjectInterceptorsDirectoryPath(String projectName)
Returns path to the /interceptors of a given project in the current working directory
|
static String |
getProjectSwaggerFilePath(String projectName,
String apiId)
Returns the path to the swagger for a defined version of an API
|
static String |
getProjectTargetGenDirectoryPath(String projectName)
Returns path to the /target/gen 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 void |
printVerbose(String msg)
To print the message if verbose flag is set
|
static String |
promptForTextInput(PrintStream outStream,
String msg)
Prompts for a test input.
|
static String |
readFileAsString(String path,
boolean inResource)
Read file as string
|
static void |
saveConfig(Config config,
String configPath) |
static void |
saveSwaggerDefinition(String projectName,
String apiDefinition,
String apiId,
String extension)
Save openAPI definition (developer first approach)
|
static void |
saveSwaggerDefinitionForMultipleAPIs(String projectName,
List<ExtendedAPI> apis)
Save swagger definition for multiple APIs.
|
static void |
setCodeGenerationContext(CodeGenerationContext codeGenerationContext) |
static void |
setConfig(Config configFromFile) |
static void |
setContainerConfig(ContainerConfig containerConfig) |
static void |
storeResourceHashesFileContent(String content,
String projectName)
Saves the resource hash content to the CLI temp folder
|
static void |
writeContent(String content,
File file)
Write content to a specified file
|
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 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 getDefinitionsLocation()
public static String getFiltersFolderLocation()
public static void createProjectStructure(String projectName) throws IOException
projectName - name of the projectIOExceptionpublic static void saveSwaggerDefinition(String projectName, String apiDefinition, String apiId, String extension)
projectName - project nameapiDefinition - api Definition as Stringpublic static void saveSwaggerDefinitionForMultipleAPIs(String projectName, List<ExtendedAPI> apis)
projectName - project nameapis - API object Listpublic 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 getMainConfigLocation()
public static String getDeploymentConfigLocation(String projectName)
projectName - name of the projectpublic static String getProjectDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectGenDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectTargetGenDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectGenSrcDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectExtensionsDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectInterceptorsDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectGenSrcInterceptorsDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectGenSwaggerPath(String projectName, String apiId, String extensionType)
projectName - name of the projectapiId - md5 hash value of apiName:apiVersionextensionType - The file extension type. (ex : yaml or json)public static String getProjectGenSwaggerPath(String projectName, String apiId)
projectName - name of the projectapiId - md5 hash value of apiName:apiVersion
* @return path to the /gen/api-definition of a given project in the current working directorypublic static String getProjectGenAPIDefinitionPath(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 copyAndReplaceFolder(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 File createDirectory(String path, boolean overwrite) throws IOException
path - folder pathoverwrite - if `true` existing directory will be removed
and new directory will be created in path.IOException - Failed delete or create the directory in pathpublic static File createFile(String path, String fileName, boolean overwrite) throws IOException
path - location of the new file.overwrite - if `true` existing file with the same name will be replaced.fileName - name of the new file.IOException - Failed delete or create the file in pathpublic static void writeContent(String content, File file) throws IOException
content - content to be writtenfile - file object initialized with pathIOException - error while writing content to filepublic 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 String promptForTextInput(PrintStream outStream, String msg)
outStream - Print Streammsg - messagepublic static void createGenDirectoryStructure(String genDirPath) throws IOException
genDirPath - path to project's /gen directoryIOExceptionpublic static String getProjectAPIFilesDirectoryPath(String projectName)
projectName - name of the projectpublic static String getProjectSwaggerFilePath(String projectName, String apiId)
projectName - name of the projectapiId - md5 hash value of apiName:apiVersionpublic static void printVerbose(String msg)
msg - MessageCopyright © 2019 WSO2. All rights reserved.