mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-09 17:45:10 +00:00
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:
parent
5d45de69c2
commit
e54464bf08
29
config/alfresco/avm-clt-context.xml
Normal file
29
config/alfresco/avm-clt-context.xml
Normal 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>
|
@ -10,7 +10,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.alfresco.repo.avm.AVMRemote;
|
import org.alfresco.repo.avm.AVMRemote;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ public abstract class AVMCltBase
|
|||||||
*/
|
*/
|
||||||
protected AVMCltBase()
|
protected AVMCltBase()
|
||||||
{
|
{
|
||||||
fContext = new ClassPathXmlApplicationContext("avm-clt-context.xml");
|
fContext = new ClassPathXmlApplicationContext("alfresco/avm-clt-context.xml");
|
||||||
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
|
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
|
||||||
fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService");
|
fAVMSyncService = (AVMSyncService)fContext.getBean("avmSyncService");
|
||||||
}
|
}
|
||||||
@ -76,32 +75,27 @@ public abstract class AVMCltBase
|
|||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < args.length)
|
while (pos < args.length)
|
||||||
{
|
{
|
||||||
// If the argument begins with "-" then this could be a
|
// If the argument is one of the accepted flags then it's
|
||||||
// flag.
|
// a flag.
|
||||||
if (args[pos].startsWith("-"))
|
if (flagArgs.containsKey(args[pos]))
|
||||||
{
|
{
|
||||||
// If the argument is one of the accepted flags then it's
|
String flag = args[pos];
|
||||||
// a flag.
|
pos++;
|
||||||
if (flagArgs.containsKey(args[pos]))
|
int count = flagArgs.get(flag);
|
||||||
|
// Check for too few arguments
|
||||||
|
if (args.length - pos < count)
|
||||||
{
|
{
|
||||||
String flag = args[pos];
|
usage(usageMessage);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
// 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.
|
// Otherwise its just a plain old arg.
|
||||||
actualArgs.add(args[pos]);
|
actualArgs.add(args[pos]);
|
||||||
|
77
source/java/org/alfresco/repo/avm/clt/AVMLs.java
Normal file
77
source/java/org/alfresco/repo/avm/clt/AVMLs.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
39
source/java/org/alfresco/repo/avm/clt/AVMLsStores.java
Normal file
39
source/java/org/alfresco/repo/avm/clt/AVMLsStores.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
36
source/java/org/alfresco/repo/avm/clt/AVMMkStore.java
Normal file
36
source/java/org/alfresco/repo/avm/clt/AVMMkStore.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user