Class Utils
java.lang.Object
org.eclipse.lemminx.customservice.synapse.utils.Utils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddUnderscoreBetweenWords(String input) static intcompareVersions(String version1, String version2) Compares two version strings and determines their relative order.static booleancontainsIgnoreCase(List<String> list, String elementName) static voidCopy the file from the source path to the target pathstatic voidCopy the file from the source path to the target path with the given target file namestatic voidcopyFolder(Path source, Path target, List<String> copiedFiles) Copy the content of the source folder to the target folderstatic voidcopySelectedContent(Path sourceFolder, Path targetFolder, List<String> includePaths) Copies selected folders and files from source to destination based on include paths.static PathcopyXSDFiles(String projectUri) static voiddeleteDirectory(Path path) Delete the given directorystatic StringderiveResourceKeyFromFilePath(String filePath) static voiddownloadConnector(String groupId, String artifactId, String version, File targetDirectory, String fileType) static Stringstatic voidextractJarFolder(String resourceFolder, Path targetDirectory) static voidextractZip(File zip, File extractTo) static DOMNodefindDescriptionNode(DOMDocument projectDOM) static DOMNodefindNaturesNode(DOMNode descriptionNode) static StringgetAbsolutePath(String path) Returns the absolute path of the given file by sanitizing the file path.static com.google.gson.JsonObjectgetAgentToolList(com.google.gson.JsonObject mediatorList, ConnectorHolder connectorHolder) Constructs the AI agent tool list by adding supported mediators and connector operations.static DOMNodegetChildNodeByName(DOMNode node, String name) static FilegetDependencyFromLocalRepo(String groupId, String artifactId, String version, String type) Retrieves a dependency file from the local Maven repository.static DOMDocumentgetDOMDocument(File file) static DOMDocumentgetDOMDocument(String content) Get the DOM document from the given xml contentstatic DOMDocumentgetDOMDocument(String content, URIResolverExtensionManager resolverExtensionManager) static DOMDocumentgetDOMDocumentFromPath(String path) Returns theDOMDocumentfor the given file path.static <T extends Enum<T>>
TgetEnumFromValue(String value, Class<T> enumClass) static StringgetFileExtension(File file) Get the extension of the given filestatic StringgetFileName(File file) Get the file name without the extensionstatic DOMElementgetFirstElement(DOMElement element) static Stringstatic StringgetInlineString(DOMNode node) Get the inline string of the given nodestatic StringgetInlineString(DOMNode node, boolean requiresXmlUnescaping) Get the inline string of the given nodestatic com.google.gson.JsonArraygetJsonArray(String content) Get the JSON array from the given contentstatic com.google.gson.JsonElementgetJsonElement(String content) Get the JSON element from the given contentstatic com.google.gson.JsonObjectgetJsonObject(String content) Get the JSON object from the given contentstatic com.google.gson.JsonObjectgetMediatorList(String version, ConnectorHolder connectorHolder) static StringgetRegistryKey(File file) static StringgetResourceKey(File file) static DOMElementgetRootElement(DOMDocument document) Get the root element of the given documentstatic DOMElementgetRootElementFromConfigXml(DOMNode document) static StringgetServerVersion(String projectPath, String defaultVersion) getTemplateMap(String resourceFolderName) getUISchemaMap(String resourceFolderName) static booleanisExpression(String value) static booleanisFileExists(String filePath) static booleanisFileInRegistry(File file) static booleanCheck whether the given content is a JSONstatic booleanisJSONObject(String content) Check whether the given content is a JSON objectstatic booleanisLegacyProject(String path) static booleanisOlderCARPlugin(String projectPath) Check whether the given project is using an older version of CAR pluginstatic booleanisRegistryPropertiesFile(File file) static booleanisValidProject(String projectRoot) static booleanstatic booleanstatic Filestatic StringnodeToString(Node node) Transform the org.w3c.dom.Node to a stringstatic intpdfToImage(String base64Pdf) Converts a Base64 encoded PDF string into a List of Base64 encoded PNG image strings.static StringpluralToSingular(String name) static StringRead the content of the given filestatic StringremoveCDATATag(String value) Remove CDATA tags from the given xml string.static StringremoveHyphen(String name) static StringsanitizeTag(String tag) static StringtoCamelCase(String input) Convert the given string to camel casestatic StringunescapeXml(String text) Unescape the given XML textstatic com.google.gson.JsonElementupdateSynapseCatalogSettings(com.google.gson.JsonObject settings, Path schemaPath) static PathupdateSynapseCatalogSettings(org.eclipse.lsp4j.InitializeParams params) static voidwriteToFile(String path, String content) Write the given content to the file
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
getInlineString
Get the inline string of the given node- Parameters:
node- the node- Returns:
- the inline string of the given node
-
getInlineString
Get the inline string of the given node- Parameters:
node- the noderequiresXmlUnescaping- whether to unescape the xml content- Returns:
- the inline string of the given node
-
parseInt
-
getDOMDocumentFromPath
Returns theDOMDocumentfor the given file path.- Parameters:
path- the xml file path- Returns:
- the
DOMDocumentfor the given file path - Throws:
IOException- if an error occurs while reading the file
-
getDOMDocument
- Throws:
IOException
-
getDOMDocument
Get the DOM document from the given xml content- Parameters:
content- the xml content- Returns:
- the DOM document for the given xml content
-
getDOMDocument
public static DOMDocument getDOMDocument(String content, URIResolverExtensionManager resolverExtensionManager) -
getRootElementFromConfigXml
-
containsIgnoreCase
-
isLegacyProject
-
findDescriptionNode
-
findNaturesNode
-
isFileExists
-
isFileInRegistry
-
getRegistryKey
-
getResourceKey
-
isZipFile
-
isXml
-
extractZip
- Throws:
IOException
-
newFile
- Throws:
IOException
-
removeHyphen
-
pluralToSingular
-
getChildNodeByName
-
addUnderscoreBetweenWords
-
getHash
-
getFirstElement
-
getRootElement
Get the root element of the given document- Parameters:
document- the document- Returns:
- the root element of the given document
-
readFile
Read the content of the given file- Parameters:
file- the file- Returns:
- the content of the given file
- Throws:
IOException- if an error occurs while reading the file
-
getJsonObject
Get the JSON object from the given content- Parameters:
content- the content- Returns:
- the JSON object from the given content
-
getJsonArray
Get the JSON array from the given content- Parameters:
content- the content- Returns:
- the JSON object from the given content
-
getJsonElement
Get the JSON element from the given content- Parameters:
content- the content- Returns:
- the JSON element from the given content
-
isJson
Check whether the given content is a JSON- Parameters:
content-- Returns:
-
getEnumFromValue
-
getFileExtension
Get the extension of the given file- Parameters:
file-- Returns:
-
getFileName
Get the file name without the extension- Parameters:
file-- Returns:
-
unescapeXml
Unescape the given XML text- Parameters:
text-- Returns:
-
escapeXML
-
getAbsolutePath
Returns the absolute path of the given file by sanitizing the file path.- Parameters:
path- the file path- Returns:
- the absolute path of the given file
-
isRegistryPropertiesFile
-
getUISchemaMap
-
getMediatorList
public static com.google.gson.JsonObject getMediatorList(String version, ConnectorHolder connectorHolder) throws IOException - Throws:
IOException
-
getAgentToolList
public static com.google.gson.JsonObject getAgentToolList(com.google.gson.JsonObject mediatorList, ConnectorHolder connectorHolder) Constructs the AI agent tool list by adding supported mediators and connector operations.- Parameters:
mediatorList- list of all the mediatorsconnectorHolder- connector holder- Returns:
- the AI agent tool list
-
getServerVersion
-
getTemplateMap
-
copyXSDFiles
- Throws:
IOExceptionURISyntaxException
-
extractJarFolder
public static void extractJarFolder(String resourceFolder, Path targetDirectory) throws IOException, URISyntaxException - Throws:
IOExceptionURISyntaxException
-
updateSynapseCatalogSettings
public static Path updateSynapseCatalogSettings(org.eclipse.lsp4j.InitializeParams params) throws IOException, URISyntaxException - Throws:
IOExceptionURISyntaxException
-
updateSynapseCatalogSettings
public static com.google.gson.JsonElement updateSynapseCatalogSettings(com.google.gson.JsonObject settings, Path schemaPath) throws IOException, URISyntaxException - Throws:
IOExceptionURISyntaxException
-
deriveResourceKeyFromFilePath
-
copyFolder
public static void copyFolder(Path source, Path target, List<String> copiedFiles) throws IOException Copy the content of the source folder to the target folder- Parameters:
source- the source foldertarget- the target foldercopiedFiles- the list of copied files- Throws:
IOException- if an error occurs while copying the content
-
deleteDirectory
Delete the given directory- Parameters:
path- the directory path- Throws:
IOException- if an error occurs while deleting the directory
-
writeToFile
Write the given content to the file- Parameters:
path- the file pathcontent- the content- Throws:
IOException- if an error occurs while writing the content to the file
-
isJSONObject
Check whether the given content is a JSON object- Parameters:
content- the content- Returns:
- whether the given content is a JSON object
-
toCamelCase
Convert the given string to camel case- Parameters:
input- the input string- Returns:
- the camel case string
-
copyFile
Copy the file from the source path to the target path- Parameters:
sourcePath-targetPath-- Throws:
IOException
-
copyFile
public static void copyFile(String sourcePath, String targetPath, String targetFileName) throws IOException Copy the file from the source path to the target path with the given target file name- Parameters:
sourcePath-targetPath-targetFileName-- Throws:
IOException
-
isExpression
-
copySelectedContent
public static void copySelectedContent(Path sourceFolder, Path targetFolder, List<String> includePaths) throws IOException Copies selected folders and files from source to destination based on include paths.- Parameters:
sourceFolder- Source directory pathincludePaths- List of relative paths to include in the copy- Throws:
IOException- If an I/O error occurs
-
nodeToString
Transform the org.w3c.dom.Node to a string- Parameters:
node-- Returns:
-
isOlderCARPlugin
Check whether the given project is using an older version of CAR plugin- Parameters:
projectPath-- Returns:
-
compareVersions
Compares two version strings and determines their relative order.- Parameters:
version1- The first version string to compare.version2- The second version string to compare.- Returns:
- a negative integer if
version1is less thanversion2, a positive integer ifversion1is greater thanversion2, or 0 if they are equal
-
sanitizeTag
-
downloadConnector
public static void downloadConnector(String groupId, String artifactId, String version, File targetDirectory, String fileType) throws IOException - Throws:
IOException
-
getDependencyFromLocalRepo
public static File getDependencyFromLocalRepo(String groupId, String artifactId, String version, String type) Retrieves a dependency file from the local Maven repository.- Parameters:
groupId- the group ID of the dependencyartifactId- the artifact ID of the dependencyversion- the version of the dependencytype- the file type (e.g., jar, zip)- Returns:
- the dependency file if it exists, otherwise null
-
isValidProject
-
removeCDATATag
Remove CDATA tags from the given xml string.* Example:
<![CDATA[<xml/>]]>will be converted to<xml/>- Parameters:
value- the xml string- Returns:
- the xml string without CDATA tags
-
pdfToImage
Converts a Base64 encoded PDF string into a List of Base64 encoded PNG image strings.- Parameters:
base64Pdf- Content of the PDF in Base64.- Returns:
- A List of strings, where each string is a Base64 encoded PNG image of a page, or an empty list if any error occurs.
-