Merged V3.3-BUG-FIX to HEAD

21634: Fix ALF-3822: Storing of datetime does not work
   21646: ALF-3752: Getting Parent on a specific version throws exception
   21655: Fix ALF-4006: Incorrect search result after renaming a folder
   21659: Workaround for ALF-4230: use of flash technology to upload documents into a share site makes the use of (some) external authentication methods difficult (or impossible)
      - The Flash uploader can be disabled via share-config: DocumentLibary / file-upload / adobe-flash-enabled
   21675: AVM - build/test fix (testSubmitUpdatedItemWithLF)
   21687: Merged V3.3 to V3.3-BUG-FIX
      21650: Fix for ALF-4239: Cannot open any folder that contains a node that is neither folder nor content in Share repo browser
      21658: Merged HEAD to BRANCHES/V3.3:
         21557: Fix ALF-4141: Cannot create relationship via OpenCMIS
      21673: ALF-1905: Corrected LDAP connection validation to allow synchronization connection to use anonymous bind
      21686: Merged PATCHES/V3.3.1 to V3.3
         21684: ALF-4039: Use ISO 9705-style encoding to ensure that compound WCM store names do not collide when user names contain illegal characters
            - Previously, characters that were illegal were just replaced with _ so there could be collisions in store names
            - Also, the sequence -- in a user name or user names "preview" and "workflow" would have been problematic.
         21535: (RECORD ONLY) Merged V3.3 to PATCHES/V3.3.1
            20778: Added revision to version label.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21689 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2010-08-09 15:28:11 +00:00
parent b51e8ef744
commit 420caeac25
6 changed files with 147 additions and 41 deletions

View File

