|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.wso2.carbon.registry.synchronization.Utils
public class Utils
Some utility methods used by the synchronization operations.
Field Summary | |
---|---|
static int |
RADIX
|
Method Summary | |
---|---|
static void |
addResource(String path)
This method add the resources which are not added to commit |
static void |
cleanEmbeddedRegistry()
Method to clean the embedded registry instance, after the synchronization operation. |
static List<String> |
cleanUpDirectory(File directory,
List<String> filesToPreserve)
Method to determine the files that are required to be cleaned up from meta information directory and preserve only the given list of files. |
static boolean |
confirmDelete(File file,
File metaFile,
UserInputCallback callback)
This method will obtain the consent from the user to delete the specified file and meta file (corresponding to the file), if the user agrees to. |
static boolean |
contentChanged(File file)
Determines whether the content of the given file has changed. |
static void |
copy(File source,
File destination)
copying the contents of one file to another. |
static org.apache.axiom.om.OMElement |
createDefaultMetaFile(boolean isCollection,
String path,
String username)
Method to generate the XML content of a meta file. |
static void |
createMetaFile(String fileName,
org.apache.axiom.om.OMElement metaData)
This method creates the file that store the meta data of the current directory or file. |
static String |
decodeFilename(String path)
This method will obtain the decoded representation of the given encoded resource path. |
static boolean |
deleteFile(File file)
This method deletes the specified file from the filesystem. |
static String |
encodeResourceName(String resourceName)
This method will obtain the encoded representation of the given resource name. |
static boolean |
fileContentChanged(File file)
|
static byte[] |
getBytesFromFile(File file)
Returns the contents of the file in a byte array. |
static String |
getMD5(byte[] content)
Method to obtain the MD5 hash value for the given content. |
static String |
getMD5(File file)
Method to obtain the MD5 hash value for the given file. |
static org.apache.axiom.om.OMElement |
getMetaOMElement(String filePath)
Method to obtain the XML representation of the meta information corresponding to the given file. |
static org.apache.axiom.om.OMElement |
getOMElementFromMetaFile(String metaFilePath)
Method to obtain the XML representation of the data contained in a meta file. |
static String |
getPath(String url)
Method to extract the resource path from the given URL. |
static String |
getRegistryUrl(String url)
Method to extract the URL of the remote registry instance from the given URL. |
static org.apache.axiom.om.OMElement |
readMetaElement(XMLStreamReader xmlReader)
This method reads the xml stream up to the children and return the meta element. |
static boolean |
resourceUpdated(String metaFilePath,
org.apache.axiom.om.OMElement metaElement)
This method checks whether the resource updated or not in the Registry from the last checkout/update |
static void |
setResourcesDelete(String dirPath)
This method mark the resources as delete if it no longer exists in the file system |
static org.apache.axiom.om.OMElement |
updateDefaultAddMetaFile(org.apache.axiom.om.OMElement root,
String path,
String username,
boolean isDirectory)
Method to update the XML content of a meta file. |
static void |
updateMetaFile(String fileName,
org.apache.axiom.om.OMElement metaData)
This method update the file that store the meta data of the current directory or file. |
static void |
writeMetaElement(XMLStreamWriter xmlWriter,
org.apache.axiom.om.OMElement metaElement)
This method writes the meta element to the xml stream up to the children. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RADIX
Method Detail |
---|
public static void writeMetaElement(XMLStreamWriter xmlWriter, org.apache.axiom.om.OMElement metaElement) throws XMLStreamException
xmlWriter
- xml writermetaElement
- meta element to write
XMLStreamException
- if the operation failedpublic static org.apache.axiom.om.OMElement readMetaElement(XMLStreamReader xmlReader) throws SynchronizationException, XMLStreamException
xmlReader
- the xml reader.
SynchronizationException
- if the provided XML is invalid.
XMLStreamException
- if XML parsing failed.public static void createMetaFile(String fileName, org.apache.axiom.om.OMElement metaData) throws SynchronizationException
fileName
- the name of the file.metaData
- the meta data element.
SynchronizationException
- if the operation failed.public static void updateMetaFile(String fileName, org.apache.axiom.om.OMElement metaData) throws SynchronizationException
fileName
- the name of the file.metaData
- the meta data element.
SynchronizationException
- if the operation failed.public static boolean resourceUpdated(String metaFilePath, org.apache.axiom.om.OMElement metaElement)
metaFilePath
- Resource metadata file location in the file systemmetaElement
- Metadata of Registry resource
public static byte[] getBytesFromFile(File file) throws SynchronizationException
file
- the file the to read
SynchronizationException
- if the operation failed.public static org.apache.axiom.om.OMElement getMetaOMElement(String filePath) throws SynchronizationException
getOMElementFromMetaFile(String)
method.
filePath
- the path to the file of which the meta information is required.
SynchronizationException
- if the operation failed.public static org.apache.axiom.om.OMElement getOMElementFromMetaFile(String metaFilePath) throws SynchronizationException
metaFilePath
- the path to the meta file.
SynchronizationException
- if the operation failed.public static org.apache.axiom.om.OMElement createDefaultMetaFile(boolean isCollection, String path, String username) throws SynchronizationException
isCollection
- whether the resource at the given path is a collection.path
- the path of the resource for which the meta information is generated.username
- the username of the creator.
SynchronizationException
- if the operation failed.public static org.apache.axiom.om.OMElement updateDefaultAddMetaFile(org.apache.axiom.om.OMElement root, String path, String username, boolean isDirectory) throws SynchronizationException
root
- metadata OMElementpath
- the path of the resource for which the meta information is generated.username
- the username of the creator.
SynchronizationException
- if the operation failed.public static void copy(File source, File destination) throws SynchronizationException
source
- sourcedestination
- destination
SynchronizationException
- throws if the operation failed.public static String getRegistryUrl(String url)
url
- aggregate URL containing a concatenation of the registry URL and the resource path
that is capable of referencing a remote resource. This url will contain only the
resource path if the resource was local to the given registry instance.
public static String getPath(String url)
url
- aggregate URL containing a concatenation of the registry URL and the resource path
that is capable of referencing a remote resource. This url will contain only the
resource path if the resource was local to the given registry instance.
public static String encodeResourceName(String resourceName) throws SynchronizationException
resourceName
- the name of the resource.
SynchronizationException
- if the operation failed.URLEncoder
public static String decodeFilename(String path) throws SynchronizationException
path
- the encoded path of the resource.
SynchronizationException
- if the operation failed.URLDecoder
public static boolean confirmDelete(File file, File metaFile, UserInputCallback callback) throws SynchronizationException
file
- the file or directory to delete.metaFile
- the meta file corresponding to the file or directory to delete.callback
- the callback which is used to obtain the user's consent. If this parameter is
null, the file and the meta file will be deleted irrespective of the user's
choice.
SynchronizationException
- if an error occurred during the operation.public static boolean deleteFile(File file)
file
- the file or directory to delete.
public static List<String> cleanUpDirectory(File directory, List<String> filesToPreserve)
directory
- the meta information directory that requires cleaning up.filesToPreserve
- the list of files to preserve.
public static String getMD5(byte[] content)
content
- the content as an array of bytes.
public static String getMD5(File file) throws SynchronizationException
file
- the content file.
SynchronizationException
public static boolean contentChanged(File file) throws SynchronizationException
file
- the file to test for changes.
SynchronizationException
- if an error occurred during the operation.public static boolean fileContentChanged(File file) throws SynchronizationException
SynchronizationException
public static void cleanEmbeddedRegistry()
public static void addResource(String path) throws SynchronizationException
path
-
SynchronizationException
public static void setResourcesDelete(String dirPath) throws SynchronizationException
dirPath
- Parent directory of the deleted file/s
SynchronizationException
- If the operation failed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |