First three AVM CLTs.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4467 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park 2006-11-30 05:07:54 +00:00
parent 5d45de69c2
commit e54464bf08
5 changed files with 200 additions and 25 deletions

View File

@ -0,0 +1,29 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Remote AVM interface -->
<bean id="avmRemote" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl">
<value>rmi://localhost:1313/avm</value>
</property>
<property name="serviceInterface">
<value>org.alfresco.repo.avm.AVMRemote</value>
</property>
<property name="refreshStubOnConnectFailure">
<value>true</value>
</property>
</bean>
<bean id="avmSyncService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
<property name="serviceUrl">
<value>rmi://localhost:1313/avmsync</value>
</property>
<property name="serviceInterface">
<value>org.alfresco.service.cmr.avmsync.AVMSyncService</value>
</property>
<property name="refreshStubOnConnectFailure">
<value>true</value>
</property>
</bean>
</beans>

View File

@ -10,7 +10,6 @@ import java.util.Map;
import org.alfresco.repo.avm.AVMRemote;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.util.Pair;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@ -43,7 +42,7 @@ public abstract class AVMCltBase
*/
protected AVMCltBase()
{
fContext = new ClassPathXmlApplicationContext("avm-clt-context.xml");
fContext = new ClassPathXmlApplicationContext("alfresco/avm-clt-context.xml");
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService");
}
@ -76,32 +75,27 @@ public abstract class AVMCltBase
int pos = 0;
while (pos < args.length)
{
// If the argument begins with "-" then this could be a
// flag.
if (args[pos].startsWith("-"))
// If the argument is one of the accepted flags then it's
// a flag.
if (flagArgs.containsKey(args[pos]))
{
// 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)
{
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;
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]);

View File

@ -0,0 +1,77 @@
/**
*
*/
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

@ -0,0 +1,39 @@
/**
*
*/
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

@ -0,0 +1,36 @@
/**
*
*/
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);
}
}