Moved a bunch of things to more logical locations.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4497 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-12-03 15:43:16 +00:00
parent 03a93a3cf7
commit b8595831c8
27 changed files with 56 additions and 52 deletions

View File

@@ -1,408 +0,0 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.namespace.QName;
/**
* Remote interface for AVM.
* @author britt
*/
public interface AVMRemote
{
/**
* Get an input handle. A handle is an opaque reference
* to a server side input stream.
* @param version The version to look under.
* @param path The path to the file.
* @return An InputStream.
*/
public InputStream getFileInputStream(int version, String path);
/**
* Get an InputStream from a descriptor directly.
* @param desc The descriptor.
* @return An InputStream.
*/
public InputStream getFileInputStream(AVMNodeDescriptor desc);
/**
* Get an opaque handle to a server side output stream.
* @param path The path to the existing file.
* @return An opaque handle.
*/
public OutputStream getFileOutputStream(String path);
/**
* Get a listing of a directories direct contents.
* @param version The version to look under.
* @param path The path to the directory.
* @return A sorted listing.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(int version, String path);
/**
* Get a listing of a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @return A sorted listing.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListing(int version, String path);
/**
* Get a directory listing from a node descriptor.
* @param dir The directory node descriptor.
* @return A sorted listing.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListing(AVMNodeDescriptor dir);
/**
* Get the names of nodes that have been deleted in a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @return A list of deleted names.
*/
public List<String> getDeleted(int version, String path);
/**
* Create a file and return a handle to an output stream.
* @param path The path to the file.
* @param name The name of the file to create.
* @return An opaque handle to a server side output stream.
*/
public OutputStream createFile(String path, String name);
/**
* Create a directory.
* @param path The path to the containing directory.
* @param name The name for the new directory.
*/
public void createDirectory(String path, String name);
/**
* Create a new layered file.
* @param targetPath The path that is targeted.
* @param parent The path to the parent directory.
* @param name The name for the new file.
*/
public void createLayeredFile(String targetPath, String parent, String name);
/**
* Create a layered directory.
* @param targetPath The path that is targeted.
* @param parent The parent directory.
* @param name The name of the new directory.
*/
public void createLayeredDirectory(String targetPath, String parent, String name);
/**
* Set a layered directory node to point at a different target.
* @param path The path to the layered directory node.
* @param target The new target.
*/
public void retargetLayeredDirectory(String path, String target);
/**
* Create a new AVMStore.
* @param name The name to give the new store.
*/
public void createAVMStore(String name);
/**
* Create a new branch.
* @param version The version to look under for the source node.
* @param srcPath The path to the source node.
* @param dstPath The path to the destination directory.
* @param name The name of the new branch.
*/
public void createBranch(int version, String srcPath, String dstPath, String name);
/**
* Remove a node.
* @param parent The path to the parent directory.
* @param name The name of the node to remove.
*/
public void removeNode(String parent, String name);
/**
* Rename a node.
* @param srcParent The source directory path.
* @param srcName The source node name.
* @param dstParent The destination directory path.
* @param dstName The destination name for the node.
*/
public void rename(String srcParent, String srcName, String dstParent, String dstName);
/**
* Uncover a name in a layered directory.
* @param dirPath The path to the directory.
* @param name The name to uncover.
*/
public void uncover(String dirPath, String name);
/**
* Get the latest version id of the given AVMStore.
* @param storeName The name of the AVMStore.
* @return The latest version id.
*/
public int getLatestVersionID(String storeName);
/**
* Get the id of the latest extant snpashot.
* @param storeName The name of the store.
* @return The id.
*/
public int getLatestSnapshotID(String storeName);
/**
* Snapshot an AVMStore.
* @param store The name of the AVMStore to snapshot.
* @return The version id of the new snapshot.
*/
public int createSnapshot(String store, String label, String comment);
/**
* Get a List of all versions in a given store.
* @param name The name of the store.
* @return A List of VersionDescriptors.
*/
public List<VersionDescriptor> getAVMStoreVersions(String name);
/**
* Get AVMStore versions between given dates.
* @param name The name of the store.
* @param from The date from which (inclusive).
* @param to The date to which (inclusive).
* @return A List of VersionDescriptors.
*/
public List<VersionDescriptor> getAVMStoreVersions(String name, Date from, Date to);
/**
* Get a list of all AVM stores.
* @return A List of AVMStoreDescriptors.
*/
public List<AVMStoreDescriptor> getAVMStores();
/**
* Get the descriptor for a given AVMStore.
* @param name The name of the store.
* @return An AVMStoreDescriptor.
*/
public AVMStoreDescriptor getAVMStore(String name);
/**
* Get the specified root of the specified store.
* @param version The version number to fetch.
* @param name The name of the store.
* @return The AVMNodeDescriptor for the root.
*/
public AVMNodeDescriptor getAVMStoreRoot(int version, String name);
/**
* Get a descriptor for the specified node.
* @param version The version to look under.
* @param path The path to the node.
* @return An AVMNodeDescriptor.
*/
public AVMNodeDescriptor lookup(int version, String path);
/**
* Get a descriptor for the specified node.
* @param dir The descriptor for the directory node.
* @param name The name of the node to lookup.
* @return An AVMNodeDescriptor.
*/
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name);
/**
* Get the indirection path for a node.
* @param version The version to look under.
* @param path The path to the node.
* @return The indirection path/target.
*/
public String getIndirectionPath(int version, String path);
/**
* Purge an AVMStore.
* @param name The name of the store to purge.
*/
public void purgeAVMStore(String name);
/**
* Purge a given version from a given store.
* @param version The version id.
* @param name The name of the store.
*/
public void purgeVersion(int version, String name);
/**
* Turn a directory into a primary indirection node.
* @param path The path to the directory.
*/
public void makePrimary(String path);
/**
* Get a list of ancestors of a node.
* @param desc The descriptor of the node whose history is to be fetched.
* @param count The maximum number of ancestors that will be returned.
* @return A List of descriptors for ancestors starting most recent first.
*/
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count);
/**
* Turn on or off a directory's opacity.
* @param path The path to the directory.
* @param opacity Whether the directory should be opaque or not.
*/
public void setOpacity(String path, boolean opacity);
/**
* Get the most recent common ancestor of two nodes.
* @param left One node.
* @param right The other node.
* @return The common ancestor.
*/
public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left, AVMNodeDescriptor right);
/**
* Get layering information about a path.
* @param version The version to look under.
* @param path The path to the node.
* @return A LayeringDescriptor.
*/
public LayeringDescriptor getLayeringInfo(int version, String path);
/**
* Set a property on a node.
* @param path The path to the node.
* @param name The name of the property.
* @param value The value to give the property.
*/
public void setNodeProperty(String path, QName name, PropertyValue value);
/**
* Set a group of properties on a node.
* @param path The path to the node.
* @param properties A Map of QNames to PropertyValues to set.
*/
public void setNodeProperties(String path, Map<QName, PropertyValue> properties);
/**
* Get the value of a node property.
* @param version The version to look under.
* @param path The path to the node.
* @param name The name of the property.
* @return A PropertyValue.
*/
public PropertyValue getNodeProperty(int version, String path, QName name);
/**
* Get all properties of a node.
* @param version The version.
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
public Map<QName, PropertyValue> getNodeProperties(int version, String path);
/**
* Delete a property from a node.
* @param path The path to the node.
* @param name The name of the property.
*/
public void deleteNodeProperty(String path, QName name);
/**
* Delete all properties from a node.
* @param path The path to the node.
*/
public void deleteNodeProperties(String path);
/**
* Set a property on a store.
* @param store The name of the store.
* @param name The name of the property to set.
* @param value The value of the property to set.
*/
public void setStoreProperty(String store, QName name, PropertyValue value);
/**
* Set a group of properties on a store.
* @param store The name of the store.
* @param props A Map of QNames to PropertyValues to set.
*/
public void setStoreProperties(String store, Map<QName, PropertyValue> props);
/**
* Get a property from a store.
* @param store The name of the store.
* @param name The name of the property.
* @return A PropertyValue.
*/
public PropertyValue getStoreProperty(String store, QName name);
/**
* Query a store for keys that match a pattern.
* @param store The store name.
* @param keyPattern The sql 'like' pattern.
* @return A Map of keys to values.
*/
public Map<QName, PropertyValue> queryStorePropertyKey(String store, QName keyPattern);
/**
* Query all stores for keys that match a pattern.
* @param keyPattern The sql 'like' pattern.
* @return A Map of store names to Maps of matching keys to values.
*/
public Map<String, Map<QName, PropertyValue>> queryStoresPropertyKey(QName keyPattern);
/**
* Get all the properties on a store.
* @param store The name of the store.
* @return A Map of QNames to PropertyValues.
*/
public Map<QName, PropertyValue> getStoreProperties(String store);
/**
* Delete a property from a store.
* @param store The name of the store.
* @param name The name of the property.
*/
public void deleteStoreProperty(String store, QName name);
/**
* Rename a store.
* @param sourceName The original name.
* @param destName The new name.
*/
public void renameStore(String sourceName, String destName);
}