@@ -1172,6 +1172,8 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
public String getWebdavUrl() public String getWebdavUrl()
{ {
try try
{
if (getIsContainer() || getIsDocument())
{ {
List<FileInfo> paths = this.services.getFileFolderService().getNamePath(null, getNodeRef()); List<FileInfo> paths = this.services.getFileFolderService().getNamePath(null, getNodeRef());
@@ -1187,11 +1189,13 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
} }
return path.toString(); return path.toString();
} }
}
catch (FileNotFoundException nodeErr) catch (FileNotFoundException nodeErr)
{ {
// cannot build path if file no longer exists // cannot build path if file no longer exists
return ""; return "";
} }
return "";
} }
/** /**

View File

@@ -372,14 +372,14 @@ public class LDAPInitialDirContextFactoryImpl implements LDAPInitialDirContextFa
// Check more if we have a real principal we expect to work // Check more if we have a real principal we expect to work
env = new Hashtable<String, String>(defaultEnvironment.size()); String principal = defaultEnvironment.get(Context.SECURITY_PRINCIPAL);
env.putAll(defaultEnvironment); if (principal != null)
if (env.get(Context.SECURITY_PRINCIPAL) != null)
{ {
// Correct principal invalid password // Correct principal invalid password
env = new Hashtable<String, String>(defaultEnvironment.size()); env = new Hashtable<String, String>(authenticatedEnvironment.size());
env.putAll(defaultEnvironment); env.putAll(authenticatedEnvironment);
env.put(Context.SECURITY_PRINCIPAL, principal);
env.put(Context.SECURITY_CREDENTIALS, "sdasdasdasdasd123123123"); env.put(Context.SECURITY_CREDENTIALS, "sdasdasdasdasd123123123");
try try
{ {

View File

@@ -403,6 +403,8 @@ public abstract class BaseContentNode implements TemplateContent
public String getWebdavUrl() public String getWebdavUrl()
{ {
try try
{
if (getIsContainer() || getIsDocument())
{ {
List<FileInfo> paths = this.services.getFileFolderService().getNamePath(null, getNodeRef()); List<FileInfo> paths = this.services.getFileFolderService().getNamePath(null, getNodeRef());
@@ -418,11 +420,13 @@ public abstract class BaseContentNode implements TemplateContent
} }
return path.toString(); return path.toString();
} }
}
catch (FileNotFoundException nodeErr) catch (FileNotFoundException nodeErr)
{ {
// cannot build path if file no longer exists // cannot build path if file no longer exists
return ""; return "";
} }
return "";
} }
/** /**

View File

@@ -29,12 +29,12 @@ public class FileNameValidator
/** /**
* The bad file name pattern. * The bad file name pattern.
*/ */
private static final Pattern FILENAME_ILLEGAL_PATTERN = Pattern.compile(".*[\"\\*\\\\><\\?/:\\|]+.*"); public static final String FILENAME_ILLEGAL_REGEX = "[\\\"\\*\\\\\\>\\<\\?\\/\\:\\|]";
private static final Pattern FILENAME_ILLEGAL_PATTERN_REPLACE = Pattern.compile("[\\\"\\*\\\\\\>\\<\\?\\/\\:\\|]"); private static final Pattern FILENAME_ILLEGAL_PATTERN_REPLACE = Pattern.compile(FILENAME_ILLEGAL_REGEX);
public static boolean isValid(String name) public static boolean isValid(String name)
{ {
return !FILENAME_ILLEGAL_PATTERN.matcher(name).matches(); return !FILENAME_ILLEGAL_PATTERN_REPLACE.matcher(name).find();
} }
/** /**

View File

@@ -1496,6 +1496,7 @@ public class SandboxServiceImplTest extends AbstractWCMServiceImplTest
// submit (new assets) ! // submit (new assets) !
sbService.submitWebApp(authorSandboxIdA, webAppA, "A1", "A1"); sbService.submitWebApp(authorSandboxIdA, webAppA, "A1", "A1");
// wait for submit to complete
pollForSnapshotCount(stagingSandboxIdA, 1); pollForSnapshotCount(stagingSandboxIdA, 1);
assets = sbService.listChangedWebApp(authorSandboxIdA, webAppA, false); assets = sbService.listChangedWebApp(authorSandboxIdA, webAppA, false);
@@ -1531,6 +1532,9 @@ public class SandboxServiceImplTest extends AbstractWCMServiceImplTest
assertEquals(1, assetService.listAssets(authorSandboxIdB, -1, authorSandboxPathB, false).size()); assertEquals(1, assetService.listAssets(authorSandboxIdB, -1, authorSandboxPathB, false).size());
assets = sbService.listChangedWebApp(authorSandboxIdB, webAppB, false);
assertEquals(0, assets.size());
// modify file // modify file
final String MYFILE_MODIFIED = "This is testfile.txt modified in BBB"; final String MYFILE_MODIFIED = "This is testfile.txt modified in BBB";
@@ -1542,18 +1546,12 @@ public class SandboxServiceImplTest extends AbstractWCMServiceImplTest
assets = sbService.listChangedWebApp(authorSandboxIdB, webAppB, false); assets = sbService.listChangedWebApp(authorSandboxIdB, webAppB, false);
assertEquals(1, assets.size()); assertEquals(1, assets.size());
// ETHREEOH_2836 // ETHREEOH-2836
assertEquals(AVMDifference.NEWER, assets.get(0).getDiffCode()); assertEquals(AVMDifference.NEWER, assets.get(0).getDiffCode());
// initiate submit (modified asset) // initiate submit (modified asset)
sbService.submitWebApp(authorSandboxIdB, webAppB, "B1", "B1"); sbService.submitWebApp(authorSandboxIdB, webAppB, "B1", "B1");
assets = sbService.listChangedWebApp(authorSandboxIdB, webAppB, false);
assertEquals(1, assets.size());
// ETHREEOH_2836
assertEquals(AVMDifference.NEWER, assets.get(0).getDiffCode());
// wait for submit to complete // wait for submit to complete
pollForSnapshotCount(stagingSandboxIdB, 1); pollForSnapshotCount(stagingSandboxIdB, 1);

View File

@@ -195,9 +195,8 @@ public class WCMUtil extends AVMUtil
storeName = WCMUtil.getCorrespondingMainStoreName(storeName); storeName = WCMUtil.getCorrespondingMainStoreName(storeName);
} }
final int index = storeName.indexOf(WCMUtil.STORE_SEPARATOR); final int index = storeName.indexOf(WCMUtil.STORE_SEPARATOR);
return (index == -1 return (index == -1 ? null : unescapeStoreNameComponent(storeName.substring(index
? null + WCMUtil.STORE_SEPARATOR.length())));
: storeName.substring(index + WCMUtil.STORE_SEPARATOR.length()));
} }
/** /**
@@ -303,6 +302,104 @@ public class WCMUtil extends AVMUtil
return (buildAVMPath(otherStoreName, WCMUtil.getStoreRelativePath(avmPath))); return (buildAVMPath(otherStoreName, WCMUtil.getStoreRelativePath(avmPath)));
} }
/**
* Utility function for escaping part of a compound store name (delimited by STORE_SEPARATOR sequences). Uses ISO
* 9075 style encoding to escape otherwise problematic character sequences.
*
* @param component
* the component
* @return the escaped string
*/
private static final String escapeStoreNameComponent(String component)
{
StringBuilder builder = null;
int length = component.length();
// If the component matches one of the common suffixes, encode it
if (component.equals(STORE_PREVIEW) || component.equals(STORE_WORKFLOW))
{
builder = new StringBuilder(length + 5);
appendEncoded(builder, component);
return builder.toString();
}
// Look for problematic character sequences
Matcher matcher = PATTERN_ILLEGAL_SEQUENCE.matcher(component);
int lastAppendPosition = 0;
while (matcher.find())
{
if (builder == null)
{
builder = new StringBuilder(length + 5);
}
if (matcher.start() != lastAppendPosition)
{
builder.append(component, lastAppendPosition, matcher.start());
}
lastAppendPosition = matcher.end();
appendEncoded(builder, matcher.group());
}
if (builder == null)
{
return component;
}
if (lastAppendPosition < length)
{
builder.append(component, lastAppendPosition, length);
}
return builder.toString();
}
/**
* Utility function for decoding from Strings produced by the above method.
*
* @param component
* the encoded component
* @return the decoded component
*/
private static String unescapeStoreNameComponent(String component)
{
StringBuilder builder = null;
int length = component.length();
int lastAppendPosition = 0;
int escapeIndex;
while ((escapeIndex = component.indexOf("_x", lastAppendPosition)) != -1)
{
if (builder == null)
{
builder = new StringBuilder(length + 5);
}
if (escapeIndex != lastAppendPosition)
{
builder.append(component, lastAppendPosition, escapeIndex);
}
lastAppendPosition = component.indexOf('_', escapeIndex + 2);
builder.appendCodePoint(Integer.parseInt(component.substring(escapeIndex + 2, lastAppendPosition), 16));
lastAppendPosition++;
}
if (builder == null)
{
return component;
}
if (lastAppendPosition < length)
{
builder.append(component, lastAppendPosition, length);
}
return builder.toString();
}
private static final void appendEncoded(StringBuilder builder, String sequence)
{
builder.append("_x").append(Integer.toString(sequence.codePointAt(0), 16).toUpperCase()).append("_");
int length = sequence.length();
int next = sequence.offsetByCodePoints(0, 1);
if (next < length)
{
builder.append(sequence, next, length);
}
}
/** /**
* Returns the main staging store name for the specified web project * Returns the main staging store name for the specified web project
* *
@@ -340,7 +437,7 @@ public class WCMUtil extends AVMUtil
final String userName) final String userName)
{ {
ParameterCheck.mandatoryString("userName", userName); ParameterCheck.mandatoryString("userName", userName);
String fixedUserName = FileNameValidator.getValidFileName(userName); String fixedUserName = escapeStoreNameComponent(userName);
return (WCMUtil.buildStagingStoreName(storeId) + WCMUtil.STORE_SEPARATOR + return (WCMUtil.buildStagingStoreName(storeId) + WCMUtil.STORE_SEPARATOR +
fixedUserName); fixedUserName);
} }
@@ -754,6 +851,9 @@ public class WCMUtil extends AVMUtil
// Component Separator. // Component Separator.
protected static final String STORE_SEPARATOR = "--"; protected static final String STORE_SEPARATOR = "--";
/** Matches character sequences that must be escaped in a compound store name. */
protected static final Pattern PATTERN_ILLEGAL_SEQUENCE = Pattern.compile(FileNameValidator.FILENAME_ILLEGAL_REGEX + "|_x|" + STORE_SEPARATOR);
// names of the stores representing the layers for an AVM website // names of the stores representing the layers for an AVM website
//XXXarielb this should be private //XXXarielb this should be private
protected final static String STORE_WORKFLOW = "workflow"; protected final static String STORE_WORKFLOW = "workflow";