diff --git a/ccm-ldn-exporter/src/com/arsdigita/london/exporter/ContentExporter.java b/ccm-ldn-exporter/src/com/arsdigita/london/exporter/ContentExporter.java
index b77001236..ebf4a8630 100755
--- a/ccm-ldn-exporter/src/com/arsdigita/london/exporter/ContentExporter.java
+++ b/ccm-ldn-exporter/src/com/arsdigita/london/exporter/ContentExporter.java
@@ -1,7 +1,5 @@
-
package com.arsdigita.london.exporter;
-
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.Folder;
@@ -16,7 +14,7 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.Filter;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.domain.DataObjectNotFoundException;
-
+
import com.arsdigita.xml.Document;
import com.arsdigita.xml.Element;
@@ -37,15 +35,12 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.log4j.Logger;
public class ContentExporter {
-
- private static final Logger s_log = Logger.getLogger(ContentExporter.class);
+ private static final Logger s_log = Logger.getLogger(ContentExporter.class);
private Map m_folders;
private Map m_elements;
private Map m_paths;
-
private List m_items;
-
private File m_itemDir;
private File m_assetDir;
@@ -58,20 +53,22 @@ public class ContentExporter {
m_paths = new HashMap();
m_items = new ArrayList();
}
-
-
+
public void exportManifest(ContentSection section,
String version,
String systemID) {
Session session = SessionManager.getSession();
if (!m_itemDir.exists() && !m_itemDir.mkdirs()) {
- throw new UncheckedWrapperException(new IOException("mkdirs " + m_itemDir + " failed"));
+ throw new UncheckedWrapperException(new IOException("mkdirs "
+ + m_itemDir
+ + " failed"));
}
-
+
DataCollection folders = session.retrieve(Folder.BASE_DATA_OBJECT_TYPE);
- Filter f = folders.addInSubqueryFilter(ACSObject.ID,
- "com.arsdigita.london.exporter.itemIDsInSection");
+ Filter f =
+ folders.addInSubqueryFilter(ACSObject.ID,
+ "com.arsdigita.london.exporter.itemIDsInSection");
f.set("sectionID", section.getID());
folders.addEqualsFilter("isDeleted", Boolean.FALSE);
folders.addEqualsFilter("version", version);
@@ -80,37 +77,44 @@ public class ContentExporter {
Element root = null;
while (folders.next()) {
- Folder folder = (Folder)DomainObjectFactory
- .newInstance(folders.getDataObject());
-
+ Folder folder = (Folder) DomainObjectFactory.newInstance(folders.
+ getDataObject());
+
Folder parent = getParent(folder);
if (s_log.isDebugEnabled()) {
- s_log.debug("Folder" + folder.getOID() + " parent " + (parent == null ? null : parent.getOID()));
+ s_log.debug("Folder" + folder.getOID() + " parent " + (parent
+ == null
+ ? null
+ : parent.
+ getOID()));
}
-
+
if (parent != null || folder.getName().equals("/")) {
Element pel = null;
if (parent != null) {
- pel = (Element)m_elements.get(parent);
+ pel = (Element) m_elements.get(parent);
}
s_log.debug("Processing " + folder + " " + pel);
-
+
if (pel == null && parent != null) {
s_log.debug("Oh damn " + folder.getOID());
- throw new RuntimeException("No elemnent for " + parent.getOID());
+ throw new RuntimeException("No elemnent for " + parent.
+ getOID());
}
Element el = new Element("cms:folder", CMS.CMS_XML_NS);
el.addAttribute("name", folder.getName());
el.addAttribute("label", folder.getLabel());
el.addAttribute("oid", folder.getOID().toString());
-
+
m_elements.put(folder, el);
- String path = (parent == null ? "" : m_paths.get(parent) + "/" + folder.getName());
+ String path = (parent == null ? "" : m_paths.get(parent) + "/"
+ + folder.getName());
m_paths.put(folder, path);
File dir = new File(m_itemDir, path);
-
+
if (!dir.exists() && !dir.mkdir()) {
- throw new UncheckedWrapperException(new IOException("mkdir " + dir + " failed"));
+ throw new UncheckedWrapperException(new IOException(
+ "mkdir " + dir + " failed"));
}
if (pel != null) {
@@ -124,30 +128,37 @@ public class ContentExporter {
s_log.warn("Skip " + folder.getOID() + " " + folder.getName());
}
}
-
- DataCollection items = session.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
+
+ DataCollection items = session.retrieve(
+ ContentPage.BASE_DATA_OBJECT_TYPE);
items.addEqualsFilter("isDeleted", Boolean.FALSE);
items.addEqualsFilter("version", version);
items.addOrder("ancestors");
while (items.next()) {
- ContentPage item = (ContentPage)DomainObjectFactory
- .newInstance(items.getDataObject());
+ ContentPage item =
+ (ContentPage) DomainObjectFactory.newInstance(items.
+ getDataObject());
- if (item.getObjectType().getQualifiedName().equals("com.arsdigita.london.cms.freeform.FreeformContentItem")) {
+ if (item.getObjectType().getQualifiedName().equals(
+ "com.arsdigita.london.cms.freeform.FreeformContentItem")) {
continue;
}
-
+
Folder parent = getParent(item);
if (s_log.isDebugEnabled()) {
- s_log.debug("Item" + item.getOID() + " parent " + (parent == null ? null : parent.getOID()));
+ s_log.debug("Item" + item.getOID() + " parent " + (parent
+ == null
+ ? null
+ : parent.
+ getOID()));
}
if (parent == null) {
s_log.warn("Skipping item " + item.getOID() + " has no parent");
continue;
}
- Element pel = (Element)m_elements.get(parent);
+ Element pel = (Element) m_elements.get(parent);
if (pel == null) {
throw new RuntimeException("No elemnent for " + parent.getOID());
}
@@ -161,26 +172,28 @@ public class ContentExporter {
pel.addContent(el);
s_log.debug("Adding " + el + " to " + pel + " path");
-
+
m_items.add(item.getOID());
}
-
+
Document doc = null;
try {
s_log.debug("Got root " + root);
-
- Element imp = new Element("imp:import", "http://xmlns.redhat.com/waf/london/importer/1.0");
+
+ Element imp =
+ new Element("imp:import",
+ "http://xmlns.redhat.com/waf/london/importer/1.0");
imp.addAttribute("source", systemID);
imp.addContent(root);
doc = new Document(imp);
} catch (ParserConfigurationException ex) {
throw new UncheckedWrapperException(ex);
}
-
+
try {
File dst = new File(m_itemDir, "index.xml");
FileOutputStream os = new FileOutputStream(dst, false);
-
+
os.write(doc.toString(true).getBytes("UTF-8"));
os.flush();
os.close();
@@ -188,50 +201,52 @@ public class ContentExporter {
throw new UncheckedWrapperException("cannot write file", ex);
}
}
-
+
public void exportItems() {
Iterator oids = m_items.iterator();
while (oids.hasNext()) {
- TransactionContext txn = SessionManager.getSession()
- .getTransactionContext();
+ TransactionContext txn = SessionManager.getSession().
+ getTransactionContext();
txn.beginTxn();
- OID oid = (OID)oids.next();
-
+ OID oid = (OID) oids.next();
+
if (s_log.isInfoEnabled()) {
s_log.info("Exporting item " + oid);
}
-
+
ContentPage item = null;
try {
- item = (ContentPage)DomainObjectFactory.newInstance(oid);
+ item = (ContentPage) DomainObjectFactory.newInstance(oid);
} catch (DataObjectNotFoundException ex) {
- throw new UncheckedWrapperException("cannot find item " + oid, ex);
+ throw new UncheckedWrapperException("cannot find item " + oid,
+ ex);
}
-
-
- Element el = new Element("cms:item", CMS.CMS_XML_NS);
- DomainObjectExporter exporter = new DomainObjectExporter(el, m_assetDir);
+
+
+ Element el = new Element("cms:item", CMS.CMS_XML_NS);
+ DomainObjectExporter exporter = new DomainObjectExporter(el,
+ m_assetDir);
exporter.setNamespace("cms", CMS.CMS_XML_NS);
exporter.setWrapAttributes(true);
exporter.setWrapRoot(false);
exporter.setWrapObjects(false);
exporter.walk(item,
getClass().getName());
-
+
Document doc = null;
try {
doc = new Document(el);
} catch (ParserConfigurationException ex) {
throw new UncheckedWrapperException(ex);
}
-
-
+
+
try {
- String path = (String)m_paths.get(item);
+ String path = (String) m_paths.get(item);
File dst = new File(m_itemDir, "." + path);
FileOutputStream os = new FileOutputStream(dst);
-
+
os.write(doc.toString(true).getBytes("UTF-8"));
os.flush();
os.close();
@@ -241,19 +256,19 @@ public class ContentExporter {
txn.commitTxn();
}
}
-
+
protected Folder getParent(ContentItem item) {
if (item instanceof Folder) {
m_folders.put(item.get(ContentItem.ANCESTORS),
item);
}
- String ancestors = (String)item.get(ContentItem.ANCESTORS);
-
+ String ancestors = (String) item.get(ContentItem.ANCESTORS);
+
if (s_log.isDebugEnabled()) {
s_log.debug("Ancestors " + ancestors);
}
-
+
String base = null;
if (item instanceof Folder) {
@@ -265,22 +280,23 @@ public class ContentExporter {
if (base == null) {
return null;
}
-
- Folder parent = (Folder)m_folders.get(base);
-
+
+ Folder parent = (Folder) m_folders.get(base);
+
if (s_log.isDebugEnabled()) {
- s_log.debug("Item " + item.getOID() + " with " + ancestors + " parent " + base + " obj " + parent);
+ s_log.debug("Item " + item.getOID() + " with " + ancestors
+ + " parent " + base + " obj " + parent);
}
-
+
return parent;
}
-
+
protected String getParentPath(String path) {
int offset = path.lastIndexOf("/", path.length() - 2);
if (offset == -1) {
s_log.warn("No ancestors parent for " + path);
return null;
}
- return path.substring(0, offset+1);
+ return path.substring(0, offset + 1);
}
}
diff --git a/ccm-sci-publicpersonalprofile/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciPublicPersonalProfile.xml b/ccm-sci-publicpersonalprofile/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciPublicPersonalProfile.xml
index 42333aa0e..f3fa86c48 100644
--- a/ccm-sci-publicpersonalprofile/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciPublicPersonalProfile.xml
+++ b/ccm-sci-publicpersonalprofile/src/WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/SciPublicPersonalProfile.xml
@@ -18,7 +18,9 @@
-
+
+
+
diff --git a/ccm-sci-publicpersonalprofile/src/ccm-sci-publicpersonalprofile.load b/ccm-sci-publicpersonalprofile/src/ccm-sci-publicpersonalprofile.load
index 6ddfce203..7914916ac 100644
--- a/ccm-sci-publicpersonalprofile/src/ccm-sci-publicpersonalprofile.load
+++ b/ccm-sci-publicpersonalprofile/src/ccm-sci-publicpersonalprofile.load
@@ -17,7 +17,7 @@
-
+