}
} else {
NodeRevisionDescriptors hpathNrds = content.retrieve(sToken, hpath);
NodeRevisionDescriptor hpathNrd = content.retrieve(sToken, hpathNrds);
NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME, NamespaceCache.SLIDE_URI);
if (UriHandler.useHistoryCollectionHack) {
if (nextHnProp == null || nextHnProp.getValue() == null) {
// XXX start with historyCollectionHackChildren to assure no
// resources are created directly in history folder
nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, "10", NamespaceCache.SLIDE_URI);
nextHnProp.setKind(NodeProperty.Kind.PROTECTED);
hpathNrd.setProperty(nextHnProp);
}
String nextHnStr = (String) nextHnProp.getValue();
long nextHnLong = Long.parseLong(nextHnStr);
if (nextHnLong % 10 == 0) {
// create parent collection
long dirNum = nextHnLong / 10;
char dirChar[] = Long.toString(dirNum).toCharArray();
StringBuffer buf = new StringBuffer();
for (int i = 0; i < dirChar.length - 1; i++) {
buf.append(dirChar[i]);
buf.append('/');
}
buf.append(dirChar[dirChar.length - 1]);
String dirPath = hpath + "/" + buf.toString();
try {
structure.create(sToken, new SubjectNode(), dirPath);
//content.create(sToken,dirPath,true);
//NodeRevisionDescriptors dnrds =
// structure.retrieve(stoken,dirPath);
content.create(sToken, dirPath, new NodeRevisionDescriptor(0), null);
} catch (ObjectAlreadyExistsException oae) {
Domain.warn("Object " + dirPath + " already exists.");
} catch (RevisionAlreadyExistException rae) {
Domain.warn("Revision " + dirPath + " already exists.");
}
}
StringBuffer buf = new StringBuffer();
char nextHnChar[] = nextHnStr.toCharArray();
for (int i = 0; i < nextHnChar.length - 1; i++) {
buf.append(nextHnChar[i]);
buf.append('/');
}
buf.append('h');
buf.append(nextHnChar[nextHnChar.length - 1]);
result = new UriHandler(hpath + "/" + buf.toString());
nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, String.valueOf(nextHnLong + 1),
NamespaceCache.SLIDE_URI);
hpathNrd.setProperty(nextHnProp);
} else {
if (nextHnProp == null) {
// convert to slide namespace if this property is still
// in DAV: namespace
nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME);
if (nextHnProp != null) {
hpathNrd.removeProperty(nextHnProp);
nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, nextHnProp.getValue(),
NamespaceCache.SLIDE_URI);
nextHnProp.setKind(NodeProperty.Kind.PROTECTED);
hpathNrd.setProperty(nextHnProp);
}
}
if (nextHnProp == null || nextHnProp.getValue() == null) {
nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, I_INITIAL_HISTORY_NAME, NamespaceCache.SLIDE_URI);
nextHnProp.setKind(NodeProperty.Kind.PROTECTED);
hpathNrd.setProperty(nextHnProp);
}
String nextHnStr = (String) nextHnProp.getValue();
result = new UriHandler(hpath + "/" + nextHnStr);
long nextHnLong = Long.parseLong(nextHnStr);
nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, String.valueOf(nextHnLong + 1),
NamespaceCache.SLIDE_URI);
hpathNrd.setProperty(nextHnProp);
}
content.store(sToken, hpath, hpathNrd, null); //revisionContent = null