replace(DB.path_data, sPathData+sXmlFileName+" ("+oFmt.format(dtCreated)+").xml");
store(oConn);
setCreationDate(oConn, dtCreated);
PageSet oPSet = null;
try {
oPSet = new PageSet(sStorage+sPathMetadata, sStorage+oSource.getString(DB.path_data), false);
} catch (Exception xcpt) {
throw new IOException(xcpt.getMessage(), xcpt);
}
Node oRoot = oPSet.getRootNode();
Node oPgst = oPSet.seekChildByName(oRoot, "pageset");
if (DebugFile.trace) DebugFile.writeln("PageSet.setAttribute("+oPgst+",\"guid\",\""+getString(DB.gu_pageset)+"\")");
oPSet.setAttribute(oPgst, "guid", getString(DB.gu_pageset));
PageDB[] aPags = oSource.getPages(oConn);
if (aPags!=null) {
if (DebugFile.trace) DebugFile.writeln("PageSet.seekChildByName("+oPgst+",\"pages\")");
Node oPags = oPSet.seekChildByName(oPgst,"pages");
if (DebugFile.trace) DebugFile.writeln("PageSet.filterChildsByName("+oPags+",\"page\")");
Vector<DOMSubDocument> vPags = oPSet.filterChildsByName((Element) oPags, "page");
for (int p=0; p<aPags.length; p++) {
PageDB oPage = aPags[p];
oPage.replace(DB.gu_page, Gadgets.generateUUID());
oPage.replace(DB.gu_pageset, getString(DB.gu_pageset));
oPage.remove(DB.dt_modified);
String sTlPage = oPage.getString(DB.tl_page);
iParenthesis = sTlPage.indexOf('(');
if (iParenthesis>0) sTlPage = sTlPage.substring(0, iParenthesis)+" ("+oFmt.format(dtCreated)+").html";
if (DebugFile.trace) DebugFile.writeln("PageDB.replace(DB.tl_page, \""+sTlPage+"\")");
oPage.replace(DB.tl_page, sTlPage);
final String sSrcPathPage = oPage.getString(DB.path_page);
String sPathPage = sSrcPathPage;
iLastSlash = sPathPage.indexOf("/"+oSource.getString(DB.gu_pageset)+"/");
if (-1==iLastSlash) iLastSlash = sPathPage.indexOf("\\"+oSource.getString(DB.gu_pageset)+"\\");
char cSep = sPathPage.charAt(iLastSlash);
String sPathPages = sPathPage.substring(0, ++iLastSlash)+getString(DB.gu_pageset);
sPathPage = sPathPages+cSep+sTlPage.replace(' ','_');
if (DebugFile.trace) DebugFile.writeln("Page.replace(DB.path_page, \""+sPathPages+cSep+sTlPage.replace(' ','_')+"\")");
oPage.replace(DB.path_page, sPathPages+cSep+sTlPage.replace(' ','_'));
oPage.store(oConn);
oPage.setCreationDate(oConn, dtCreated);
oPSet.setAttribute(vPags.get(p).getNode(), "guid", oPage.getString(DB.gu_page));
try {
oFS.mkdirs(sProtocol+sPathPages);
if (oFS.exists(sProtocol+sSrcPathPage))
oFS.copy(sProtocol+sSrcPathPage, sProtocol+sPathPage);
} catch (Exception xcpt) {
throw new IOException(xcpt.getMessage(), xcpt);
}
} // next
} // fi (aPags)
oPSet.save(sStorage+getString(DB.path_data));
if (DebugFile.trace) {
DebugFile.decIdent();
DebugFile.writeln("End PageSetDB.clone()");
}