View File

@@ -1,115 +0,0 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
import java.io.IOException;
import java.io.InputStream;
import org.alfresco.repo.avm.clt.ClientTicketHolder;
/**
* Wrapper around AVMRemote stream reading.
* @author britt
*/
public class AVMRemoteInputStream extends InputStream
{
/**
* The AVMRemote reference.
*/
private AVMRemoteTransport fAVMRemote;
/**
* The handle to the input stream.
*/
private String fHandle;
/**
* Construct one.
* @param handle The handle returned by getInputStream();
* @param remote The AVMRemote instance.
*/
public AVMRemoteInputStream(String handle, AVMRemoteTransport remote)
{
fHandle = handle;
fAVMRemote = remote;
}
/**
* Read in a single byte.
* @return The byte as 0-255 or -1 for eof.
*/
@Override
public int read() throws IOException
{
try
{
byte [] buff = fAVMRemote.readInput(ClientTicketHolder.GetTicket(), fHandle, 1);
if (buff.length == 0)
{
return -1;
}
return ((int)buff[0]) & 0xff;
}
catch (Exception e)
{
throw new IOException("Remote I/O Error.");
}
}
/**
* Read a buffer of bytes.
* @param b The buffer into which to put the bytes.
* @param off The offset into the buffer.
* @param len The number of bytes to read.
* @return The actual number of bytes read or -1 on eof.
*/
@Override
public int read(byte[] b, int off, int len) throws IOException
{
try
{
byte [] buff = fAVMRemote.readInput(ClientTicketHolder.GetTicket(), fHandle, len);
if (buff.length == 0)
{
return -1;
}
System.arraycopy(buff, 0, b, off, buff.length);
return buff.length;
}
catch (Exception e)
{
throw new IOException("Remote I/O Error.");
}
}
/**
* Close the underlying AVMRemote handle.
*/
@Override
public void close() throws IOException
{
try
{
fAVMRemote.closeInputHandle(ClientTicketHolder.GetTicket(), fHandle);
}
catch (Exception e)
{
throw new IOException("Remote Error closing input stream.");
}
}
}

View File

@@ -16,6 +16,7 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.remote.AVMRemote;
import org.alfresco.service.namespace.QName;
/**

View File

@@ -1,110 +0,0 @@
/*
* Copyright (C) 2006 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.repo.avm;
import java.io.IOException;
import java.io.OutputStream;
import org.alfresco.repo.avm.clt.ClientTicketHolder;
public class AVMRemoteOutputStream extends OutputStream
{
private AVMRemoteTransport fAVMRemote;
private String fHandle;
/**
* Create a new one.
* @param handle The handle returned from an AVMRemote call.
* @param remote The AVMRemote instance.
*/
public AVMRemoteOutputStream(String handle, AVMRemoteTransport remote)
{
fAVMRemote = remote;
fHandle = handle;
}
/**
* Write one character.
* @param b The character.
*/
@Override
public void write(int b)
throws IOException
{
byte [] buff = new byte[1];
buff[0] = (byte)b;
write(buff);
}
/**
* Close the stream.
*/
@Override
public void close()
throws IOException
{
try
{
fAVMRemote.closeOutputHandle(ClientTicketHolder.GetTicket(), fHandle);
}
catch (Exception e)
{
throw new IOException("IO Error: " + e);
}
}
/**
* Write a portion of a block of bytes.
* @param b The buffer containing the data.
* @param off The offset into the buffer.
* @param len The number of bytes to write.
*/
@Override
public void write(byte[] b, int off, int len)
throws IOException
{
try
{
if (off == 0)
{
fAVMRemote.writeOutput(ClientTicketHolder.GetTicket(), fHandle, b, len);
}
else
{
byte [] buff = new byte[len];
System.arraycopy(b, off, buff, 0, len);
fAVMRemote.writeOutput(ClientTicketHolder.GetTicket(), fHandle, buff, len);
}
}
catch (Exception e)
{
throw new IOException("IO Error: " + e);
}
}
/**
* Write a buffer of data.
* @param b The buffer.
*/
@Override
public void write(byte[] b)
throws IOException
{
write(b, 0, b.length);
}
}

View File

