String dir = pathBuffer.toString();
try {
structure.retrieve(sToken, dir);
} catch (ObjectNotFoundException onfe) {
try {
structure.create(sToken, new SubjectNode(), dir);
content.create(sToken, dir, new NodeRevisionDescriptor(0), null);
} catch (ObjectAlreadyExistsException oae) {
Domain.warn("Object " + dir + " already exists.");
} catch (RevisionAlreadyExistException rae) {
Domain.warn("Revision " + dir + " already exists.");
}
}
}
// make hpath/1/2/3/h4 out of 1234
pathBuffer.append("/h").append(nextHnStr.charAt(nextHnStr.length() - 1));
String fullPath = pathBuffer.toString();
return new UriHandler(fullPath);
} else {
return new UriHandler(uniqueUri);
}
} 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) {