Aktueller Stand ccm-sci-publicpersonalprofile
git-svn-id: https://svn.libreccm.org/ccm/trunk@1001 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
c3f13c765b
commit
94a846d859
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package com.arsdigita.london.exporter;
|
||||
|
||||
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.Folder;
|
||||
|
|
@ -39,13 +37,10 @@ import org.apache.log4j.Logger;
|
|||
public class ContentExporter {
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -59,18 +54,20 @@ public class ContentExporter {
|
|||
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,
|
||||
Filter f =
|
||||
folders.addInSubqueryFilter(ACSObject.ID,
|
||||
"com.arsdigita.london.exporter.itemIDsInSection");
|
||||
f.set("sectionID", section.getID());
|
||||
folders.addEqualsFilter("isDeleted", Boolean.FALSE);
|
||||
|
|
@ -80,24 +77,29 @@ 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());
|
||||
|
|
@ -105,12 +107,14 @@ public class ContentExporter {
|
|||
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) {
|
||||
|
|
@ -125,29 +129,36 @@ public class ContentExporter {
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
|
@ -169,7 +180,9 @@ public class ContentExporter {
|
|||
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);
|
||||
|
|
@ -192,11 +205,11 @@ public class ContentExporter {
|
|||
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);
|
||||
|
|
@ -204,14 +217,16 @@ public class ContentExporter {
|
|||
|
||||
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);
|
||||
DomainObjectExporter exporter = new DomainObjectExporter(el,
|
||||
m_assetDir);
|
||||
exporter.setNamespace("cms", CMS.CMS_XML_NS);
|
||||
exporter.setWrapAttributes(true);
|
||||
exporter.setWrapRoot(false);
|
||||
|
|
@ -228,7 +243,7 @@ public class ContentExporter {
|
|||
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -248,7 +263,7 @@ public class ContentExporter {
|
|||
item);
|
||||
}
|
||||
|
||||
String ancestors = (String)item.get(ContentItem.ANCESTORS);
|
||||
String ancestors = (String) item.get(ContentItem.ANCESTORS);
|
||||
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Ancestors " + ancestors);
|
||||
|
|
@ -266,10 +281,11 @@ public class ContentExporter {
|
|||
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;
|
||||
|
|
@ -281,6 +297,6 @@ public class ContentExporter {
|
|||
s_log.warn("No ancestors parent for " + path);
|
||||
return null;
|
||||
}
|
||||
return path.substring(0, offset+1);
|
||||
return path.substring(0, offset + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.SciPublicPersonalProfile"
|
||||
extends="com.arsdigita.cms.ContentPage">
|
||||
|
||||
<xrd:attributes rule="exclude">
|
||||
<xrd:property name="/object/profileUrl"/>
|
||||
</xrd:attributes>
|
||||
</xrd:adapter>
|
||||
|
||||
</xrd:context>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
</requires>
|
||||
<provides>
|
||||
<table name="ct_sci_public_personal_profiles"/>
|
||||
<initalizer class="com.arsdigita.cms.contenttypes.SciPublicPersonalProfileInizalizer"/>
|
||||
<initializer class="com.arsdigita.cms.contenttypes.SciPublicPersonalProfileInitializer"/>
|
||||
</provides>
|
||||
<scripts>
|
||||
<schema directory="ccm-sci-publicpersonalprofile"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue