Merged V2.9 to HEAD

9018: MT: system-wide jobs should run across all stores/indexes
   9204: Merged V2.2 to V2.9
      8633: Merged V2.1 to V2.2
         8629: Merged V2.1-A to V2.1
            8493: Fixed ADB-51: ImporterBootstrap doesn't use transaction retrying
            8494: EHCache and JGroup patches and upgrades
            8546: ACT-1650: performance optimization
            8550: Fixes to transactional cache handling
            8553: Fixed tests: MLText is a Map, but will always have at least one entry, even that entry is null.
            8583: ACT-954: IndexInfo files now reopen when they close (for whatever reason)
      8640: Merged V2.1 to V2.2
         8638: Used correct exception type for IO channel reopen logic
      9102: Unit test to check that transactional cache size overrun is handled
      9106: Merged V2.1 to V2.2
         9043: Fixed AR-2291: SchemaBootstrap lock is only required before first SQL execution
         9045: Fix AR-2291: SchemaBootstrap lock is only required before first SQL execution
         9047: Fixed AR-2305: Index tracking in AUTO mode doesn't report anything on bootstrap
         9048: Fixed AR-2300: Random-based GUID instead of time-based GUIDs
         9049: Fix patches to only run once
         9050 <Defered>: Changed getString() method to use the available buffer length rather than a hard coded value.
         9060: Fixed ETWOONE-109 and ETWOONE-128: RetryingTransactionHelper fixes and improvements
         9061: Fixed NodeRefPropertyMethodInterceptorTest
         9075 <Defered>: Added delete permission check when marking a file for delete on close. ETWOONE-141/ACT-2416.
         9080: Fixed EHCache source zip
         9081: Fixed ETWOONE-118: Tomcat failed bootstrap doesn't clean up EHCache cluster structures
         9085: Fixed ETWOONE-154: Added JSR107 Jar to WAR
      9115: Fixed test: TransactionalCache uses LRU so repeatedly checking if a entry is there keeps it in the cache.
   9206: Merged V2.2 to V2.9
      8857: Improvements to ACL performance for large ACLs
      8951: Always check permission entry changes are made at position 0
   9219 <No change>: Made NTLMLogonDetails class Serializable, port of r8973.
   9220: Added delete permission check when marking a file for delete on close. Port of r9075.
   9222: Merged V2.1 to V2.9
      8683: Early warning for nodes indexed in the wrong store (ACT-964)
      8684: Enhanced tests
      8685: Enhanced tests
      8686: Additional tests
   9223: Merged V2.2 to V2.9
      9120: Merged V2.1 to V2.2
         8740: Fix for AR-2173 - do no recheck case of the user name when validating tickets (it has been done)
      9122: Additional unit test from support case.
   9224: Merged V2.2 to V2.9
      9076: Fixed ETWOTWO-426: Upgrading alfresco from 2.1.1 to 2.2 throws errors with Mysql 5.0.51
      9104: Merged V2.1 to V2.2
         9025: Fixed AR-2314, AR-2299: Optimizations after profiling
      9105: Merged V2.1 to V2.2
         8745: Fix AR-2233 (regression introduced by fix for AR-2221)
      9121: Merged V2.1 to V2.2
         9017: Fix index back up failing due to background index merge/deletions (inlcudes back port of CHK-2588)
      9137: Incorporated additions from Will into AVM console (ETWOTWO-439)
   9225: Merged V2.1 to V2.9
      8641: Merged V2.1-A to V2.1
         7729: Fix to Repository Web Service (queryAssociated) to allow reverse association lookup (ie. given target, get the source)
      8673: Fix for AR-2098 - shorter URL form now has NTLM filter mapping example in web.xml
      8682: Fix for AR-2005
      8695: AR-2054.
      8696: Improved sort test to include prefix form of field name
   9226: Fix ALFCOM-994 (see also earlier change in r9223)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9233 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-05-22 12:40:46 +00:00
parent 86027f41f1
commit 6e225ce15d
60 changed files with 2359 additions and 1164 deletions

View File