@@ -1,427 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.namespace.QName;
/**
* This is the actual remote interface that is wrapped by
* RMI.
* @author britt
*/
public interface AVMRemoteTransport
{
/**
* Get an input handle. A handle is an opaque reference
* to a server side input stream.
* @param version The version to look under.
* @param path The path to the file.
* @return A handle.
*/
public String getInputHandle(String ticket, int version, String path);
/**
* Get an input handle from a descriptor.
* @param ticket The authentication ticket.
* @param desc The descriptor.
* @return An input handle.
*/
public String getInputHandle(String ticket, AVMNodeDescriptor desc);
/**
* Read a chunk of data from a handle.
* @param handle The opaque input stream handle.
* @param count The number of bytes to try to read.
* @return An array of bytes. 0 length at eof.
*/
public byte[] readInput(String Ticket, String handle, int count);
/**
* Close an input stream. Server side input streams are
* timer limited, ie, they will be automatically closed
* after a given idle time. However, be nice, and close
* handles when you're done.
* @param handle The opaque handle to the server side stream.
*/
public void closeInputHandle(String ticket, String handle);
/**
* Get an opaque handle to a server side output stream.
* @param path The path to the existing file.
* @return An opaque handle.
*/
public String getOutputHandle(String ticket, String path);
/**
* Write <code>count</code> bytes from buffer <code>buff</code>
* starting at offset <code>offset</code> in <code>buff</code>
* @param handle The opaque handle to the server side output stream.
* @param buff The data buffer.
* @param count The number of bytes to write.
*/
public void writeOutput(String ticket, String handle, byte [] buff, int count);
/**
* Close the server side output stream designated by the handle.
* @param handle The handle to the server side output stream.
*/
public void closeOutputHandle(String ticket, String handle);
/**
* Get a listing of a directories direct contents.
* @param version The version to look under.
* @param path The path to the directory.
* @return A sorted listing.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListingDirect(String ticket, int version, String path);
/**
* Get a listing of a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @return A sorted listing.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListing(String ticket, int version, String path);
/**
* Get a directory listing from a node descriptor.
* @param dir The directory node descriptor.
* @return A sorted listing.
*/
public SortedMap<String, AVMNodeDescriptor>
getDirectoryListing(String ticket, AVMNodeDescriptor dir);
/**
* Get the names of nodes that have been deleted in a directory.
* @param version The version to look under.
* @param path The path to the directory.
* @return A list of deleted names.
*/
public List<String> getDeleted(String ticket, int version, String path);
/**
* Create a file and return a handle to an output stream.
* @param path The path to the file.
* @param name The name of the file to create.
* @return An opaque handle to a server side output stream.
*/
public String createFile(String ticket, String path, String name);
/**
* Create a directory.
* @param path The path to the containing directory.
* @param name The name for the new directory.
*/
public void createDirectory(String ticket, String path, String name);
/**
* Create a new layered file.
* @param targetPath The path that is targeted.
* @param parent The path to the parent directory.
* @param name The name for the new file.
*/
public void createLayeredFile(String ticket, String targetPath, String parent, String name);
/**
* Create a layered directory.
* @param targetPath The path that is targeted.
* @param parent The parent directory.
* @param name The name of the new directory.
*/
public void createLayeredDirectory(String ticket, String targetPath, String parent, String name);
/**
* Set a layered directory node to point at a different target.
* @param path The path to the layered directory node.
* @param target The new target.
*/
public void retargetLayeredDirectory(String ticket, String path, String target);
/**
* Create a new AVMStore.
* @param name The name to give the new store.
*/
public void createAVMStore(String ticket, String name);
/**
* Create a new branch.
* @param version The version to look under for the source node.
* @param srcPath The path to the source node.
* @param dstPath The path to the destination directory.
* @param name The name of the new branch.
*/
public void createBranch(String ticket, int version, String srcPath, String dstPath, String name);
/**
* Remove a node.
* @param parent The path to the parent directory.
* @param name The name of the node to remove.
*/
public void removeNode(String ticket, String parent, String name);
/**
* Rename a node.
* @param srcParent The source directory path.
* @param srcName The source node name.
* @param dstParent The destination directory path.
* @param dstName The destination name for the node.
*/
public void rename(String ticket, String srcParent, String srcName, String dstParent, String dstName);
/**
* Uncover a name in a layered directory.
* @param dirPath The path to the directory.
* @param name The name to uncover.
*/
public void uncover(String ticket, String dirPath, String name);
/**
* Get the latest version id of the given AVMStore.
* @param storeName The name of the AVMStore.
* @return The latest version id.
*/
public int getLatestVersionID(String ticket, String storeName);
/**
* Get the id of the latest extant snpashot.
* @param storeName The name of the store.
* @return The id.
*/
public int getLatestSnapshotID(String ticket, String storeName);
/**
* Snapshot an AVMStore.
* @param store The name of the AVMStore to snapshot.
* @return The version id of the new snapshot.
*/
public int createSnapshot(String ticket, String store, String label, String comment);
/**
* Get a List of all versions in a given store.
* @param name The name of the store.
* @return A List of VersionDescriptors.
*/
public List<VersionDescriptor> getAVMStoreVersions(String ticket, String name);
/**
* Get AVMStore versions between given dates.
* @param name The name of the store.
* @param from The date from which (inclusive).
* @param to The date to which (inclusive).
* @return A List of VersionDescriptors.
*/
public List<VersionDescriptor> getAVMStoreVersions(String ticket, String name, Date from, Date to);
/**
* Get a list of all AVM stores.
* @return A List of AVMStoreDescriptors.
*/
public List<AVMStoreDescriptor> getAVMStores(String ticket);
/**
* Get the descriptor for a given AVMStore.
* @param name The name of the store.
* @return An AVMStoreDescriptor.
*/
public AVMStoreDescriptor getAVMStore(String ticket, String name);
/**
* Get the specified root of the specified store.
* @param version The version number to fetch.
* @param name The name of the store.
* @return The AVMNodeDescriptor for the root.
*/
public AVMNodeDescriptor getAVMStoreRoot(String ticket, int version, String name);
/**
* Get a descriptor for the specified node.
* @param version The version to look under.
* @param path The path to the node.
* @return An AVMNodeDescriptor.
*/
public AVMNodeDescriptor lookup(String ticket, int version, String path);
/**
* Get a descriptor for the specified node.
* @param dir The descriptor for the directory node.
* @param name The name of the node to lookup.
* @return An AVMNodeDescriptor.
*/
public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name);
/**
* Get the indirection path for a node.
* @param version The version to look under.
* @param path The path to the node.
* @return The indirection path/target.
*/
public String getIndirectionPath(String ticket, int version, String path);
/**
* Purge an AVMStore.
* @param name The name of the store to purge.
*/
public void purgeAVMStore(String ticket, String name);
/**
* Purge a given version from a given store.
* @param version The version id.
* @param name The name of the store.
*/
public void purgeVersion(String ticket, int version, String name);
/**
* Turn a directory into a primary indirection node.
* @param path The path to the directory.
*/
public void makePrimary(String ticket, String path);
/**
* Get a list of ancestors of a node.
* @param desc The descriptor of the node whose history is to be fetched.
* @param count The maximum number of ancestors that will be returned.
* @return A List of descriptors for ancestors starting most recent first.
*/
public List<AVMNodeDescriptor> getHistory(String ticket, AVMNodeDescriptor desc, int count);
/**
* Turn on or off a directory's opacity.
* @param path The path to the directory.
* @param opacity Whether the directory should be opaque or not.
*/
public void setOpacity(String ticket, String path, boolean opacity);
/**
* Get the most recent common ancestor of two nodes.
* @param left One node.
* @param right The other node.
* @return The common ancestor.
*/
public AVMNodeDescriptor getCommonAncestor(String ticket, AVMNodeDescriptor left, AVMNodeDescriptor right);
/**
* Get layering information about a path.
* @param version The version to look under.
* @param path The path to the node.
* @return A LayeringDescriptor.
*/
public LayeringDescriptor getLayeringInfo(String ticket, int version, String path);
/**
* Set a property on a node.
* @param path The path to the node.
* @param name The name of the property.
* @param value The value to give the property.
*/
public void setNodeProperty(String ticket, String path, QName name, PropertyValue value);
/**
* Set a group of properties on a node.
* @param path The path to the node.
* @param properties A Map of QNames to PropertyValues to set.
*/
public void setNodeProperties(String ticket, String path, Map<QName, PropertyValue> properties);
/**
* Get the value of a node property.
* @param version The version to look under.
* @param path The path to the node.
* @param name The name of the property.
* @return A PropertyValue.
*/
public PropertyValue getNodeProperty(String ticket, int version, String path, QName name);
/**
* Get all properties of a node.
* @param version The version.
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
public Map<QName, PropertyValue> getNodeProperties(String ticket, int version, String path);
/**
* Delete a property from a node.
* @param path The path to the node.
* @param name The name of the property.
*/
public void deleteNodeProperty(String ticket, String path, QName name);
/**
* Delete all properties from a node.
* @param path The path to the node.
*/
public void deleteNodeProperties(String ticket, String path);
/**
* Set a property on a store.
* @param store The name of the store.
* @param name The name of the property to set.
* @param value The value of the property to set.
*/
public void setStoreProperty(String ticket, String store, QName name, PropertyValue value);
/**
* Set a group of properties on a store.
* @param store The name of the store.
* @param props A Map of QNames to PropertyValues to set.
*/
public void setStoreProperties(String ticket, String store, Map<QName, PropertyValue> props);
/**
* Get a property from a store.
* @param store The name of the store.
* @param name The name of the property.
* @return A PropertyValue.
*/
public PropertyValue getStoreProperty(String ticket, String store, QName name);
/**
* Query a store for keys that match a pattern.
* @param store The store name.
* @param keyPattern The sql 'like' pattern.
* @return A Map of keys to values.
*/
public Map<QName, PropertyValue> queryStorePropertyKey(String ticket, String store, QName keyPattern);
/**
* Query all stores for keys that match a pattern.
* @param keyPattern The sql 'like' pattern.
* @return A Map of store names to Maps of matching keys to values.
*/
public Map<String, Map<QName, PropertyValue>> queryStoresPropertyKey(String ticket, QName keyPattern);
/**
* Get all the properties on a store.
* @param store The name of the store.
* @return A Map of QNames to PropertyValues.
*/
public Map<QName, PropertyValue> getStoreProperties(String ticket, String store);
/**
* Delete a property from a store.
* @param store The name of the store.
* @param name The name of the property.
*/
public void deleteStoreProperty(String ticket, String store, QName name);
/**
* Rename a store.
* @param ticket The authentication ticket.
* @param sourceName The original name.
* @param destName The new name.
*/
public void renameStore(String ticket, String sourceName, String destName);
}