@@ -26,14 +26,19 @@ package org.alfresco.repo.avm;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.alfresco.repo.avm.util.BulkLoader;
import org.alfresco.repo.domain.PropertyValue;
@@ -45,6 +50,8 @@ import org.alfresco.service.cmr.avm.locking.AVMLock;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.springframework.context.support.FileSystemXmlApplicationContext;
@@ -56,6 +63,11 @@ import org.springframework.context.support.FileSystemXmlApplicationContext;
*/
public class AVMInterpreter
{
private static final Pattern collectionPattern = Pattern.compile("^\\[(.*)\\]$");
private static final Pattern nodeRefPattern = Pattern.compile("^\\w+://\\w+\\w+$");
private static final Pattern integerPattern = Pattern.compile("^\\d+$");
private static final Pattern dateTimePattern = Pattern.compile("^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$");
/**
* The service interface.
*/
@@ -169,263 +181,263 @@ public class AVMInterpreter
}
}
/**
* Interpret a single command using the BufferedReader passed in for any data needed.
* @param line The unparsed command
* @param in A Reader to be used for commands that need input data.
* @return The textual output of the command.
*/
public String interpretCommand(String line, BufferedReader in)
{
String[] command = line.split(",\\s+");
if (command.length == 0)
{
command = new String[1];
command[0] = line;
}
try
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream out = new PrintStream(bout);
if (command[0].equals("ls"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]),
command[1]);
if (desc == null)
{
return "Not Found.";
}
Map<String, AVMNodeDescriptor> listing =
fService.getDirectoryListing(desc, true);
for (String name : listing.keySet())
{
out.println(name + " " + listing.get(name));
}
}
else if (command[0].equals("lsr"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]),
command[1]);
recursiveList(out, desc, 0);
}
else if (command[0].equals("lsrep"))
{
List<AVMStoreDescriptor> repos = fService.getStores();
for (AVMStoreDescriptor repo : repos)
{
out.println(repo);
}
}
else if (command[0].equals("lsver"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
List<VersionDescriptor> listing = fService.getStoreVersions(command[1]);
for (VersionDescriptor desc : listing)
{
out.println(desc);
}
}
else if (command[0].equals("mkrep"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.createStore(command[1]);
}
else if (command[0].equals("load"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fLoader.recursiveLoad(command[1], command[2]);
}
else if (command[0].equals("mkdir"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.createDirectory(command[1], command[2]);
}
else if (command[0].equals("mkbr"))
{
if (command.length != 5)
{
return "Syntax Error.";
}
fService.createBranch(Integer.parseInt(command[4]), command[1], command[2], command[3]);
}
else if (command[0].equals("mkldir"))
{
if (command.length != 4)
{
return "Syntax Error.";
}
fService.createLayeredDirectory(command[1], command[2], command[3]);
}
else if (command[0].equals("rename"))
{
if (command.length != 5)
{
return "Syntax Error.";
}
fService.rename(command[1], command[2], command[3], command[4]);
}
else if (command[0].equals("cp"))
{
if (command.length != 5)
{
return "Syntax Error.";
}
InputStream fin = fService.getFileInputStream(Integer.parseInt(command[2]), command[1]);
OutputStream fout = fService.createFile(command[3], command[4]);
byte [] buff = new byte[8192];
int read;
while ((read = fin.read(buff)) != -1)
{
fout.write(buff, 0, read);
}
fin.close();
fout.close();
}
else if (command[0].equals("retarget"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.retargetLayeredDirectory(command[1], command[2]);
}
else if (command[0].equals("mkprimary"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.makePrimary(command[1]);
}
else if (command[0].equals("mklfile"))
{
if (command.length != 4)
{
return "Syntax Error.";
}
fService.createLayeredFile(command[1], command[2], command[3]);
}
else if (command[0].equals("snap"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.createSnapshot(command[1], null, null);
}
else if (command[0].equals("cat"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
BufferedReader reader =
new BufferedReader(
new InputStreamReader(fService.getFileInputStream(Integer.parseInt(command[2]),
command[1])));
String l;
while ((l = reader.readLine()) != null)
{
out.println(l);
}
reader.close();
}
else if (command[0].equals("rm"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.removeNode(command[1], command[2]);
}
else if (command[0].equals("rmrep"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.purgeStore(command[1]);
}
else if (command[0].equals("rmver"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.purgeVersion(Integer.parseInt(command[2]), command[1]);
}
else if (command[0].equals("write"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
PrintStream ps =
new PrintStream(fService.getFileOutputStream(command[1]));
String l;
while (!(l = in.readLine()).equals(""))
{
ps.println(l);
}
ps.close();
}
else if (command[0].equals("create"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
PrintStream ps =
new PrintStream(fService.createFile(command[1], command[2]));
String l;
while (!(l = in.readLine()).equals(""))
{
ps.println(l);
}
ps.close();
}
else if (command[0].equals("stat"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]), command[1]);
out.println(desc);
out.println("Version: " + desc.getVersionID());
out.println("Owner: " + desc.getOwner());
out.println("Mod Time: " + new Date(desc.getModDate()));
}
else if (command[0].equals("getnodeproperties"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
final Map<QName, PropertyValue> properties = fService.getNodeProperties(Integer.parseInt(command[2]), command[1]);
for (final Map.Entry<QName, PropertyValue> p : properties.entrySet())
{
out.println(p.getKey() + ": " + p.getValue());
/**
* Interpret a single command using the BufferedReader passed in for any data needed.
* @param line The unparsed command
* @param in A Reader to be used for commands that need input data.
* @return The textual output of the command.
*/
public String interpretCommand(String line, BufferedReader in)
{
String[] command = line.split(",\\s+");
if (command.length == 0)
{
command = new String[1];
command[0] = line;
}
try
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
PrintStream out = new PrintStream(bout);
if (command[0].equals("ls"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]),
command[1]);
if (desc == null)
{
return "Not Found.";
}
Map<String, AVMNodeDescriptor> listing =
fService.getDirectoryListing(desc, true);
for (String name : listing.keySet())
{
out.println(name + " " + listing.get(name));
}
}
else if (command[0].equals("lsr"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]),
command[1]);
recursiveList(out, desc, 0);
}
else if (command[0].equals("lsrep"))
{
List<AVMStoreDescriptor> repos = fService.getStores();
for (AVMStoreDescriptor repo : repos)
{
out.println(repo);
}
}
else if (command[0].equals("lsver"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
List<VersionDescriptor> listing = fService.getStoreVersions(command[1]);
for (VersionDescriptor desc : listing)
{
out.println(desc);
}
}
else if (command[0].equals("mkrep"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.createStore(command[1]);
}
else if (command[0].equals("load"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fLoader.recursiveLoad(command[1], command[2]);
}
else if (command[0].equals("mkdir"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.createDirectory(command[1], command[2]);
}
else if (command[0].equals("mkbr"))
{
if (command.length != 5)
{
return "Syntax Error.";
}
fService.createBranch(Integer.parseInt(command[4]), command[1], command[2], command[3]);
}
else if (command[0].equals("mkldir"))
{
if (command.length != 4)
{
return "Syntax Error.";
}
fService.createLayeredDirectory(command[1], command[2], command[3]);
}
else if (command[0].equals("rename"))
{
if (command.length != 5)
{
return "Syntax Error.";
}
fService.rename(command[1], command[2], command[3], command[4]);
}
else if (command[0].equals("cp"))
{
if (command.length != 5)
{
return "Syntax Error.";
}
InputStream fin = fService.getFileInputStream(Integer.parseInt(command[2]), command[1]);
OutputStream fout = fService.createFile(command[3], command[4]);
byte [] buff = new byte[8192];
int read;
while ((read = fin.read(buff)) != -1)
{
fout.write(buff, 0, read);
}
fin.close();
fout.close();
}
else if (command[0].equals("retarget"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.retargetLayeredDirectory(command[1], command[2]);
}
else if (command[0].equals("mkprimary"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.makePrimary(command[1]);
}
else if (command[0].equals("mklfile"))
{
if (command.length != 4)
{
return "Syntax Error.";
}
fService.createLayeredFile(command[1], command[2], command[3]);
}
else if (command[0].equals("snap"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.createSnapshot(command[1], null, null);
}
else if (command[0].equals("cat"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
BufferedReader reader =
new BufferedReader(
new InputStreamReader(fService.getFileInputStream(Integer.parseInt(command[2]),
command[1])));
String l;
while ((l = reader.readLine()) != null)
{
out.println(l);
}
reader.close();
}
else if (command[0].equals("rm"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.removeNode(command[1], command[2]);
}
else if (command[0].equals("rmrep"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
fService.purgeStore(command[1]);
}
else if (command[0].equals("rmver"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.purgeVersion(Integer.parseInt(command[2]), command[1]);
}
else if (command[0].equals("write"))
{
if (command.length != 2)
{
return "Syntax Error.";
}
PrintStream ps =
new PrintStream(fService.getFileOutputStream(command[1]));
String l;
while (!(l = in.readLine()).equals(""))
{
ps.println(l);
}
ps.close();
}
else if (command[0].equals("create"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
PrintStream ps =
new PrintStream(fService.createFile(command[1], command[2]));
String l;
while (!(l = in.readLine()).equals(""))
{
ps.println(l);
}
ps.close();
}
else if (command[0].equals("stat"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
AVMNodeDescriptor desc = fService.lookup(Integer.parseInt(command[2]), command[1]);
out.println(desc);
out.println("Version: " + desc.getVersionID());
out.println("Owner: " + desc.getOwner());
out.println("Mod Time: " + new Date(desc.getModDate()));
}
else if (command[0].equals("getnodeproperties"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
final Map<QName, PropertyValue> properties = fService.getNodeProperties(Integer.parseInt(command[2]), command[1]);
for (final Map.Entry<QName, PropertyValue> p : properties.entrySet())
{
out.println(p.getKey() + ": " + p.getValue());
}
}
else if (command[0].equals("descnode"))
@@ -602,6 +614,73 @@ public class AVMInterpreter
return "Syntax Error.";
}
fSyncService.flatten(command[1], command[2]);
}
else if (command[0].equals("getnodeaspects"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
final Set<QName> aspects = fService.getAspects(Integer.parseInt(command[2]), command[1]);
for (final QName qn : aspects)
{
out.println(qn.toString());
}
}
else if (command[0].equals("addnodeaspect"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.addAspect(command[1], QName.createQName(command[2]));
}
else if (command[0].equals("deletenodeaspect"))
{
if (command.length != 3)
{
return "Syntax Error.";
}
fService.removeAspect(command[1], QName.createQName(command[2]));
}
else if (command[0].equals("setnodeproperty"))
{
if (command.length < 4)
{
return "Syntax Error.";
}
QName valueQName = QName.createQName(command[2]);
String propertyValue = "";
// If multiple values are specified then concatenate the values
if (command.length > 4)
{
StringBuffer sb = new StringBuffer();
for (int i=3; i<command.length; i++)
{
// Add each value in turn
sb.append(command[i]);
}
propertyValue = sb.toString();
}
else
{
propertyValue = command[3];
}
// Pass setNodeProperty() the serializable value
Serializable serializableValue = convertValueFromSring(propertyValue);
QName valueTypeQName = getValueTypeQName(propertyValue);
fService.setNodeProperty(command[1], valueQName, new PropertyValue(valueTypeQName, serializableValue));
out.println("set property " + command[2] + " of " + command[1]);
}
else
{
@@ -636,8 +715,100 @@ public class AVMInterpreter
}
}
}
}
private static Serializable convertValueFromSring(String sValue)
{
Serializable retValue = "";
CharSequence seq = sValue.subSequence(0, sValue.length());
if (collectionPattern.matcher(seq).matches())
{
String[] elements = getCSVArray(sValue.substring(1, sValue.length()-1));
// Should this be an ArrayList or a HashSet?
Collection<Serializable> propValues = new HashSet<Serializable>(elements.length);
for (int i=0; i<elements.length; i++)
{
// Add each value in turn unless it is empty
if (!"".equals(elements[i]))
{
propValues.add(convertValueFromSring(elements[i]));
}
}
retValue = (Serializable)propValues;
}
else if (nodeRefPattern.matcher(seq).matches())
{
retValue = new NodeRef(sValue);
}
else if (integerPattern.matcher(seq).matches())
{
retValue = new Integer(sValue);
}
else if (dateTimePattern.matcher(seq).matches())
{
// TODO: Support timestamps
/*
DateFormat df = DateFormat.getDateTimeInstance(dateStyle, timeStyle)df.pa
Calendar cal = Calendar.getInstance();
retValue = new NodeRef(dateTimePattern.matcher(seq).group(1));
*/
} else
{
retValue = sValue;
}
return retValue;
}
private static QName getValueTypeQName(String sValue)
{
QName typeQName = null;
CharSequence seq = sValue.subSequence(0, sValue.length());
if (collectionPattern.matcher(seq).matches())
{
String[] elements = getCSVArray(sValue.substring(1, sValue.length()-1));
if (elements[0] != "")
{
typeQName = getValueTypeQName(elements[0]);
}
}
else if (nodeRefPattern.matcher(seq).matches())
{
typeQName = DataTypeDefinition.NODE_REF;
}
else if (integerPattern.matcher(seq).matches())
{
typeQName = DataTypeDefinition.INT;
}
else if (dateTimePattern.matcher(seq).matches())
{
// TODO: Support timestamps
/*
DateFormat df = DateFormat.getDateTimeInstance(dateStyle, timeStyle)df.pa
Calendar cal = Calendar.getInstance();
retValue = new NodeRef(dateTimePattern.matcher(seq).group(1));
*/
typeQName = DataTypeDefinition.DATETIME;
} else
{
typeQName = DataTypeDefinition.TEXT;
}
return typeQName;
}
private static String[] getCSVArray(String valueString)
{
String[] elements = valueString.split(",\\s+");
if (elements.length == 0)
{
elements = new String[1];
elements[0] = valueString;
}
return elements;
}
}