View File

@@ -20,6 +20,7 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.remote.AVMRemoteTransport;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;

View File

@@ -7,7 +7,7 @@ import java.util.List;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport;
import org.alfresco.service.cmr.remote.AVMSyncServiceTransport;
import org.alfresco.service.cmr.security.AuthenticationService;
/**

View File

@@ -21,10 +21,11 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.alfresco.repo.avm.clt.ClientTicketHolder;
import org.alfresco.repo.remote.ClientTicketHolder;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.remote.AVMRemote;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.springframework.context.support.FileSystemXmlApplicationContext;

View File

@@ -28,7 +28,7 @@ public class FileNameValidator
/**
* The bad file name pattern.
*/
private static String fgBadPattern = ".*[\"\\*\\\\><\\?/:\\|\\xA3\\xAC%&\\+;]+.*";
private static String fgBadPattern = ".*[\"\\*\\\\><\\?/:\\|\\xA3\\xAC%&;]+.*";
/**
* The compiled regex.

View File

@@ -1,200 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.avm.AVMRemote;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* This is the base class for AVM clts.
* @author britt
*/
public abstract class AVMCltBase
{
/**
* The instance of the remote interface.
*/
protected AVMRemote fAVMRemote;
/**
* The instance of the remote sync service interface.
*/
protected AVMSyncService fAVMSyncService;
/**
* The ApplicationContext.
*/
protected ConfigurableApplicationContext fContext;
/**
* The Authentication Service.
*/
protected AuthenticationService fAuthenticationService;
/**
* Construct a new one. This takes care of instantiating
* the application context and grabs references to the
* services.
* @param args The program arguments.
*/
protected AVMCltBase()
{
fContext = new ClassPathXmlApplicationContext("alfresco/avm-clt-context.xml");
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService");
fAuthenticationService = (AuthenticationService)fContext.getBean("authenticationService");
fAuthenticationService.authenticate("admin", "admin".toCharArray());
String ticket = fAuthenticationService.getCurrentTicket();
ClientTicketHolder.SetTicket(ticket);
}
/**
* All clts go through this call. This parses the arguments, exits if
* there are any errors and then passes the broken flags and arguments
* to the run method of the derived clt.
* @param args The raw command line arguments.
* @param flagDefs The definition of what flags to accept and their
* arities.
* @param minArgs The minimum number of actual arguments expected.
* @param usageMessage The message that should be printed if there is a
* syntax error.
*/
public void exec(String [] args,
Object [] flagDefs,
int minArgs,
String usageMessage)
{
Map<String, Integer> flagArgs = new HashMap<String, Integer>();
Map<String, List<String>> flagValues = new HashMap<String, List<String>>();
List<String> actualArgs = new ArrayList<String>();
// Convert the flag definitions into a convenient form.
for (int i = 0; i < flagDefs.length / 2; i++)
{
flagArgs.put((String)flagDefs[i * 2], (Integer)flagDefs[i * 2 + 1]);
}
// Walk through the raw command line arguments.
int pos = 0;
while (pos < args.length)
{
if (args[pos].equals("-h"))
{
usage(usageMessage);
}
// If the argument is one of the accepted flags then it's
// a flag.
if (flagArgs.containsKey(args[pos]))
{
String flag = args[pos];
pos++;
int count = flagArgs.get(flag);
// Check for too few arguments
if (args.length - pos < count)
{
usage(usageMessage);
}
// Stuff the parsed flag away.
List<String> flArgs = new ArrayList<String>();
for (int i = 0; i < count; i++)
{
flArgs.add(args[pos + i]);
}
flagValues.put(flag, flArgs);
pos += count;
continue;
}
// Otherwise its just a plain old arg.
actualArgs.add(args[pos]);
pos++;
}
// Check for too few arguments.
if (actualArgs.size() < minArgs)
{
usage(usageMessage);
}
// Do the work.
run(flagValues, actualArgs);
// Cleanup.
fContext.close();
}
/**
* Handle syntax error by exiting.
* @param usageMessage The message to print.
*/
protected void usage(String usageMessage)
{
System.err.println(usageMessage);
fContext.close();
System.exit(1);
}
/**
* Utility to split an AVM path into a parent path and a
* base name.
* @param path The path to split.
* @return An array of 1 or 2 Strings representing the parent path
* and the base name, or just the path if the path given is a root path.
*/
protected String[] splitPath(String path)
{
if (path.endsWith(":/"))
{
String [] ret = { path };
return ret;
}
int lastSlash = path.lastIndexOf("/");
if (lastSlash == -1)
{
System.err.println("Malformed path: " + path);
fContext.close();
System.exit(1);
}
String name = path.substring(lastSlash + 1);
String parent = path.substring(0, lastSlash);
if (parent.endsWith(":"))
{
parent = parent + "/";
}
while (parent.endsWith("/") && !parent.endsWith(":/"))
{
parent = parent.substring(0, parent.length() - 1);
}
String [] ret = { parent, name };
return ret;
}
protected void copyStream(InputStream in, OutputStream out)
{
try
{
byte [] buff = new byte[8192];
int read = 0;
while ((read = in.read(buff)) != -1)
{
out.write(buff, 0, read);
}
in.close();
out.close();
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
protected abstract void run(Map<String, List<String>> flags, List<String> args);
}

View File

@@ -1,156 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
/**
* Like cp from a local filesystem to AVM.
* @author britt
*/
public class AVMCopyIn extends AVMCltBase
{
private static Object [] flagDefs = { "-r", 0, "-v", 0 };
private static String USAGE = "usage: [-r] [-v] sourcepath nodepath";
private boolean fVerbose;
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
if (flags.containsKey("-v"))
{
fVerbose = true;
}
else
{
fVerbose = false;
}
if (flags.containsKey("-r"))
{
recursiveCopy(args.get(0), args.get(1));
return;
}
File file = new File(args.get(0));
if (!file.isFile())
{
System.err.println(args.get(0) + " not found, or not a file.");
fContext.close();
System.exit(1);
}
AVMNodeDescriptor desc = fAVMRemote.lookup(-1, args.get(1));
if (desc == null)
{
try
{
String [] pathBase = splitPath(args.get(1));
if (pathBase.length == 1)
{
System.err.println(args.get(1) + " is a root path.");
fContext.close();
System.exit(1);
}
if (fVerbose)
{
System.out.println(file.getName() + " -> " + pathBase[0]);
}
InputStream in =
new FileInputStream(file);
OutputStream out = fAVMRemote.createFile(pathBase[0], pathBase[1]);
copyStream(in, out);
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
else
{
if (!desc.isDirectory())
{
System.err.println("Target must be a directory.");
fContext.close();
System.exit(1);
}
try
{
if (fVerbose)
{
System.out.println(file.getName() + " -> " + args.get(1));
}
InputStream in =
new FileInputStream(file);
OutputStream out =
fAVMRemote.createFile(args.get(1), file.getName());
copyStream(in, out);
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
}
private void recursiveCopy(String sourcePath, String dest)
{
File file = new File(sourcePath);
if (fVerbose)
{
System.out.println(sourcePath + " -> " + dest);
}
if (file.isDirectory())
{
fAVMRemote.createDirectory(dest, file.getName());
String newDest = dest + '/' + file.getName();
String [] names = file.list();
for (String name : names)
{
recursiveCopy(sourcePath + File.separatorChar + name,
newDest);
}
}
else
{
try
{
InputStream in =
new FileInputStream(file);
OutputStream out = fAVMRemote.createFile(dest, file.getName());
copyStream(in, out);
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
}
/**
* @param args
*/
public static void main(String[] args)
{
AVMCopyIn me = new AVMCopyIn();
me.exec(args, flagDefs, 2, USAGE);
}
}

View File

@@ -1,145 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
/**
* Copy out a file or a directory recursively from the repository
* to a local filesystem.
* @author britt
*/
public class AVMCopyOut extends AVMCltBase
{
private static Object [] flagDefs = { "-r", 0, "-v", 0 };
private static String USAGE = "usage: AVMCopyOut [-r] [-v] nodepath@version fspath";
private boolean fVerbose;
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
if (flags.containsKey("-v"))
{
fVerbose = true;
}
else
{
fVerbose = false;
}
String [] versionPath = args.get(0).split("@");
if (versionPath.length != 2)
{
usage(USAGE);
}
String path = versionPath[0];
int version = Integer.parseInt(versionPath[1]);
AVMNodeDescriptor desc = fAVMRemote.lookup(version, path);
if (flags.containsKey("-r"))
{
recursiveCopy(desc, args.get(1));
return;
}
if (desc == null)
{
System.err.println(versionPath[0] + " does not exist.");
fContext.close();
System.exit(1);
}
if (!desc.isFile())
{
System.err.println(versionPath[0] + " is not a file.");
fContext.close();
System.exit(1);
}
File dest = new File(args.get(1));
if (dest.exists())
{
if (!dest.isDirectory())
{
System.err.println("Destination must be a directory.");
fContext.close();
System.exit(1);
}
try
{
InputStream in = fAVMRemote.getFileInputStream(version, path);
String [] parentBase = splitPath(path);
OutputStream out = new FileOutputStream(args.get(1) + File.separator + parentBase[1]);
copyStream(in, out);
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
else
{
try
{
InputStream in = fAVMRemote.getFileInputStream(version, path);
OutputStream out = new FileOutputStream(args.get(1));
copyStream(in, out);
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
}
private void recursiveCopy(AVMNodeDescriptor src, String dst)
{
String newDst = dst + File.separator + src.getName();
if (fVerbose)
{
System.out.println(src.getPath() + " -> " + dst);
}
if (src.isDirectory())
{
File destFile = new File(newDst);
destFile.mkdir();
Map<String, AVMNodeDescriptor> listing = fAVMRemote.getDirectoryListing(src);
for (AVMNodeDescriptor child : listing.values())
{
recursiveCopy(child, newDst);
}
return;
}
try
{
InputStream in = fAVMRemote.getFileInputStream(src);
OutputStream out = new FileOutputStream(newDst);
copyStream(in, out);
}
catch (IOException e)
{
e.printStackTrace();
fContext.close();
System.exit(1);
}
}
public static void main(String[] args)
{
AVMCopyOut me = new AVMCopyOut();
me.exec(args, flagDefs, 2, USAGE);
}
}

View File

@@ -1,77 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
/**
* Get a listing of a node.
* @author britt
*/
public class AVMLs extends AVMCltBase
{
private static Object [] flagDefs = { "-R", 0 };
private static String USAGE = "usage: AVMLs [-R] nodepath";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
String[] pathVersion = args.get(0).split("@");
AVMNodeDescriptor desc = fAVMRemote.lookup(Integer.parseInt(pathVersion[1]),
pathVersion[0]);
if (flags.containsKey("-R"))
{
recursiveList(desc, 0);
}
else
{
list(desc);
}
}
private void list(AVMNodeDescriptor desc)
{
if (desc.isFile())
{
System.out.println(desc.getName() + '\t' + desc);
return;
}
Map<String, AVMNodeDescriptor> listing = fAVMRemote.getDirectoryListing(desc);
for (Map.Entry<String, AVMNodeDescriptor> entry : listing.entrySet())
{
System.out.println(entry.getKey() + '\t' + entry.getValue());
}
}
private void recursiveList(AVMNodeDescriptor desc, int indent)
{
for (int i = 0; i < indent; i++)
{
System.out.print(' ');
}
System.out.println(desc.getName() + '\t' + desc);
if (desc.isDirectory())
{
indent += 2;
Map<String, AVMNodeDescriptor> listing = fAVMRemote.getDirectoryListing(desc);
for (Map.Entry<String, AVMNodeDescriptor> entry : listing.entrySet())
{
recursiveList(entry.getValue(), indent);
}
}
}
public static void main(String[] args)
{
AVMLs me = new AVMLs();
me.exec(args, flagDefs, 1, USAGE);
}
}

View File

@@ -1,39 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
/**
* List all avm stores in the repository.
* @author britt
*/
public class AVMLsStores extends AVMCltBase
{
private static Object[] flagDefs = { };
private static String USAGE = "usage: AVMLsStores";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
List<AVMStoreDescriptor> stores = fAVMRemote.getAVMStores();
for (AVMStoreDescriptor store : stores)
{
System.out.println(store);
}
}
public static void main(String[] args)
{
AVMLsStores me = new AVMLsStores();
me.exec(args, flagDefs, 0, USAGE);
}
}

View File

@@ -1,39 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.avm.VersionDescriptor;
/**
* List all versions of a given store.
* @author britt
*/
public class AVMLsVersions extends AVMCltBase
{
private static Object [] flagDefs = { };
private static String USAGE = "usage: AVMLsVersion storename";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
List<VersionDescriptor> versions = fAVMRemote.getAVMStoreVersions(args.get(0));
for (VersionDescriptor version : versions)
{
System.out.println(version);
}
}
public static void main(String[] args)
{
AVMLsVersions me = new AVMLsVersions();
me.exec(args, flagDefs, 1, USAGE);
}
}

View File

@@ -1,68 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
/**
* Make a directory.
* @author britt
*/
public class AVMMkDir extends AVMCltBase
{
private static Object [] flagDefs = { "-p", 0 };
private static String USAGE = "usage: AVMMkDir [-p] nodepath";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
if (flags.containsKey("-p"))
{
mkdirp(args.get(0));
return;
}
String [] parentBase = splitPath(args.get(0));
if (parentBase.length == 1)
{
System.err.println(args.get(0) + " is a root path.");
fContext.close();
System.exit(1);
}
fAVMRemote.createDirectory(parentBase[0], parentBase[1]);
}
private void mkdirp(String path)
{
AVMNodeDescriptor desc = fAVMRemote.lookup(-1, path);
if (desc != null)
{
return;
}
String [] parentBase = splitPath(path);
if (parentBase.length == 1)
{
System.err.println(path + " does not exist.");
fContext.close();
System.exit(1);
}
mkdirp(parentBase[0]);
fAVMRemote.createDirectory(parentBase[0], parentBase[1]);
}
/**
* @param args
*/
public static void main(String[] args)
{
AVMMkDir me = new AVMMkDir();
me.exec(args, flagDefs, 1, USAGE);
}
}

View File

@@ -1,40 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
/**
* @author britt
*
*/
public class AVMMkLayeredDir extends AVMCltBase
{
private static Object [] flagDefs = { };
private static String USAGE = "usage: AVMMkLayeredDir nodepath targetnodepath";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
String [] pathBase = splitPath(args.get(0));
if (pathBase.length == 1)
{
System.err.println("Cannot make a layered root directory.");
fContext.close();
System.exit(1);
}
fAVMRemote.createLayeredDirectory(args.get(1), pathBase[0], pathBase[1]);
}
public static void main(String [] args)
{
AVMMkLayeredDir me = new AVMMkLayeredDir();
me.exec(args, flagDefs, 2, USAGE);
}
}

View File

@@ -1,36 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
/**
* Create an AVM store.
* @author britt
*/
public class AVMMkStore extends AVMCltBase
{
private static Object [] flagDefs = { };
private static String USAGE = "usage: AVMMkStore storename";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
fAVMRemote.createAVMStore(args.get(0));
}
/**
* @param args
*/
public static void main(String[] args)
{
AVMMkStore me = new AVMMkStore();
me.exec(args, flagDefs, 1, USAGE);
}
}

View File

@@ -1,456 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import org.alfresco.repo.avm.AVMRemote;
import org.alfresco.repo.avm.AVMRemoteInputStream;
import org.alfresco.repo.avm.AVMRemoteOutputStream;
import org.alfresco.repo.avm.AVMRemoteTransport;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.namespace.QName;
/**
* Client side wrapper for AVMRemoteTransport.
* @author britt
*/
public class AVMRemoteImpl implements AVMRemote
{
/**
* The reference to the AVMRemoteTransport instance.
*/
private AVMRemoteTransport fTransport;
/**
* Default constructor.
*/
public AVMRemoteImpl()
{
}
/**
* Set the remote transport.
*/
public void setAvmRemoteTransport(AVMRemoteTransport transport)
{
fTransport = transport;
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createAVMStore(java.lang.String)
*/
public void createAVMStore(String name)
{
fTransport.createAVMStore(ClientTicketHolder.GetTicket(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createBranch(int, java.lang.String, java.lang.String, java.lang.String)
*/
public void createBranch(int version, String srcPath, String dstPath,
String name)
{
fTransport.createBranch(ClientTicketHolder.GetTicket(), version,
srcPath, dstPath, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createDirectory(java.lang.String, java.lang.String)
*/
public void createDirectory(String path, String name)
{
fTransport.createDirectory(ClientTicketHolder.GetTicket(), path, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createFile(java.lang.String, java.lang.String)
*/
public OutputStream createFile(String path, String name)
{
return new AVMRemoteOutputStream(fTransport.createFile(ClientTicketHolder.GetTicket(), path, name), fTransport);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createLayeredDirectory(java.lang.String, java.lang.String, java.lang.String)
*/
public void createLayeredDirectory(String targetPath, String parent,
String name)
{
fTransport.createLayeredDirectory(ClientTicketHolder.GetTicket(), targetPath, parent, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createLayeredFile(java.lang.String, java.lang.String, java.lang.String)
*/
public void createLayeredFile(String targetPath, String parent, String name)
{
fTransport.createLayeredFile(ClientTicketHolder.GetTicket(), targetPath, parent, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#createSnapshot(java.lang.String)
*/
public int createSnapshot(String store, String label, String comment)
{
return fTransport.createSnapshot(ClientTicketHolder.GetTicket(), store, label, comment);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#deleteNodeProperties(java.lang.String)
*/
public void deleteNodeProperties(String path)
{
fTransport.deleteNodeProperties(ClientTicketHolder.GetTicket(), path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#deleteNodeProperty(java.lang.String, org.alfresco.service.namespace.QName)
*/
public void deleteNodeProperty(String path, QName name)
{
fTransport.deleteNodeProperty(ClientTicketHolder.GetTicket(), path, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#deleteStoreProperty(java.lang.String, org.alfresco.service.namespace.QName)
*/
public void deleteStoreProperty(String store, QName name)
{
fTransport.deleteStoreProperty(ClientTicketHolder.GetTicket(), store, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getAVMStore(java.lang.String)
*/
public AVMStoreDescriptor getAVMStore(String name)
{
return fTransport.getAVMStore(ClientTicketHolder.GetTicket(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getAVMStoreRoot(int, java.lang.String)
*/
public AVMNodeDescriptor getAVMStoreRoot(int version, String name)
{
return fTransport.getAVMStoreRoot(ClientTicketHolder.GetTicket(), version, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getAVMStoreVersions(java.lang.String)
*/
public List<VersionDescriptor> getAVMStoreVersions(String name)
{
return fTransport.getAVMStoreVersions(ClientTicketHolder.GetTicket(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getAVMStoreVersions(java.lang.String, java.util.Date, java.util.Date)
*/
public List<VersionDescriptor> getAVMStoreVersions(String name, Date from,
Date to)
{
return fTransport.getAVMStoreVersions(ClientTicketHolder.GetTicket(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getAVMStores()
*/
public List<AVMStoreDescriptor> getAVMStores()
{
return fTransport.getAVMStores(ClientTicketHolder.GetTicket());
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getCommonAncestor(org.alfresco.service.cmr.avm.AVMNodeDescriptor, org.alfresco.service.cmr.avm.AVMNodeDescriptor)
*/
public AVMNodeDescriptor getCommonAncestor(AVMNodeDescriptor left,
AVMNodeDescriptor right)
{
return fTransport.getCommonAncestor(ClientTicketHolder.GetTicket(), left, right);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getDeleted(int, java.lang.String)
*/
public List<String> getDeleted(int version, String path)
{
return fTransport.getDeleted(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getDirectoryListing(int, java.lang.String)
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
int version, String path)
{
return fTransport.getDirectoryListing(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getDirectoryListing(org.alfresco.service.cmr.avm.AVMNodeDescriptor)
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListing(
AVMNodeDescriptor dir)
{
return fTransport.getDirectoryListing(ClientTicketHolder.GetTicket(), dir);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getDirectoryListingDirect(int, java.lang.String)
*/
public SortedMap<String, AVMNodeDescriptor> getDirectoryListingDirect(
int version, String path)
{
return fTransport.getDirectoryListing(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getFileInputStream(int, java.lang.String)
*/
public InputStream getFileInputStream(int version, String path)
{
return new AVMRemoteInputStream(fTransport.getInputHandle(ClientTicketHolder.GetTicket(), version, path),
fTransport);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getFileInputStream(org.alfresco.service.cmr.avm.AVMNodeDescriptor)
*/
public InputStream getFileInputStream(AVMNodeDescriptor desc)
{
return new AVMRemoteInputStream(fTransport.getInputHandle(ClientTicketHolder.GetTicket(), desc),
fTransport);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getFileOutputStream(java.lang.String)
*/
public OutputStream getFileOutputStream(String path)
{
return new AVMRemoteOutputStream(fTransport.getOutputHandle(ClientTicketHolder.GetTicket(), path),
fTransport);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getHistory(org.alfresco.service.cmr.avm.AVMNodeDescriptor, int)
*/
public List<AVMNodeDescriptor> getHistory(AVMNodeDescriptor desc, int count)
{
return fTransport.getHistory(ClientTicketHolder.GetTicket(), desc, count);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getIndirectionPath(int, java.lang.String)
*/
public String getIndirectionPath(int version, String path)
{
return fTransport.getIndirectionPath(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getLatestSnapshotID(java.lang.String)
*/
public int getLatestSnapshotID(String storeName)
{
return fTransport.getLatestSnapshotID(ClientTicketHolder.GetTicket(), storeName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getLatestVersionID(java.lang.String)
*/
public int getLatestVersionID(String storeName)
{
return fTransport.getLatestVersionID(ClientTicketHolder.GetTicket(), storeName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getLayeringInfo(int, java.lang.String)
*/
public LayeringDescriptor getLayeringInfo(int version, String path)
{
return fTransport.getLayeringInfo(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getNodeProperties(int, java.lang.String)
*/
public Map<QName, PropertyValue> getNodeProperties(int version, String path)
{
return fTransport.getNodeProperties(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getNodeProperty(int, java.lang.String, org.alfresco.service.namespace.QName)
*/
public PropertyValue getNodeProperty(int version, String path, QName name)
{
return fTransport.getNodeProperty(ClientTicketHolder.GetTicket(), version, path, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getStoreProperties(java.lang.String)
*/
public Map<QName, PropertyValue> getStoreProperties(String store)
{
return fTransport.getStoreProperties(ClientTicketHolder.GetTicket(), store);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#getStoreProperty(java.lang.String, org.alfresco.service.namespace.QName)
*/
public PropertyValue getStoreProperty(String store, QName name)
{
return fTransport.getStoreProperty(ClientTicketHolder.GetTicket(), store, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#lookup(int, java.lang.String)
*/
public AVMNodeDescriptor lookup(int version, String path)
{
return fTransport.lookup(ClientTicketHolder.GetTicket(), version, path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#lookup(org.alfresco.service.cmr.avm.AVMNodeDescriptor, java.lang.String)
*/
public AVMNodeDescriptor lookup(AVMNodeDescriptor dir, String name)
{
return fTransport.lookup(ClientTicketHolder.GetTicket(), dir, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#makePrimary(java.lang.String)
*/
public void makePrimary(String path)
{
fTransport.makePrimary(ClientTicketHolder.GetTicket(), path);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#purgeAVMStore(java.lang.String)
*/
public void purgeAVMStore(String name)
{
fTransport.purgeAVMStore(ClientTicketHolder.GetTicket(), name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#purgeVersion(int, java.lang.String)
*/
public void purgeVersion(int version, String name)
{
fTransport.purgeVersion(ClientTicketHolder.GetTicket(), version, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#queryStorePropertyKey(java.lang.String, org.alfresco.service.namespace.QName)
*/
public Map<QName, PropertyValue> queryStorePropertyKey(String store,
QName keyPattern)
{
return fTransport.queryStorePropertyKey(ClientTicketHolder.GetTicket(), store, keyPattern);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#queryStoresPropertyKey(org.alfresco.service.namespace.QName)
*/
public Map<String, Map<QName, PropertyValue>> queryStoresPropertyKey(
QName keyPattern)
{
return fTransport.queryStoresPropertyKey(ClientTicketHolder.GetTicket(), keyPattern);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#removeNode(java.lang.String, java.lang.String)
*/
public void removeNode(String parent, String name)
{
fTransport.removeNode(ClientTicketHolder.GetTicket(), parent, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#rename(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
public void rename(String srcParent, String srcName, String dstParent,
String dstName)
{
fTransport.rename(ClientTicketHolder.GetTicket(), srcParent, srcName, dstParent, dstName);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#retargetLayeredDirectory(java.lang.String, java.lang.String)
*/
public void retargetLayeredDirectory(String path, String target)
{
fTransport.retargetLayeredDirectory(ClientTicketHolder.GetTicket(), path, target);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#setNodeProperties(java.lang.String, java.util.Map)
*/
public void setNodeProperties(String path,
Map<QName, PropertyValue> properties)
{
fTransport.setNodeProperties(ClientTicketHolder.GetTicket(), path, properties);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#setNodeProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue)
*/
public void setNodeProperty(String path, QName name, PropertyValue value)
{
fTransport.setNodeProperty(ClientTicketHolder.GetTicket(), path, name, value);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#setOpacity(java.lang.String, boolean)
*/
public void setOpacity(String path, boolean opacity)
{
fTransport.setOpacity(ClientTicketHolder.GetTicket(), path, opacity);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#setStoreProperties(java.lang.String, java.util.Map)
*/
public void setStoreProperties(String store, Map<QName, PropertyValue> props)
{
fTransport.setStoreProperties(ClientTicketHolder.GetTicket(), store, props);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#setStoreProperty(java.lang.String, org.alfresco.service.namespace.QName, org.alfresco.repo.domain.PropertyValue)
*/
public void setStoreProperty(String store, QName name, PropertyValue value)
{
fTransport.setStoreProperty(ClientTicketHolder.GetTicket(), store, name, value);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#uncover(java.lang.String, java.lang.String)
*/
public void uncover(String dirPath, String name)
{
fTransport.uncover(ClientTicketHolder.GetTicket(), dirPath, name);
}
/* (non-Javadoc)
* @see org.alfresco.repo.avm.AVMRemote#renameStore(java.lang.String, java.lang.String)
*/
public void renameStore(String sourceName, String destName)
{
fTransport.renameStore(ClientTicketHolder.GetTicket(), sourceName, destName);
}
}

View File

@@ -1,40 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
/**
* Remove an AVM Node.
* @author britt
*/
public class AVMRm extends AVMCltBase
{
private static Object [] flagDefs = { };
private static String USAGE = "usage: AVMRm nodepath";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
String [] pathBase = splitPath(args.get(0));
if (pathBase.length == 1)
{
System.err.println("One cannot remove a root node.");
fContext.close();
System.exit(1);
}
fAVMRemote.removeNode(pathBase[0], pathBase[1]);
}
public static void main(String[] args)
{
AVMRm me = new AVMRm();
me.exec(args, flagDefs, 1, USAGE);
}
}

View File

@@ -1,36 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import java.util.Map;
/**
* Snapshot a store.
* @author britt
*/
public class AVMSnapshot extends AVMCltBase
{
private static Object [] flagDefs = { };
private static String USAGE = "usage: AVMSnapshot storename label comment";
/* (non-Javadoc)
* @see org.alfresco.repo.avm.clt.AVMCltBase#run(java.util.Map, java.util.List)
*/
@Override
protected void run(Map<String, List<String>> flags, List<String> args)
{
fAVMRemote.createSnapshot(args.get(0), args.get(1), args.get(2));
}
/**
* @param args
*/
public static void main(String[] args)
{
AVMSnapshot me = new AVMSnapshot();
me.exec(args, flagDefs, 3, USAGE);
}
}

View File

@@ -1,72 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
import java.util.List;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.avmsync.AVMSyncServiceTransport;
/**
* Client side wrapper around the RMI based AVMSyncServiceTransport.
* @author britt
*/
public class AVMSyncServiceClient implements AVMSyncService
{
/**
* The instance of AVMSyncServiceTransport.
*/
private AVMSyncServiceTransport fTransport;
/**
* Default constructor.
*/
public AVMSyncServiceClient()
{
}
/**
* Set the transport for the service.
*/
public void setAvmSyncServiceTransport(AVMSyncServiceTransport transport)
{
fTransport = transport;
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avmsync.AVMSyncService#compare(int, java.lang.String, int, java.lang.String)
*/
public List<AVMDifference> compare(int srcVersion, String srcPath,
int dstVersion, String dstPath)
{
return fTransport.compare(ClientTicketHolder.GetTicket(), srcVersion, srcPath, dstVersion, dstPath);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avmsync.AVMSyncService#flatten(java.lang.String, java.lang.String)
*/
public void flatten(String layerPath, String underlyingPath)
{
fTransport.flatten(ClientTicketHolder.GetTicket(), layerPath, underlyingPath);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avmsync.AVMSyncService#resetLayer(java.lang.String)
*/
public void resetLayer(String layerPath)
{
fTransport.resetLayer(ClientTicketHolder.GetTicket(), layerPath);
}
/* (non-Javadoc)
* @see org.alfresco.service.cmr.avmsync.AVMSyncService#update(java.util.List, boolean, boolean, boolean, boolean, java.lang.String, java.lang.String)
*/
public void update(List<AVMDifference> diffList, boolean ignoreConflicts,
boolean ignoreOlder, boolean overrideConflicts,
boolean overrideOlder, String tag, String description)
{
fTransport.update(ClientTicketHolder.GetTicket(), diffList, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description);
}
}

View File

@@ -1,32 +0,0 @@
/**
*
*/
package org.alfresco.repo.avm.clt;
/**
* Remote client utility to hold an authentication ticket.
* @author britt
*/
public class ClientTicketHolder
{
/**
* Thread local tickets.
*/
private static String fTicket;
/**
* Set the ticket.
*/
public static void SetTicket(String ticket)
{
fTicket = ticket;
}
/**
* Get the ticket.
*/
public static String GetTicket()
{
return fTicket;
}
}