Revised Exporter for migration to 7.x.y

git-svn-id: https://svn.libreccm.org/ccm/trunk@5713 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2018-10-24 17:18:34 +00:00
parent 6c51705394
commit 66906c722b
177 changed files with 3753 additions and 1180 deletions

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.assets;
import com.arsdigita.cms.contentassets.FileAttachment;
import com.arsdigita.cms.portation.modules.assets.FileAsset;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class FileAssetConversion extends AbstractConversion {
public class FileAssetConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all
* trunk-{@link com.arsdigita.cms.contentassets.FileAttachment}s from the

View File

@ -20,7 +20,8 @@ package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.contentassets.FileAttachment;
import com.arsdigita.cms.portation.conversion.NgCmsFileAssetCollection;
import com.arsdigita.portation.Portable;
import org.libreccm.export.convert.Portable;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>

View File

@ -21,8 +21,9 @@ package com.arsdigita.cms.portation.conversion.assets;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.portation.modules.assets.Image;
import com.arsdigita.cms.portation.modules.assets.LegalMetadata;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -30,7 +31,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 5/2/18
*/
public class ImageConversion extends AbstractConversion {
public class ImageConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.ImageAsset}s from the
* persistent storage and collects them in a list. Then calls for

View File

@ -20,7 +20,8 @@ package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.ImageAsset;
import com.arsdigita.cms.portation.conversion.NgCmsImageCollection;
import com.arsdigita.portation.Portable;
import org.libreccm.export.convert.Portable;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
/**

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.assets;
import com.arsdigita.cms.contentassets.Note;
import com.arsdigita.cms.portation.modules.assets.SideNote;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 5/2/18
*/
public class SideNoteConversion extends AbstractConversion {
public class SideNoteConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contentassets.Note}s from
* the persistent storage and collects them in a list. Then calls for

View File

@ -21,8 +21,9 @@ package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.contentassets.Note;
import com.arsdigita.cms.portation.conversion.NgCmsSideNoteCollection;
import com.arsdigita.cms.portation.modules.contentsection.Asset;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.Locale;

View File

@ -19,8 +19,9 @@
package com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.portation.modules.contenttypes.Article;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -28,7 +29,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/19/18
*/
public class ArticleConversion extends AbstractConversion {
public class ArticleConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contenttypes.Article}s
* from the persistent storage and collects them in a list. Then calls

View File

@ -22,8 +22,9 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.portation.conversion.NgCmsArticleCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.Locale;

View File

@ -19,8 +19,9 @@
package com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.portation.modules.contenttypes.Event;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -28,7 +29,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/19/18
*/
public class EventConversion extends AbstractConversion {
public class EventConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contenttypes.Event}s from
* the persistent storage and collects them in a list. Then calls for

View File

@ -22,8 +22,9 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.portation.conversion.NgCmsEventCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.Date;
import java.util.Locale;

View File

@ -21,8 +21,9 @@ package com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.contenttypes.ArticleSectionCollection;
import com.arsdigita.cms.portation.conversion.NgCmsMPArticleCollection;
import com.arsdigita.cms.portation.modules.contenttypes.MultiPartArticle;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -30,7 +31,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class MultiPartArticleConversion extends AbstractConversion {
public class MultiPartArticleConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all
* trunk-{@link com.arsdigita.cms.contenttypes.MultiPartArticle}s from the

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.contenttypes.ArticleSection;
import com.arsdigita.cms.portation.modules.contenttypes.MultiPartArticleSection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class MultiPartArticleSectionConversion extends AbstractConversion {
public class MultiPartArticleSectionConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all
* trunk-{@link ArticleSection}s from the

View File

@ -22,8 +22,9 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.portation.conversion.NgCmsMPArticleCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.ArrayList;

View File

@ -22,8 +22,9 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.contenttypes.ArticleSection;
import com.arsdigita.cms.portation.conversion.NgCmsMPArticleCollection;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.Locale;

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.contenttypes;
import com.arsdigita.cms.contenttypes.NewsItem;
import com.arsdigita.cms.portation.modules.contenttypes.News;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/20/18
*/
public class NewsConversion extends AbstractConversion {
public class NewsConversion extends AbstractDomainObjectsConverter {
/**
* Retrieves all trunk-{@link com.arsdigita.cms.contenttypes.NewsItem}s
* from the persistent storage and collects them in a list. Then calls for

View File

@ -23,8 +23,9 @@ import com.arsdigita.cms.ItemCollection;
import com.arsdigita.cms.contenttypes.NewsItem;
import com.arsdigita.cms.portation.conversion.NgCmsNewsCollection;
import com.arsdigita.cms.portation.modules.contentsection.ContentItem;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.Date;
import java.util.Locale;

View File

@ -57,9 +57,10 @@ import org.xml.sax.helpers.DefaultHandler;
/**
* <p>
* A Content Type defines the characteristics of a content item. Content management resources are
* registered to a content type, including the {@link com.arsdigita.cms.AuthoringKit Authoring Kit},
* and {@link com.arsdigita.cms.Template templates}.</p>
* A Content Type defines the characteristics of a content item. Content
* management resources are registered to a content type, including the
* {@link com.arsdigita.cms.AuthoringKit Authoring Kit}, and
* {@link com.arsdigita.cms.Template templates}.</p>
*
* <p>
* Each content type is associated with a {@link
@ -73,19 +74,23 @@ import org.xml.sax.helpers.DefaultHandler;
public class ContentType extends ACSObject {
/**
* Internal logger instance to faciliate debugging. Enable logging output by editing
* /WEB-INF/conf/log4j.properties int hte runtime environment and set
* com.arsdigita.cms.ui.authoring.NewItemForm=DEBUG by uncommenting or adding the line.
* Internal logger instance to faciliate debugging. Enable logging output by
* editing /WEB-INF/conf/log4j.properties int hte runtime environment and
* set com.arsdigita.cms.ui.authoring.NewItemForm=DEBUG by uncommenting or
* adding the line.
*/
private static final Logger s_log = Logger.getLogger(ContentType.class);
public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.ContentType";
public static final String BASE_DATA_OBJECT_TYPE
= "com.arsdigita.cms.ContentType";
/**
* The path content types are expected to store their type definition file (usually
* [domainObjectBaseName].xml by convention). Any content item should use this location unless
* there are good reasons for a different location.
* The path content types are expected to store their type definition file
* (usually [domainObjectBaseName].xml by convention). Any content item
* should use this location unless there are good reasons for a different
* location.
*/
public static final String CONTENTTYPE_DEFINITIONFILE_PATH = "/WEB-INF/content-types/";
public static final String CONTENTTYPE_DEFINITIONFILE_PATH
= "/WEB-INF/content-types/";
public static final String OBJECT_TYPE = "associatedObjectType";
/**
* The name or title of the content type, e.g. "File Storage Item"
@ -115,10 +120,12 @@ public class ContentType extends ACSObject {
}
/**
* Constructor. The contained <code>DataObject</code> is retrieved from the persistent storage
* mechanism with an <code>OID</code> specified by <i>oid</i>.
* Constructor. The contained <code>DataObject</code> is retrieved from the
* persistent storage mechanism with an <code>OID</code> specified by
* <i>oid</i>.
*
* @param oid The <code>OID</code> for the retrieved <code>DataObject</code>.
* @param oid The <code>OID</code> for the retrieved
* <code>DataObject</code>.
*
*/
public ContentType(OID oid) throws DataObjectNotFoundException {
@ -126,9 +133,9 @@ public class ContentType extends ACSObject {
}
/**
* Constructor. The contained <code>DataObject</code> is retrieved from the persistent storage
* mechanism with an <code>OID</code> specified by <i>id</i> and
* <code>ContentType.BASE_DATA_OBJECT_TYPE</code>.
* Constructor. The contained <code>DataObject</code> is retrieved from the
* persistent storage mechanism with an <code>OID</code> specified by
* <i>id</i> and <code>ContentType.BASE_DATA_OBJECT_TYPE</code>.
*
* @param id The <code>id</code> for the retrieved <code>DataObject</code>.
*
@ -146,8 +153,8 @@ public class ContentType extends ACSObject {
}
/**
* @return the base PDL object type for this item. Child classes should override this method to
* return the correct value
* @return the base PDL object type for this item. Child classes should
* override this method to return the correct value
*/
@Override
public String getBaseDataObjectType() {
@ -163,9 +170,9 @@ public class ContentType extends ACSObject {
}
/**
* Returns the object type of the items of this content type. (For example: If I create a
* ContentType "foo". Then a I create an item "bar" of type foo. This associated object type is
* the same as bar.getObjectType())
* Returns the object type of the items of this content type. (For example:
* If I create a ContentType "foo". Then a I create an item "bar" of type
* foo. This associated object type is the same as bar.getObjectType())
*
* @return The data object type representation of this content type
*/
@ -183,15 +190,17 @@ public class ContentType extends ACSObject {
}
/**
* Fetches the label for the content type. The label is a globalized notation displayed to the
* user to identify the content type. As an example a content type named "Article" (as in
* getName()) will be displayed in an english environment as the label "Article", in German as
* Fetches the label for the content type. The label is a globalized
* notation displayed to the user to identify the content type. As an
* example a content type named "Article" (as in getName()) will be
* displayed in an english environment as the label "Article", in German as
* "Artikel", etc.
*
* The label is retrieved from content type's resources. The message uses some convention to
* retrieve the message key and resource bundle.
* The label is retrieved from content type's resources. The message uses
* some convention to retrieve the message key and resource bundle.
*
* Client classes may overwrite the method to provide a label from a different source.
* Client classes may overwrite the method to provide a label from a
* different source.
*
* @return The (globalized) label.
*/
@ -225,7 +234,8 @@ public class ContentType extends ACSObject {
// We assume the name of the key in resource bundle is the same as
// the ObjectType minus the domain part ("com.arsdigita.")
// and starting with "cms" and suffix ".type_label" appended
String labelKey = objectTypeName.substring(objectTypeName.indexOf("cms"))
String labelKey = objectTypeName
.substring(objectTypeName.indexOf("cms"))
.concat(".type_label")
.toLowerCase();
if (s_log.isDebugEnabled()) {
@ -234,7 +244,8 @@ public class ContentType extends ACSObject {
// First try: check, if the resource file really exists, and if it does,
// use it.
if (this.getClass().getClassLoader().getResource(bundleResourcePath) != null) {
if (this.getClass().getClassLoader().getResource(bundleResourcePath)
!= null) {
s_log.debug("Found resource file, using it.");
// Property file exists, use it!
final String bundleName = objectTypeName.concat("Resources");
@ -243,7 +254,8 @@ public class ContentType extends ACSObject {
} else {
s_log.debug("No resource file found, using item's definition file");
// No property file found, try to use the item's definition file
final InputStream defFile = Thread.currentThread().getContextClassLoader()
final InputStream defFile = Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream(typeResourcePath);
if (defFile == null) {
@ -266,17 +278,20 @@ public class ContentType extends ACSObject {
// As a proper example:
// /WEB-INF/content-types/com.arsditita.cms.contenttypes.Event.xml
try {
final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
final SAXParserFactory parserFactory = SAXParserFactory
.newInstance();
final SAXParser parser = parserFactory.newSAXParser();
final BundleName bundleName = new BundleName();
parser.parse(defFile, bundleName);
if (bundleName.getName() == null) {
// Fallback to the non-globalized identifier (name)
s_log.warn("Failed to translate content type name. No bundle found.");
s_log.warn(
"Failed to translate content type name. No bundle found.");
return new GlobalizedMessage(getName());
} else {
label = new GlobalizedMessage(labelKey, bundleName.getName());
label = new GlobalizedMessage(labelKey, bundleName
.getName());
}
} catch (ParserConfigurationException ex) {
s_log.warn("Failed to translate content type name:", ex);
@ -337,10 +352,11 @@ public class ContentType extends ACSObject {
}
/**
* Fetches the name for the content type. The name is a fixed String, which 'names' a content
* type and is not localizible. It is stored in the database and a symbolic name for the formal
* ID. It may contain any characters but is preferable an english term. Examples are "FAQ item"
* or "Article" or "Multipart Article". It has to be unique system-wide.
* Fetches the name for the content type. The name is a fixed String, which
* 'names' a content type and is not localizible. It is stored in the
* database and a symbolic name for the formal ID. It may contain any
* characters but is preferable an english term. Examples are "FAQ item" or
* "Article" or "Multipart Article". It has to be unique system-wide.
*
* @return The name (ie. may be used as a non-localized label)
*/
@ -353,8 +369,9 @@ public class ContentType extends ACSObject {
*
* @see getName() for additional details.
*
* The name is stored in the database. In the database this property is stored under 'label',
* when globliation was not an issue. The Method is primarly used in the initial loading step.
* The name is stored in the database. In the database this property is
* stored under 'label', when globliation was not an issue. The Method is
* primarly used in the initial loading step.
*
* @param name The name
*/
@ -400,19 +417,24 @@ public class ContentType extends ACSObject {
/**
* <p>
* An internal content type is one that is not user-defined and maintained internally. A content
* type should be made internal under the following two conditions:</p>
* An internal content type is one that is not user-defined and maintained
* internally. A content type should be made internal under the following
* two conditions:</p>
*
* <ol>
* <li>The object type needs to take advantage of content type services (i.e., versioning,
* categorization, lifecycle, workflow) that are already implemented in CMS.</li>
* <li>The content type cannot be explicitly registered to a content section.</li>
* <li>The object type needs to take advantage of content type services
* (i.e., versioning, categorization, lifecycle, workflow) that are already
* implemented in CMS.</li>
* <li>The content type cannot be explicitly registered to a content
* section.</li>
* </ol>
*
* <p>
* The {@link com.arsdigita.cms.Template} content type is one such internal content type.</p>
* The {@link com.arsdigita.cms.Template} content type is one such internal
* content type.</p>
*
* @return Boolean.TRUE if this content type is internal, Boolean.FALSE otherwise.
* @return Boolean.TRUE if this content type is internal, Boolean.FALSE
* otherwise.
*/
public Boolean isInternal() {
return "I".equalsIgnoreCase((String) get(MODE));
@ -420,11 +442,13 @@ public class ContentType extends ACSObject {
/**
* <p>
* A hidden content type is one that is not user-defined but not meant to be used directly (p.
* ex. GenericArticle). in contrast they provide some basic features for different kind of
* content type to be extended from. Also, they are legit perents for UDCTs.
* A hidden content type is one that is not user-defined but not meant to be
* used directly (p. ex. GenericArticle). in contrast they provide some
* basic features for different kind of content type to be extended from.
* Also, they are legit perents for UDCTs.
*
* @return Boolean.TRUE if this content type is internal, Boolean.FALSE otherwise.
* @return Boolean.TRUE if this content type is internal, Boolean.FALSE
* otherwise.
*/
public Boolean isHidden() {
return "H".equalsIgnoreCase((String) get(MODE));
@ -462,18 +486,19 @@ public class ContentType extends ACSObject {
}
/**
* Create an authoring kit to this content type. To save this authoring kit, you need to call
* <code>save()</code> method on the returned AuthoringKit.
* Create an authoring kit to this content type. To save this authoring kit,
* you need to call <code>save()</code> method on the returned AuthoringKit.
*/
public AuthoringKit createAuthoringKit() {
return createAuthoringKit(null);
}
/**
* Create an authoring kit to this content type. To save this authoring kit, you need to call
* <code>save()</code> method on the returned AuthoringKit.
* Create an authoring kit to this content type. To save this authoring kit,
* you need to call <code>save()</code> method on the returned AuthoringKit.
*
* @param createComponent the create component class associated with the authoring kit
* @param createComponent the create component class associated with the
* authoring kit
*/
public AuthoringKit createAuthoringKit(String createComponent) {
@ -491,20 +516,22 @@ public class ContentType extends ACSObject {
}
/**
* Fetch the item creation form id of the Java domain object implementation. applies to
* user-defined types
* Fetch the item creation form id of the Java domain object implementation.
* applies to user-defined types
*
* @return The id of the persistent form used to create an item of this content type
* @return The id of the persistent form used to create an item of this
* content type
*/
public BigDecimal getItemFormID() {
return (BigDecimal) get(ITEM_FORM_ID);
}
/**
* Sets the item creation form id of the Java domain object implementation. applies to
* user-defined types
* Sets the item creation form id of the Java domain object implementation.
* applies to user-defined types
*
* @param itemFormID The id of the persistent form used to create an item of this content type
* @param itemFormID The id of the persistent form used to create an item of
* this content type
*/
public void setItemFormID(BigDecimal itemFormID) {
set(ITEM_FORM_ID, itemFormID);
@ -513,8 +540,8 @@ public class ContentType extends ACSObject {
/**
* Retrieve the persistent form of this content type
*
* @return the persistent form used to create or edit content items of this type (only applies
* to user-defined types)
* @return the persistent form used to create or edit content items of this
* type (only applies to user-defined types)
*/
public PersistentForm getItemForm() throws DataObjectNotFoundException {
@ -692,7 +719,8 @@ public class ContentType extends ACSObject {
}
/**
* Fetches a collection of all content types, including internal content types.
* Fetches a collection of all content types, including internal content
* types.
*
* @return A collection of all content types
*/
@ -701,9 +729,11 @@ public class ContentType extends ACSObject {
}
/**
* Fetches a collection of all content types, including internal content types.
* Fetches a collection of all content types, including internal content
* types.
*
* @param hidden If false, fetch all content types, ecluding hidden content types
* @param hidden If false, fetch all content types, ecluding hidden content
* types
*
* @return A collection of all content types
*/
@ -721,11 +751,15 @@ public class ContentType extends ACSObject {
}
/**
* @param internal If false, fetch all content types, excluding internal content types.
* @param hidden If false, fetch all content types, excluding hidden content types.
* @param internal If false, fetch all content types, excluding internal
* content types.
* @param hidden If false, fetch all content types, excluding hidden
* content types.
*/
private static ContentTypeCollection getAllContentTypes(boolean internal, boolean hidden) {
DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
private static ContentTypeCollection getAllContentTypes(boolean internal,
boolean hidden) {
DataCollection da = SessionManager.getSession().retrieve(
BASE_DATA_OBJECT_TYPE);
ContentTypeCollection types = new ContentTypeCollection(da);
if (!internal) {
@ -739,8 +773,8 @@ public class ContentType extends ACSObject {
}
/**
* Fetches a collection of content types that have been registered to at least one content
* section, excluding internal content types.
* Fetches a collection of content types that have been registered to at
* least one content section, excluding internal content types.
*
* @return A collection of registered content types
*/
@ -771,9 +805,11 @@ public class ContentType extends ACSObject {
// Or must be a descendant of the requested type
try {
StringTokenizer strTok = new StringTokenizer(ct.getDescendants(), "/");
StringTokenizer strTok = new StringTokenizer(ct.getDescendants(),
"/");
while (strTok.hasMoreElements()) {
or.addFilter(ff.equals(ContentType.ID, (String) strTok.nextElement()));
or.addFilter(ff.equals(ContentType.ID, (String) strTok
.nextElement()));
}
} catch (Exception ex) {
// WTF? The selected content type does not exist in the table???
@ -786,7 +822,8 @@ public class ContentType extends ACSObject {
private static List s_xsl = new ArrayList();
/**
* Registers an XSL file against a content type. NB this interface is liable to change.
* Registers an XSL file against a content type. NB this interface is liable
* to change.
*
* @param type the content type
* @param path the path relative to the server root
@ -796,7 +833,8 @@ public class ContentType extends ACSObject {
}
/**
* Unregisters an XSL file against a content type. NB this interface is liable to change.
* Unregisters an XSL file against a content type. NB this interface is
* liable to change.
*
* @param type the content type
* @param path the path relative to the server root
@ -893,8 +931,8 @@ public class ContentType extends ACSObject {
}
/**
* Retrieves all objects of this type stored in the database. Very
* necessary for exporting all entities of the current work environment.
* Retrieves all objects of this type stored in the database. Very necessary
* for exporting all entities of the current work environment.
*
* @return List of all objects
*/
@ -916,4 +954,5 @@ public class ContentType extends ACSObject {
collection.close();
return objectList;
}
}

View File

@ -25,7 +25,8 @@ import com.arsdigita.cms.portation.conversion.lifecycle.LifecycleConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.LifecycleDefinitionConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.PhaseConversion;
import com.arsdigita.cms.portation.conversion.lifecycle.PhaseDefinitionConversion;
import com.arsdigita.portation.AbstractConverter;
import org.libreccm.export.convert.AbstractDomainObjectConverter;
import java.lang.reflect.Method;
@ -33,7 +34,7 @@ import java.lang.reflect.Method;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/12/18
*/
public class CmsConverter extends AbstractConverter {
public class CmsConverter extends AbstractDomainObjectConverter {
private static CmsConverter instance;
static {

View File

@ -29,10 +29,14 @@ import com.arsdigita.cms.portation.modules.contentsection.ContentType;
import com.arsdigita.cms.portation.modules.contentsection.Folder;
import com.arsdigita.cms.portation.modules.contentsection.FolderType;
import com.arsdigita.kernel.RoleCollection;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.workflow.Workflow;
import com.arsdigita.workflow.simple.TaskCollection;
import com.arsdigita.workflow.simple.WorkflowTemplate;
@ -42,7 +46,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/16/18
*/
public class ContentSectionConversion extends AbstractConversion {
public class ContentSectionConversion extends AbstractDomainObjectsConverter {
private static ContentSectionConversion instance;
static {
@ -107,12 +111,12 @@ public class ContentSectionConversion extends AbstractConversion {
contentSection.setRootAssetsFolder(rootAssetsFolder);
rootAssetsFolder.setSection(contentSection);
// set roles
// set ROLES
RoleCollection roleCollection = trunkContentSection
.getStaffGroup().getRoles();
while (roleCollection.next()) {
contentSection.addRole(NgCoreCollection
.roles
contentSection.addRole(CcmCoreEntities
.ROLES
.get(roleCollection
.getRole()
.getID()
@ -156,8 +160,8 @@ public class ContentSectionConversion extends AbstractConversion {
TaskCollection workflowTemplateCollection = trunkContentSection
.getWorkflowTemplates();
while (workflowTemplateCollection.next()) {
final Workflow template = NgCoreCollection
.workflows
final Workflow template = CcmCoreEntities
.WORKFLOWS
.get(workflowTemplateCollection
.getTask()
.getID()
@ -207,8 +211,8 @@ public class ContentSectionConversion extends AbstractConversion {
ContentTypeWorkflowTemplate.getWorkflowTemplate(
trunkContentSection, trunkContentType);
if (trunkWorkflowTemplate != null) {
final Workflow defaultWorkflow = NgCoreCollection
.workflows
final Workflow defaultWorkflow = CcmCoreEntities
.WORKFLOWS
.get(trunkWorkflowTemplate
.getID()
.longValue());

View File

@ -19,8 +19,9 @@
package com.arsdigita.cms.portation.conversion.contentsection;
import com.arsdigita.cms.portation.modules.contentsection.ContentType;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -28,7 +29,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/16/18
*/
public class ContentTypeConversion extends AbstractConversion {
public class ContentTypeConversion extends AbstractDomainObjectsConverter {
private static ContentTypeConversion instance;
static {

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.contentsection;
import com.arsdigita.cms.portation.modules.contentsection.Folder;
import com.arsdigita.cms.portation.modules.contentsection.FolderType;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 4/16/18
*/
public class FolderConversion extends AbstractConversion {
public class FolderConversion extends AbstractDomainObjectsConverter {
private static FolderConversion instance;
static {

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 3/26/18
*/
public class LifecycleConversion extends AbstractConversion {
public class LifecycleConversion extends AbstractDomainObjectsConverter {
private static LifecycleConversion instance;
static {

View File

@ -21,8 +21,9 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.lifecycle.PhaseDefinitionCollection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -30,7 +31,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 3/26/18
*/
public class LifecycleDefinitionConversion extends AbstractConversion {
public class LifecycleDefinitionConversion extends AbstractDomainObjectsConverter {
private static LifecycleDefinitionConversion instance;
static {

View File

@ -21,8 +21,9 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle;
import com.arsdigita.cms.portation.modules.lifecycle.Phase;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -30,7 +31,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 3/26/18
*/
public class PhaseConversion extends AbstractConversion {
public class PhaseConversion extends AbstractDomainObjectsConverter {
private static PhaseConversion instance;
static {

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.conversion.lifecycle;
import com.arsdigita.cms.portation.modules.lifecycle.PhaseDefinition;
import com.arsdigita.portation.AbstractConversion;
import com.arsdigita.portation.cmd.ExportLogger;
import org.libreccm.export.convert.AbstractDomainObjectsConverter;
import org.libreccm.export.cmd.ExportLogger;
import java.util.List;
@ -29,7 +30,7 @@ import java.util.List;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 3/26/18
*/
public class PhaseDefinitionConversion extends AbstractConversion {
public class PhaseDefinitionConversion extends AbstractDomainObjectsConverter {
private static PhaseDefinitionConversion instance;
static {

View File

@ -18,13 +18,13 @@
*/
package com.arsdigita.cms.portation.modules;
import com.arsdigita.portation.AbstractExporter;
import org.libreccm.export.convert.AbstractExporterManager;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/12/18
*/
public class CmsExporter extends AbstractExporter {
public class CmsExporter extends AbstractExporterManager {
private static CmsExporter instance;
static {

View File

@ -20,10 +20,12 @@ package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.contentsection.Asset;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.l10n.LocalizedString;
import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
import java.util.Locale;
/**

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.modules.assets;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.contentsection.Asset;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.ArrayList;
import java.util.List;

View File

@ -20,8 +20,11 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigDecimal;

View File

@ -20,8 +20,9 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@ -21,9 +21,13 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.contentsection.util.ContentItemVersionMapper;
import com.arsdigita.cms.portation.modules.lifecycle.Lifecycle;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.workflow.Workflow;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@ -20,9 +20,13 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
import com.arsdigita.portation.modules.core.security.Role;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import org.libreccm.security.Role;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.Workflow;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@ -21,10 +21,14 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.cms.portation.modules.contentsection.util.ContentTypeModeMapper;
import com.arsdigita.cms.portation.modules.lifecycle.LifecycleDefinition;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import org.libreccm.export.convert.Portable;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.workflow.Workflow;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.Locale;

View File

@ -20,8 +20,11 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.modules.core.categorization.Category;
import com.arsdigita.portation.modules.core.categorization.util.CategoryInformation;
import org.libreccm.categorization.Category;
import org.libreccm.export.convert.categorization.util.CategoryInformation;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**

View File

@ -20,7 +20,8 @@ package com.arsdigita.cms.portation.modules.contentsection;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.Portable;
import org.libreccm.export.convert.Portable;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.UUID;

View File

@ -19,7 +19,8 @@
package com.arsdigita.cms.portation.modules.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.portation.Portable;
import org.libreccm.export.convert.Portable;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@ -19,8 +19,9 @@
package com.arsdigita.cms.portation.modules.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.ArrayList;

View File

@ -19,7 +19,8 @@
package com.arsdigita.cms.portation.modules.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.portation.Portable;
import org.libreccm.export.convert.Portable;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import java.util.Date;

View File

@ -19,8 +19,9 @@
package com.arsdigita.cms.portation.modules.lifecycle;
import com.arsdigita.cms.portation.conversion.NgCmsCollection;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.l10n.LocalizedString;
import java.util.Locale;

View File

@ -52,7 +52,22 @@ import com.arsdigita.webdevsupport.WebDevSupport;
import com.arsdigita.workflow.simple.TaskComment;
import org.apache.log4j.Logger;
import org.libreccm.categorization.CategoriesExporter;
import org.libreccm.categorization.CategorizationsExporter;
import org.libreccm.core.ResourceTypesExporter;
import org.libreccm.export.ExportManager;
import org.libreccm.security.GroupMembershipsExporter;
import org.libreccm.security.GroupsExporter;
import org.libreccm.security.PermissionsExporter;
import org.libreccm.security.RoleMembershipsExporter;
import org.libreccm.security.RolesExporter;
import org.libreccm.security.UsersExporter;
import org.libreccm.workflow.AssignableTasksExporter;
import org.libreccm.workflow.TaskAssignmentsExporter;
import org.libreccm.workflow.TaskCommentsExporter;
import org.libreccm.workflow.TaskDependenciesExporter;
import org.libreccm.workflow.TasksExporter;
import org.libreccm.workflow.WorkflowsExporter;
/**
* CoreInitializer
@ -75,10 +90,10 @@ public class Initializer extends CompoundInitializer {
s_log.info("Ading Sub-Initilizers ...");
add(new com.arsdigita.persistence.Initializer());
add(new PDLInitializer
(new ManifestSource
("ccm-core.pdl.mf",
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
add(new PDLInitializer(new ManifestSource("ccm-core.pdl.mf",
new NameFilter(DbHelper
.getDatabaseSuffix(
database), "pdl"))));
add(new com.arsdigita.ui.Initializer());
add(new com.arsdigita.kernel.Initializer());
@ -92,97 +107,114 @@ public class Initializer extends CompoundInitializer {
}
/**
*
* @param e
*/
@Override
public final void init(final DomainInitEvent e) {
super.init(e);
public final void init(final DomainInitEvent event) {
super.init(event);
s_log.debug("Running core init(DomainInitEvent) ...");
e.getFactory().registerInstantiator
(Host.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
Host.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() {
public DomainObject doNewInstance(DataObject dobj) {
public DomainObject doNewInstance(final DataObject dobj) {
return new Host(dobj);
}
});
e.getFactory().registerInstantiator
(ApplicationType.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
ApplicationType.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() {
public DomainObject doNewInstance(DataObject dobj) {
public DomainObject doNewInstance(final DataObject dobj) {
return new ApplicationType(dobj);
}
});
e.getFactory().registerInstantiator
(TaskComment.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
TaskComment.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() {
public DomainObject doNewInstance(final DataObject data) {
return new TaskComment(data);
}
});
/* domain.ReflectionInstantiator instantiator for
* dataObject com.arsdigita.webdevsupport.WebDevSupport */
e.getFactory().registerInstantiator
(WebDevSupport.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
WebDevSupport.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(final DataObject data) {
return new WebDevSupport(data);
}
});
e.getFactory().registerInstantiator
(Login.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
Login.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(final DataObject data) {
return new Login(data);
}
});
e.getFactory().registerInstantiator
(Admin.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
Admin.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(final DataObject data) {
public DomainObject doNewInstance(
final DataObject data) {
return new Admin(data);
}
});
e.getFactory().registerInstantiator
(Permissions.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
Permissions.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(final DataObject data) {
return new Permissions(data);
}
});
e.getFactory().registerInstantiator
(BasicAuditTrail.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
BasicAuditTrail.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() {
public DomainObject doNewInstance(final DataObject data) {
return new BasicAuditTrail(data);
}
});
e.getFactory().registerInstantiator
(MimeType.BASE_DATA_OBJECT_TYPE,
event.getFactory().registerInstantiator(
MimeType.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() {
public DomainObject doNewInstance(DataObject dataObject) {
return new MimeType(dataObject);
public DomainObject doNewInstance(final DataObject dataObject) {
return new MimeType(
dataObject);
}
@Override
public DomainObjectInstantiator
resolveInstantiator(DataObject obj) {
resolveInstantiator(final DataObject obj) {
return this;
}
});
// register the document converters
@ -209,6 +241,22 @@ public class Initializer extends CompoundInitializer {
// Initialize the the CharsetEncodingProvider internal data structure
URLRewriter.addParameterProvider(new CharsetEncodingProvider());
final ExportManager exportManager = ExportManager.getInstance();
exportManager.registerExporter(new CategoriesExporter());
exportManager.registerExporter(new CategorizationsExporter());
exportManager.registerExporter(new ResourceTypesExporter());
exportManager.registerExporter(new GroupMembershipsExporter());
exportManager.registerExporter(new GroupsExporter());
exportManager.registerExporter(new PermissionsExporter());
exportManager.registerExporter(new RoleMembershipsExporter());
exportManager.registerExporter(new RolesExporter());
exportManager.registerExporter(new UsersExporter());
exportManager.registerExporter(new AssignableTasksExporter());
exportManager.registerExporter(new TaskAssignmentsExporter());
exportManager.registerExporter(new TaskCommentsExporter());
exportManager.registerExporter(new TaskDependenciesExporter());
exportManager.registerExporter(new TasksExporter());
exportManager.registerExporter(new WorkflowsExporter());
// Creates an entry in table web_hosts. Might be considered a loader
// task (and is already handled there). But configuration may be

View File

@ -70,7 +70,7 @@ public class Permission extends DomainObject {
static final String PARTY_ID = "partyId";
static final String PRIVILEGE = "privilege";
static final String BASE_DATA_OBJECT_TYPE =
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.kernel.permissions.Permission";
/**

View File

@ -1,191 +0,0 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.cmd;
import com.arsdigita.portation.AbstractExporter;
import com.arsdigita.portation.Format;
import com.arsdigita.util.cmd.Program;
import org.apache.commons.cli.CommandLine;
/**
* A Commandline tool for exporting all the objects of specified classes to
* one or many specified file types.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 25.05.16
*/
public class ExportCliTool extends Program {
/**
* Constructor for the command line tool.
*/
private ExportCliTool() {
super("Export Commandline Tool",
"1.0.0",
"Exportation of POJOs...");
}
/**
* Main method, which calls the {@code doRun}-method and hands the given
* arguments over to that method.
*
* @param args The command line arguments
*/
public static void main(String[] args) {
new ExportCliTool().run(args);
}
/**
* This method differentiates between multiple commands. Through the
* parameter the command line arguments will be matched to predefined
* commands which will then depending on the case define what will be
* called or executed.
*
* The commands are:
* {@code help} which prints just the usage of this tool
* {@code export} which executes the process of exporting whatever
* is required to be exported
*
* @param cmdLine The parsed command line arguments
*/
@Override
protected void doRun(CommandLine cmdLine) {
String[] args = cmdLine.getArgs();
if (args.length < 1) {
printUsage();
System.exit(-1);
}
final String command = args[0];
System.out.printf("command: %s\n", command);
switch (command) {
case "help":
printUsage();
break;
case "convert":
convert();
break;
case "export":
convert();
export(args);
break;
default:
printUsage();
break;
}
}
/**
* Method for converting all trunk objects into ng objects at once.
*/
private void convert() {
try {
System.out.println("Started conversions of systems objects to " +
"ng-objects:");
RootConverter.rootConversionExecution();
System.out.println("Finished conversions.");
System.out.print("\n");
} catch (Exception e) {
System.err.printf("ERROR while converting trunk-objects to " +
"ng-objects: %s\n", e);
e.printStackTrace();
}
}
/**
* Method defining the process of exporting after its command has been
* triggered.
*
* @param args The secondary command line arguments
*/
private void export(String[] args) {
if (args.length != 2) {
printUsage();
System.exit(-1);
}
final Format format = Format.XML;
final String pathName = args[1];
final boolean ind = false;
System.out.printf("format to export to: %s\n", format.toString());
System.out.printf("path to export to: %s\n", pathName);
System.out.printf("indentations in files: %b\n", ind);
AbstractExporter.setFormat(format);
AbstractExporter.setPath(pathName);
AbstractExporter.setIndentation(ind);
System.out.print("\n");
try {
System.out.println("Started exporting all ng-objects:");
RootExporter.rootExportExecution();
System.out.println("Finished exports.");
System.out.print("\n");
} catch (Exception ex) {
System.err.printf("ERROR while exporting: %s\n", ex);
ex.printStackTrace();
}
}
/**
* Prints the usage of this command line tool.
*/
private void printUsage() {
System.out.print(
"\n" +
"\t\t\t\t --- ExportCliTool ---\n" +
"\n" +
"Usage:\t<command>\n" +
"\n" +
"Available commands:\n" +
"\thelp" +
"\t\t\t\t\t Shows information on how to use this tool.\n" +
"\tconvert" +
"\t\t\t\t\t Converts all trunk objects to ng objects.\n" +
"\texport <path>" +
"\t\t\t\t Exports the chosen module class to a file\n" +
"\t\t\t\t" +
"\t\t at the location specified by the given path." +
"\n" +
"\n" +
"Available module-classes for export:\n" +
/*" \t\t categories \t\t all categories of the system\n" +
" \t\t categorizations \t\t all categorizations of the system\n" +
" \t\t users \t\t all users of the system\n" +
" \t\t groups \t\t all groups of the system\n" +
" \t\t groupMemberships \t\t all groupsMemberships of the system\n" +
" \t\t roles \t\t all roles of the system\n" +
" \t\t roleMemberships \t\t all roleMemberships of the system\n" +
" \t\t workflowTemplates \t\t all workflowTemplates of the system\n" +
" \t\t workflows \t\t all workflows of the system\n" +
" \t\t assignableTasks \t\t all assignableTasks of the system\n" +
" \t\t taskAssignments \t\t all taskAssignments of the system\n" +
" \t\t permissions \t\t all permissions of the system\n" +
" \n" +
" \t\t default: \t\t all objects of the entire core module" +
*/"\n" +
"\n" +
"Do use for exporting java objects of a specified class.\n" +
"\n"
);
}
}

View File

@ -1,94 +0,0 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.conversion;
import com.arsdigita.portation.modules.core.categorization.Categorization;
import com.arsdigita.portation.modules.core.categorization.Category;
import com.arsdigita.portation.modules.core.categorization.Domain;
import com.arsdigita.portation.modules.core.categorization.DomainOwnership;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.core.Resource;
import com.arsdigita.portation.modules.core.core.ResourceType;
import com.arsdigita.portation.modules.core.security.Group;
import com.arsdigita.portation.modules.core.security.GroupMembership;
import com.arsdigita.portation.modules.core.security.Party;
import com.arsdigita.portation.modules.core.security.Permission;
import com.arsdigita.portation.modules.core.security.Role;
import com.arsdigita.portation.modules.core.security.RoleMembership;
import com.arsdigita.portation.modules.core.security.User;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import com.arsdigita.portation.modules.core.workflow.AssignableTask;
import com.arsdigita.portation.modules.core.workflow.Task;
import com.arsdigita.portation.modules.core.workflow.TaskAssignment;
import com.arsdigita.portation.modules.core.workflow.TaskComment;
import com.arsdigita.portation.modules.core.workflow.TaskDependency;
import com.arsdigita.portation.modules.core.workflow.Workflow;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Storage class for all ng-objects after conversion. This also helps for an
* easier access for the restoration of the dependencies.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 27.6.16
*/
public class NgCoreCollection {
public static Map<Long, Party> parties = new HashMap<>();
public static Map<Long, User> users = new HashMap<>();
public static Map<Long, Group> groups = new HashMap<>();
public static Map<Long, GroupMembership> groupMemberships = new HashMap<>();
public static Map<Long, Role> roles = new HashMap<>();
public static Map<Long, RoleMembership> roleMemberships = new HashMap<>();
public static Map<Long, CcmObject> ccmObjects = new HashMap<>();
public static Map<Long, Category> categories = new HashMap<>();
public static Map<Long, Categorization> categorizations = new HashMap<>();
public static Map<Long, Permission> permissions = new HashMap<>();
public static Map<Long, Workflow> workflows = new HashMap<>();
public static Map<Long, TaskComment> taskComments = new HashMap<>();
public static Map<Long, Task> tasks = new HashMap<>();
public static Map<Long, AssignableTask> assignableTasks = new HashMap<>();
public static Map<Long, TaskDependency> taskDependencies = new HashMap<>();
public static Map<Long, TaskAssignment> taskAssignments = new HashMap<>();
public static Map<Long, ResourceType> resourceTypes = new HashMap<>();
public static Map<Long, Resource> resources = new HashMap<>();
public static Map<Long, CcmApplication> ccmApplications = new HashMap<>();
public static Map<Long, Domain> domains = new HashMap<>();
public static Map<Long, DomainOwnership> domainOwnerships = new HashMap<>();
// in case maps need to be sorted for export
public static ArrayList<Category> sortedCategories;
public static ArrayList<Workflow> sortedWorkflows;
public static ArrayList<AssignableTask> sortedAssignableTasks;
public static ArrayList<CcmApplication> sortedCcmApplications;
/**
* Private constructor to prevent the instantiation of this class.
*/
private NgCoreCollection() {}
}

View File

@ -0,0 +1,126 @@
package org.libreccm.categorization;
import com.arsdigita.categorization.Category;
import com.arsdigita.categorization.CategoryLocalization;
import com.arsdigita.categorization.CategoryLocalizationCollection;
import com.arsdigita.util.UncheckedWrapperException;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import org.libreccm.export.AbstractDomainObjectsExporter;
import org.libreccm.export.IdSequence;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CategoriesExporter extends AbstractDomainObjectsExporter<Category> {
@Override
public Class<Category> exportsType() {
return Category.class;
}
@Override
public String exportsBaseDataObjectType() {
return Category.BASE_DATA_OBJECT_TYPE;
}
@Override
public String convertsToType() {
return "org.libreccm.categorization.Category";
}
@Override
protected List<String> exportDomainObject(final Category domainObject,
final Path targetDir) {
final String uuid = generateUuid(domainObject);
final Path targetFilePath = targetDir
.resolve("org.libreccm.categorization.Categorization")
.resolve(String.format("%s.json", uuid));
final File targetFile = targetFilePath.toFile();
final JsonFactory jsonFactory = new JsonFactory();
try (JsonGenerator jsonGenerator = jsonFactory
.createGenerator(targetFile, JsonEncoding.UTF8)) {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("objectId",
IdSequence.getInstance().nextId());
jsonGenerator.writeStringField("uuid", uuid);
jsonGenerator.writeStringField("uniqueId", uuid);
jsonGenerator.writeStringField("name", domainObject.getName());
final CategoryLocalizationCollection localizations = domainObject
.getCategoryLocalizationCollection();
final Map<Locale, String> titles = new HashMap<>();
final Map<Locale, String> descriptions = new HashMap<>();
while (localizations.next()) {
final CategoryLocalization localization = localizations
.getCategoryLocalization();
final Locale locale = new Locale(localization.getLocale());
final String title = localization.getName();
final String description = localization.getDescription();
titles.put(locale, title);
descriptions.put(locale, description);
}
jsonGenerator.writeObjectFieldStart("title");
for (Map.Entry<Locale, String> title : titles.entrySet()) {
jsonGenerator.writeStringField(title.getKey().toString(),
title.getValue());
}
jsonGenerator.writeEndObject();
jsonGenerator.writeObjectFieldStart("description");
for (Map.Entry<Locale, String> desc : descriptions.entrySet()) {
jsonGenerator.writeStringField(desc.getKey().toString(),
desc.getValue());
}
jsonGenerator.writeEndObject();
jsonGenerator.writeBooleanField("enabled",
domainObject.isEnabled());
jsonGenerator.writeBooleanField("visible",
domainObject.isVisible());
jsonGenerator.writeBooleanField("abstractCategory",
domainObject.isAbstract());
jsonGenerator.writeStringField(
"parentCategory",
generateUuid(domainObject.getDefaultParentCategory()));
jsonGenerator.writeNumberField(
"categoryOrder",
domainObject
.getDefaultParentCategory()
.getSortKey(domainObject)
.longValue());
jsonGenerator.writeEndObject();
return Arrays.asList(new String[]{uuid});
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
}
}

View File

@ -16,30 +16,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.core.CcmObject;
import org.libreccm.export.convert.Portable;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.core.CcmObject;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.export.Exportable;
import org.libreccm.export.convert.UuidGenerator;
/**
* Association class describing the association between a category and an
* object. Instances of these class should not created manually. The methods
* provided by the {@code CategoryManager} take care of that.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created on 6/15/16
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@uni-bremen.de">Jens Pelzetter</a>
*/
@JsonIdentityInfo(generator = CategorizationIdGenerator.class,
property = "customCatId")
public class Categorization implements Portable {
public class Categorization implements Exportable, Portable {
private long categorizationId;
private String uuid;
@JsonIdentityReference(alwaysAsId = true)
private Category category;
@JsonIdentityReference(alwaysAsId = true)
private CcmObject categorizedObject;
private boolean index;
@ -47,10 +54,14 @@ public class Categorization implements Portable {
private long objectOrder;
private String type;
public Categorization(final Category category,
final CcmObject categorizedObject) {
public Categorization(final Category category, final CcmObject
categorizedObject) {
this.categorizationId = ACSObject.generateID().longValue();
this.uuid = UuidGenerator
.getInstance()
.generateUuid(category.getName(),
categorizedObject.getDisplayName());
this.category = category;
this.categorizedObject = categorizedObject;
@ -61,10 +72,9 @@ public class Categorization implements Portable {
this.type = "";
NgCoreCollection.categorizations.put(this.categorizationId, this);
CcmCoreEntities.CATEGORIZATIONS.put(this.categorizationId, this);
}
public long getCategorizationId() {
return categorizationId;
}
@ -73,6 +83,16 @@ public class Categorization implements Portable {
this.categorizationId = categorizationId;
}
@Override
public String getUuid() {
return uuid;
}
@Override
public void setUuid(final String uuid) {
this.uuid = uuid;
}
public Category getCategory() {
return category;
}
@ -120,4 +140,5 @@ public class Categorization implements Portable {
public void setType(String type) {
this.type = type;
}
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;

View File

@ -16,12 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import org.libreccm.export.convert.AbstractMarshaller;
import org.libreccm.export.convert.Format;
import org.libreccm.export.cmd.ExportLogger;
import org.libreccm.export.convert.CcmCoreEntities;
import java.util.ArrayList;
@ -62,6 +64,6 @@ public class CategorizationMarshaller extends AbstractMarshaller<Categorization>
final boolean indentation) {
ExportLogger.exporting("categorizations");
prepare(format, pathName, "categorizations", indentation);
exportList(new ArrayList<>(NgCoreCollection.categorizations.values()));
exportList(new ArrayList<>(CcmCoreEntities.CATEGORIZATIONS.values()));
}
}

View File

@ -0,0 +1,114 @@
package org.libreccm.categorization;
import com.arsdigita.categorization.CategorizedCollection;
import com.arsdigita.categorization.Category;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.WebConfig;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import org.libreccm.export.AbstractDomainObjectsExporter;
import org.libreccm.export.IdSequence;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CategorizationsExporter
extends AbstractDomainObjectsExporter<Category> {
@Override
public Class<Category> exportsType() {
return Category.class;
}
@Override
public String exportsBaseDataObjectType() {
return Category.BASE_DATA_OBJECT_TYPE;
}
@Override
public String convertsToType() {
return "org.libreccm.categorization.Categorization";
}
@Override
protected List<String> exportDomainObject(final Category domainObject,
final Path targetDir) {
final CategorizedCollection categorized = domainObject
.getObjects(ACSObject.BASE_DATA_OBJECT_TYPE);
final List<String> uuids = new ArrayList<>();
while (categorized.next()) {
final String uuid = exportCategorization(targetDir,
domainObject,
categorized.getACSObject(),
categorized.getPosition());
uuids.add(uuid);
}
return uuids;
}
private String exportCategorization(final Path targetDir,
final Category category,
final ACSObject object,
final long position) {
final String categoryUuid = generateUuid(category);
final String objectUuid = generateUuid(object);
final byte[] uuidSource = String
.format("%s/%s-%s",
WebConfig.getInstanceOf().getSiteName(),
category.getOID().toString(),
object.getOID().toString())
.getBytes(StandardCharsets.UTF_8);
final String uuid = UUID.nameUUIDFromBytes(uuidSource).toString();
final ACSObject indexObj = category.getIndexObject();
boolean isIndex = object.equals(indexObj);
final Path targetFilePath = targetDir
.resolve("org.libreccm.categorization.Categorization")
.resolve(String.format("%s.json", uuid));
final File targetFile = targetFilePath.toFile();
final JsonFactory jsonFactory = new JsonFactory();
try (JsonGenerator jsonGenerator = jsonFactory
.createGenerator(targetFile, JsonEncoding.UTF8)) {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("categorizationId",
IdSequence.getInstance().nextId());
jsonGenerator.writeStringField("uuid", uuid);
jsonGenerator.writeStringField("category", categoryUuid);
jsonGenerator.writeStringField("categorizedObject", objectUuid);
jsonGenerator.writeBooleanField("indexObject", isIndex);
jsonGenerator.writeNumberField("objectOrder", position);
jsonGenerator.writeEndObject();
return uuid;
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
}
}

View File

@ -16,15 +16,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.categorization.CategoryLocalization;
import com.arsdigita.categorization.CategoryLocalizationCollection;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.categorization.util.CategoryInformation;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.export.convert.categorization.util.CategoryInformation;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -110,7 +115,7 @@ public class Category extends CcmObject implements Portable {
? defaultParent.getNumberOfChildCategories() + 1
: 0;
NgCoreCollection.categories.put(this.getObjectId(), this);
CcmCoreEntities.CATEGORIES.put(this.getObjectId(), this);
}
/**

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;

View File

@ -16,12 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import org.libreccm.export.convert.AbstractMarshaller;
import org.libreccm.export.convert.Format;
import org.libreccm.export.cmd.ExportLogger;
import org.libreccm.export.convert.CcmCoreEntities;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
@ -60,6 +62,6 @@ public class CategoryMarshaller extends AbstractMarshaller<Category> {
final boolean indentation) {
ExportLogger.exporting("categories");
prepare(format, pathName, "categories", indentation);
exportList(NgCoreCollection.sortedCategories);
exportList(CcmCoreEntities.SORTED_CATEGORIES);
}
}

View File

@ -16,14 +16,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import org.libreccm.export.convert.Portable;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.web.CcmApplication;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -35,7 +40,7 @@ import java.util.List;
import java.util.Locale;
/**
* A domain is collection of categories designed a specific purpose. This entity
* A domain is collection of CATEGORIES designed a specific purpose. This entity
* replaces the {@code Domain} entity from the old
* {@link com.arsdigita.london.terms.Domain} module as well as the {@code
* CategoryPurpose} entity from the old {@code ccm-core module}.
@ -89,7 +94,7 @@ public class Domain extends CcmObject implements Portable {
this.owners = new ArrayList<>();
NgCoreCollection.domains.put(this.getObjectId(), this);
CcmCoreEntities.DOMAINS.put(this.getObjectId(), this);
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;

View File

@ -16,12 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import org.libreccm.export.convert.AbstractMarshaller;
import org.libreccm.export.convert.Format;
import org.libreccm.export.cmd.ExportLogger;
import org.libreccm.export.convert.CcmCoreEntities;
import java.util.ArrayList;
@ -62,6 +64,6 @@ public class DomainMarshaller extends AbstractMarshaller<Domain> {
final boolean indentation) {
ExportLogger.exporting("domains");
prepare(format, pathName, "domains", indentation);
exportList(new ArrayList<>(NgCoreCollection.domains.values()));
exportList(new ArrayList<>(CcmCoreEntities.DOMAINS.values()));
}
}

View File

@ -16,13 +16,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.core.CcmObject;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import org.libreccm.export.convert.Portable;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.core.CcmObject;
import org.libreccm.web.CcmApplication;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
@ -59,7 +63,7 @@ public class DomainOwnership implements Portable {
this.ownerOrder = 1;
this.domainOrder = 1;
NgCoreCollection.domainOwnerships.put(this.getOwnershipId(), this);
CcmCoreEntities.DOMAIN_OWNERSHIPS.put(this.getOwnershipId(), this);
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;

View File

@ -16,12 +16,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.categorization;
package org.libreccm.categorization;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import org.libreccm.export.convert.AbstractMarshaller;
import org.libreccm.export.convert.Format;
import org.libreccm.export.cmd.ExportLogger;
import org.libreccm.export.convert.CcmCoreEntities;
import java.util.ArrayList;
@ -62,6 +64,6 @@ public class DomainOwnershipMarshaller extends AbstractMarshaller<DomainOwnershi
final boolean indentation) {
ExportLogger.exporting("domain ownerships");
prepare(format, pathName, "domainOwnerships", indentation);
exportList(new ArrayList<>(NgCoreCollection.domainOwnerships.values()));
exportList(new ArrayList<>(CcmCoreEntities.DOMAIN_OWNERSHIPS.values()));
}
}

View File

@ -0,0 +1,77 @@
package org.libreccm.core;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.util.UncheckedWrapperException;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import org.libreccm.export.AbstractDomainObjectsExporter;
import org.libreccm.export.IdSequence;
import org.libreccm.security.PermissionsExporter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
/**
* Abstract class for exporting types which extend {@link ACSObject}. The
* implementation of
* {@link #exportDomainObject(com.arsdigita.kernel.ACSObject, java.nio.file.Path)}
* in this class takes care of the basic stuff for export an ACSObject/CcmObject
* including exporting the properties shared by all ACSObjects/CcmObjects.
*
* Please note that this exporter does not handle permissions and
* categorizations for the object. This is done by the
* {@link PermissionsExporter} and the {@link CategorizationsExporter}.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
*/
public abstract class AbstractCcmObjectsExporter<T extends ACSObject>
extends AbstractDomainObjectsExporter<T> {
/**
* Implement this method to export the properties specific for the type.
*
* @param ccmObject The {@link ACSObject} to export.
* @param jsonGenerator The {@link JsonGenerator} to use.
* @throws java.io.IOException
*/
protected abstract void exportObjectProperties(
T ccmObject, final JsonGenerator jsonGenerator)
throws IOException ;
@Override
public final List<String> exportDomainObject(final T domainObject,
final Path targetDir) {
final String uuid = generateUuid(domainObject);
final Path targetFilePath = generateTargetFilePath(
targetDir, exportsType().getName(), uuid);
final JsonFactory jsonFactory = new JsonFactory();
try (JsonGenerator jsonGenerator = jsonFactory
.createGenerator(targetFilePath.toFile(), JsonEncoding.UTF8)) {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("objectId",
IdSequence.getInstance().nextId());
jsonGenerator.writeStringField("uuid", uuid);
jsonGenerator.writeStringField("displayName",
domainObject.getDisplayName());
exportObjectProperties(domainObject, jsonGenerator);
jsonGenerator.writeEndObject();
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
return Arrays.asList(new String[]{uuid});
}
}

View File

@ -0,0 +1,79 @@
package org.libreccm.core;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.kernel.ResourceType;
import com.arsdigita.util.UncheckedWrapperException;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import org.libreccm.export.AbstractDomainObjectsExporter;
import org.libreccm.export.IdSequence;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
*/
public abstract class AbstractResourceTypesExporter<T extends ResourceType>
extends AbstractDomainObjectsExporter<T> {
/**
* Implement this method to export the properties specific for the type.
*
* @param resourceType The {@link ResourceType} to export.
* @param jsonGenerator The {@link JsonGenerator} to use.
*/
protected abstract void exportResourceTypeProperties(
T resourceType, JsonGenerator jsonGenerator);
@Override
public final List<String> exportDomainObject(final T domainObject,
final Path targetDir) {
final String uuid = generateUuid(domainObject);
final Path targetFilePath = generateTargetFilePath(
targetDir, exportsType().getName(), uuid);
final JsonFactory jsonFactory = new JsonFactory();
try (JsonGenerator jsonGenerator = jsonFactory
.createGenerator(targetFilePath.toFile(), JsonEncoding.UTF8)) {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("resourceTypeId",
IdSequence.getInstance().nextId());
jsonGenerator.writeStringField("uuid", uuid);
jsonGenerator.writeObjectFieldStart("title");
jsonGenerator.writeStringField(
KernelConfig.getConfig().getDefaultLanguage(),
domainObject.getTitle());
jsonGenerator.writeEndObject();
jsonGenerator.writeObjectFieldStart("description");
jsonGenerator.writeStringField(
KernelConfig.getConfig().getDefaultLanguage(),
domainObject.getDescription());
jsonGenerator.writeEndObject();
jsonGenerator.writeBooleanField("workspaceApplication", false);
jsonGenerator.writeBooleanField("viewableAsFullPage", false);
jsonGenerator.writeBooleanField("workspaceAsEmbedded", false);
jsonGenerator.writeBooleanField("singleton", false);
jsonGenerator.writeEndObject();
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
return Arrays.asList(new String[]{uuid});
}
}

View File

@ -0,0 +1,58 @@
package org.libreccm.core;
import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.kernel.Resource;
import com.arsdigita.kernel.ResourceType;
import com.fasterxml.jackson.core.JsonGenerator;
import java.io.IOException;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T>
*/
public abstract class AbstractResourcesExporter<T extends Resource>
extends AbstractCcmObjectsExporter<T> {
/**
* Implement this method to export the properties specific for the type.
*
* @param resource The {@link Resource} to export.
* @param jsonGenerator The {@link JsonGenerator} to use.
* @throws java.io.IOException
*/
@Override
protected final void exportObjectProperties(
final T resource, final JsonGenerator jsonGenerator)
throws IOException {
jsonGenerator.writeObjectFieldStart("title");
jsonGenerator.writeStringField(
KernelConfig.getConfig().getDefaultLanguage(),
resource.getTitle());
jsonGenerator.writeEndObject();
jsonGenerator.writeObjectFieldStart("description");
jsonGenerator.writeStringField(
KernelConfig.getConfig().getDefaultLanguage(),
resource.getDescription());
jsonGenerator.writeEndObject();
final ResourceType type = resource.getResourceType();
final String typeUuid = generateUuid(type);
jsonGenerator.writeStringField("resourceType", typeUuid);
final Resource parent = resource.getParentResource();
final String parentUuid = generateUuid(parent);
jsonGenerator.writeStringField("parent", parentUuid);
exportResourceProperties(resource, jsonGenerator);
}
protected abstract void exportResourceProperties(
T resource, JsonGenerator jsonGenerator)
throws IOException;
}

View File

@ -16,14 +16,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.categorization.Categorization;
import com.arsdigita.portation.modules.core.categorization.Category;
import com.arsdigita.portation.modules.core.categorization.util.CategoryInformation;
import com.arsdigita.portation.modules.core.security.Permission;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.Category;
import org.libreccm.export.convert.categorization.util.CategoryInformation;
import org.libreccm.security.Permission;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@ -73,7 +76,7 @@ public class CcmObject {
this.permissions = new ArrayList<>();
this.categories = new ArrayList<>();
NgCoreCollection.ccmObjects.put(this.objectId, this);
CcmCoreEntities.CCM_OBJECTS.put(this.objectId, this);
}
// specific constructor for ldn-terms' Domain and LegalMetadata
@ -91,7 +94,7 @@ public class CcmObject {
this.permissions = new ArrayList<>();
this.categories = new ArrayList<>();
NgCoreCollection.ccmObjects.put(this.objectId, this);
CcmCoreEntities.CCM_OBJECTS.put(this.objectId, this);
}
public long getObjectId() {

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>

View File

@ -16,11 +16,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import org.libreccm.core.CcmObject;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.l10n.LocalizedString;
import org.libreccm.web.CcmApplication;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import com.arsdigita.portation.modules.core.web.CcmApplication;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -75,7 +80,7 @@ public class Resource extends CcmObject {
this.childs = new ArrayList<>();
//this.parent
NgCoreCollection.resources.put(this.getObjectId(), this);
CcmCoreEntities.resources.put(this.getObjectId(), this);
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;

View File

@ -16,11 +16,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import com.arsdigita.portation.Portable;
import com.arsdigita.portation.conversion.NgCoreCollection;
import com.arsdigita.portation.modules.core.l10n.LocalizedString;
import org.libreccm.export.convert.Portable;
import org.libreccm.export.convert.CcmCoreEntities;
import org.libreccm.l10n.LocalizedString;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@ -65,7 +67,7 @@ public class ResourceType implements Portable {
this.viewableAsEmbedded = false;
this.singleton = false;
NgCoreCollection.resourceTypes.put(this.resourceTypeId, this);
CcmCoreEntities.RESOURCE_TYPES.put(this.resourceTypeId, this);
}
public long getResourceTypeId() {

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;

View File

@ -16,12 +16,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.modules.core.core;
package org.libreccm.core;
import com.arsdigita.portation.AbstractMarshaller;
import com.arsdigita.portation.Format;
import com.arsdigita.portation.cmd.ExportLogger;
import com.arsdigita.portation.conversion.NgCoreCollection;
import org.libreccm.core.ResourceType;
import org.libreccm.export.convert.AbstractMarshaller;
import org.libreccm.export.convert.Format;
import org.libreccm.export.cmd.ExportLogger;
import org.libreccm.export.convert.CcmCoreEntities;
import java.util.ArrayList;
@ -62,6 +66,6 @@ public class ResourceTypeMarshaller extends AbstractMarshaller<ResourceType> {
final boolean indentation) {
ExportLogger.exporting("resource types");
prepare(format, pathName, "resourceTypes", indentation);
exportList(new ArrayList<>(NgCoreCollection.resourceTypes.values()));
exportList(new ArrayList<>(CcmCoreEntities.RESOURCE_TYPES.values()));
}
}

View File

@ -0,0 +1,38 @@
package org.libreccm.core;
import com.arsdigita.kernel.ResourceType;
import com.fasterxml.jackson.core.JsonGenerator;
import java.util.Arrays;
import java.util.List;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ResourceTypesExporter
extends AbstractResourceTypesExporter<ResourceType> {
@Override
public Class<ResourceType> exportsType() {
return ResourceType.class;
}
@Override
public String exportsBaseDataObjectType() {
return ResourceType.BASE_DATA_OBJECT_TYPE;
}
@Override
public String convertsToType() {
return "org.libreccm.core.ResourceType";
}
protected void exportResourceTypeProperties(
final ResourceType resourceType, final JsonGenerator jsonGenerator) {
//Nothing
}
}

View File

@ -0,0 +1,166 @@
package org.libreccm.export;
import com.arsdigita.domain.DomainObject;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.web.WebConfig;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Base class for exporters for migration to LibreCCM 7.
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
* @param <T> The subclass of {@link DomainObject} the implementation handles.
*/
public abstract class AbstractDomainObjectsExporter<T extends DomainObject> {
final WebConfig webConfig = WebConfig.getInstanceOf();
/**
* Provides the class of the domain object which is handled by the
* implementation.
*
* @return
*/
public abstract Class<T> exportsType();
/**
* Provides the base data object type of the domain object handled by the
* implementation. This information is used by
* {@link #exportDomainObjects(java.nio.file.Path)} to retrieve the domain
* objects to export.
*
* @return
*/
public abstract String exportsBaseDataObjectType();
/**
* Provides the fully qualified class name of the type to which the domain
* objects handled by the implementation are converted.
*
* @return
*/
public abstract String convertsToType();
/**
* The implementation of this method is supposed to do the export for a
* single entity. To generate the path of the target file
* {@link #generateTargetFilePath(java.nio.file.Path, java.lang.String)} can
* be used. A single domain object can be split into several objects by the
* exporter.
*
* @param domainObject The domain object to export.
* @param targetDir The target directory for the export
*
* @return The UUIDs of the exported objects.
*/
protected abstract List<String> exportDomainObject(final T domainObject,
final Path targetDir);
/**
* Helper for method for generating an UUID for an entity. In LibreCCM 7
* UUIDs are used for identifying entities. To avoid collision are the keep
* the UUID the same for between runs of the export we use name based UUIDs
* (variant 3) here. The UUID is generated from the OID of the domain object
* to export. More exactly first a string containing the name of the site as
* returned by {@link WebConfig#getSiteName()} and the string representation
* of the OID, separated by {@code '/'} is created. From this string the
* UUID is generated.
*
* Exporter for association objects like
* {@code org.librecms.categorization.Categorization} should not use this
* method. Instead they should generate the UUID from the site name and the
* OIDs of the entities associated by the object.
*
* @param forDomainObject The {@link DomainObject} for which the UUID is
* generated.
*
* @return The UUID of the {@link DomainObject}.
*/
protected final String generateUuid(final DomainObject forDomainObject) {
final String uuidSource = String.format(
"%s/%s",
webConfig.getSiteName(),
forDomainObject.getOID().toString());
final byte[] uuidSourceBytes = uuidSource
.getBytes(StandardCharsets.UTF_8);
return UUID.nameUUIDFromBytes(uuidSourceBytes).toString();
}
/**
* Helper method for generating the target file path for the export of an
* entity.
*
* @param targetDir The target directory.
* @param uuid The UUID of the entity.
*
* @return The path for target file.
*/
protected final Path generateTargetFilePath(final Path targetDir,
final String uuid) {
return generateTargetFilePath(targetDir, convertsToType(), uuid);
}
protected final Path generateTargetFilePath(final Path targetDir,
final String targetType,
final String uuid) {
return targetDir
.resolve(targetType)
.resolve(String.format("%s.json", uuid));
}
/**
* Retrieves all {@link DomainObject}s of the type returned by
* {@link #exportsBaseDataObjectType()} and calls
* {@link #exportDomainObject(com.arsdigita.domain.DomainObject, java.nio.file.Path)}
* for each of them.
*
* @param targetDir target directory for the export.
* @return The list of uuids of the the exported entites.
*/
@SuppressWarnings("unchecked")
public final List<String> exportDomainObjects(final Path targetDir) {
final Session session = SessionManager.getSession();
final DataCollection dataCollection = session
.retrieve(exportsBaseDataObjectType());
final List<T> domainObjects = new ArrayList<>();
while (dataCollection.next()) {
final DataObject dataObject = dataCollection.getDataObject();
final DomainObject domainObject = DomainObjectFactory
.newInstance(dataObject);
if (!(domainObject.getClass().isAssignableFrom(exportsType()))) {
throw new ExportException(String.format(
"DomainObject is not of type \"%s\" but of type \"%s\".",
exportsType().getName(),
domainObject.getClass().getName()));
}
domainObjects.add((T) domainObject);
}
final List<String> uuids = new ArrayList<>();
for (final T domainObject : domainObjects) {
final List<String> createdUuids = exportDomainObject(domainObject,
targetDir);
uuids.addAll(createdUuids);
}
return uuids;
}
}

View File

@ -0,0 +1,54 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.libreccm.export;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ExportException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
* Creates a new instance of <code>ExportException</code> without detail message.
*/
public ExportException() {
super();
}
/**
* Constructs an instance of <code>ExportException</code> with the specified detail message.
*
* @param msg The detail message.
*/
public ExportException(final String msg) {
super(msg);
}
/**
* Constructs an instance of <code>ExportException</code> which wraps the
* specified exception.
*
* @param exception The exception to wrap.
*/
public ExportException(final Exception exception) {
super(exception);
}
/**
* Constructs an instance of <code>ExportException</code> with the specified message which also wraps the
* specified exception.
*
* @param msg The detail message.
* @param exception The exception to wrap.
*/
public ExportException(final String msg, final Exception exception) {
super(msg, exception);
}
}

View File

@ -0,0 +1,257 @@
package org.libreccm.export;
import com.arsdigita.util.UncheckedWrapperException;
import com.arsdigita.web.WebConfig;
import com.fasterxml.jackson.core.JsonEncoding;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Set;
import java.util.stream.Collectors;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public final class ExportManager {
private static final ExportManager INSTANCE = new ExportManager();
private List<AbstractDomainObjectsExporter<?>> exporters;
private ExportManager() {
// Nothing
}
public static ExportManager getInstance() {
return INSTANCE;
}
public void exportData(final Path targetDirPath) {
final Set<String> types = exporters
.stream()
.map(exporter -> exporter.convertsToType())
.collect(Collectors.toSet());
for(final String type : types) {
try {
final Path typeDirPath = targetDirPath.resolve(type);
Files.createDirectories(typeDirPath);
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
}
if (!Files.isDirectory(targetDirPath)) {
throw new IllegalArgumentException(String.format(
"Path %s does not point to a directory.",
targetDirPath));
}
if (!Files.isWritable(targetDirPath)) {
throw new IllegalArgumentException(String.format(
"Path %s is not writable.",
targetDirPath));
}
final Map<String, List<String>> exportedEntities = new HashMap<>();
for (final AbstractDomainObjectsExporter< ?> exporter : exporters) {
final List<String> uuids = exporter
.exportDomainObjects(targetDirPath);
exportedEntities.put(exporter.convertsToType(), uuids);
}
final Path manifestFilePath = targetDirPath.resolve("ccm-export.json");
final JsonFactory jsonFactory = new JsonFactory();
try (final JsonGenerator manifestGenerator = jsonFactory
.createGenerator(manifestFilePath.toFile(), JsonEncoding.UTF8)) {
manifestGenerator.writeStartObject();
manifestGenerator.writeStartObject();
manifestGenerator.writeStringField(
"created",
LocalDateTime.now(ZoneId.of("UTC")).toString());
manifestGenerator.writeStringField(
"onServer",
WebConfig.getInstanceOf().getSiteName());
manifestGenerator.writeArrayFieldStart("types");
for (final String type : exportedEntities.keySet()) {
manifestGenerator.writeString(type);
}
manifestGenerator.writeEndObject();
manifestGenerator.writeObjectFieldStart("entities");
for (final Map.Entry<String, List<String>> entities
: exportedEntities.entrySet()) {
manifestGenerator.writeArrayFieldStart(entities.getKey());
for (final String uuid : entities.getValue()) {
manifestGenerator.writeString(uuid);
}
manifestGenerator.writeEndArray();
}
manifestGenerator.writeEndObject();
manifestGenerator.writeEndObject();
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
}
public void registerExporter(final AbstractDomainObjectsExporter<?> exporter) {
exporters.add(exporter);
}
// public void exportEntities(final List<DomainO> entities,
// final String exportName,
// final String targetDir) {
//
// final Path targetDirPath = Paths.get(targetDir);
//
// final Set<String> types = entities
// .stream()
// .map(entity -> entity.getClass().getName())
// .collect(Collectors.toSet());
//
// if (!Files.isDirectory(targetDirPath)) {
// throw new IllegalArgumentException(String.format(
// "Path %s does not point to a directory.",
// targetDir));
// }
//
// if (!Files.isWritable(targetDirPath)) {
// throw new IllegalArgumentException(String.format(
// "Path %s is not writable.",
// targetDir));
// }
//
// final Path exportDir = targetDirPath.resolve(exportName);
// final Path exportDirPath;
// try {
// exportDirPath = Files.createDirectory(exportDir);
// } catch (IOException ex) {
// throw new UncheckedWrapperException(ex);
// }
// final Path manifestFilePath = exportDirPath.resolve("ccm-export.json");
//
// final JsonFactory factory = new JsonFactory();
// final Map<String, List<Exportable>> typeEntityMap;
// try (final JsonGenerator manifestGenerator = factory
// .createGenerator(manifestFilePath.toFile(),
// JsonEncoding.UTF8)) {
//
// manifestGenerator.writeStartObject();
// manifestGenerator.writeStringField(
// "created",
// LocalDateTime.now(ZoneId.of("UTC")).toString());
// manifestGenerator.writeStringField(
// "onServer",
// WebConfig.getInstanceOf().getSiteName());
// manifestGenerator.writeFieldName("types");
// manifestGenerator.writeStartArray();
// typeEntityMap = new HashMap<>();
// for (final String type : types) {
//
// final Path typePath = exportDirPath.resolve(type);
// Files.createDirectory(typePath);
// manifestGenerator.writeString(type);
//
// final List<Exportable> entitiesOfType = entities
// .stream()
// .filter(entity -> entity.getClass().getName().equals(type))
// .collect(Collectors.toList());
//
// typeEntityMap.put(type, entitiesOfType);
// }
//
// manifestGenerator.writeEndArray();
//
// manifestGenerator.writeFieldName("entities");
// manifestGenerator.writeStartObject();
//
// for (final Map.Entry<String, List<Exportable>> entry : typeEntityMap
// .entrySet()) {
//
// final String type = entry.getKey();
// final List<Exportable> entitiesOfType = entry.getValue();
// final Path typeDirPath = exportDirPath.resolve(type);
// Files.createDirectory(typeDirPath);
// final List<String> exportedEntities = createExportedEntities(
// targetDirPath, type, entitiesOfType);
//
// manifestGenerator.writeFieldName(type);
// manifestGenerator.writeStartArray();
// for (final String exportedEntity : exportedEntities) {
// manifestGenerator.writeString(exportedEntity);
// }
// manifestGenerator.writeEndArray();
// }
//
// manifestGenerator.writeEndObject();
// manifestGenerator.writeEndObject();
// } catch (IOException ex) {
// throw new UncheckedWrapperException(ex);
// }
// }
//
// private List<String> createExportedEntities(
// final Path targetDir,
// final String type,
// final List<Exportable> entities) {
//
// final List<String> exportedEntites = new ArrayList<>();
//
// for (final Exportable entity : entities) {
//
// exportEntity(targetDir, entity);
// exportedEntites.add(entity.getUuid());
// }
//
// return exportedEntites;
// }
//
// private void exportEntity(final Path targetDir,
// final Exportable entity) {
//
//// if (EXPORTERS.containsKey(entity.getClass().getName())) {
//// throw new IllegalArgumentException(String.format(
//// "No exporter for type \"%s\" available.",
//// entity.getClass().getName()));
//// }
// final Path entityFilePath = targetDir
// .resolve(String.format("%s.json", entity.getUuid()));
//
//// final AbstractExporter<?> exporter = EXPORTERS
//// .get(entity.getClass().getName());
//// final String data = exporter.exportEntity(entity);
// try {
// final String data = objectMapper.writeValueAsString(entity);
//
// Files.write(entityFilePath, data.getBytes(StandardCharsets.UTF_8));
// } catch (IOException ex) {
// throw new UncheckedWrapperException(ex);
// }
// }
}

View File

@ -0,0 +1,12 @@
package org.libreccm.export;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public interface Exportable {
String getUuid();
void setUuid(String uuid);
}

View File

@ -0,0 +1,26 @@
package org.libreccm.export;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class IdSequence {
private static final IdSequence INSTANCE = new IdSequence();
private long idSequence = 0;
private IdSequence() {
// Nothing
}
public static IdSequence getInstance() {
return INSTANCE;
}
public long nextId() {
idSequence++;
return idSequence;
}
}

View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.export.cmd;
import com.arsdigita.util.cmd.Program;
import org.apache.commons.cli.CommandLine;
import org.libreccm.export.ExportManager;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* A Commandline tool for exporting all the objects of specified classes to
* one or many specified file types.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ExportCliTool extends Program {
/**
* Constructor for the command line tool.
*/
private ExportCliTool() {
super("Export Commandline Tool",
"1.0.0",
"Export of all entities for reimport in LibreCCM 7");
}
/**
* Main method, which calls the {@code doRun}-method and hands the given
* arguments over to that method.
*
* @param args The command line arguments
*/
public static void main(final String[] args) {
new ExportCliTool().run(args);
}
@Override
protected void doRun(final CommandLine cmdLine) {
String[] args = cmdLine.getArgs();
if (args.length < 1) {
System.out.println("Usage ExportCliTool $targetDir");
System.exit(-1);
}
final String targetDir = args[0];
final Path targetDirPath = Paths.get(targetDir);
ExportManager.getInstance().exportData(targetDirPath);
}
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.cmd;
package org.libreccm.export.cmd;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.cmd;
package org.libreccm.export.cmd;
import java.lang.reflect.Method;

View File

@ -16,11 +16,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.cmd;
package org.libreccm.export.cmd;
import com.arsdigita.portation.modules.CoreExporter;
import java.lang.reflect.Method;
import org.libreccm.export.modules.CoreExporter;
/**
* Helper class to bundle all export calls.
@ -49,7 +47,7 @@ public class RootExporter {
.getDeclaredMethod("startMarshaller");
startExport.invoke(cls.newInstance());
}*/
// ...
}
}

View File

@ -16,17 +16,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
package org.libreccm.export.convert;
/**
* Abstract super class for conversion from trunk objects to ng object. The
* class demands the implementation of the following method of the
* appropriate converters.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created the 7/28/17
*/
public abstract class AbstractConverter {
public abstract class AbstractDomainObjectConverter {
/**
* Method, to start all the different converter classes in a specific
* order, so that dependencies can only be set, where the objects have

View File

@ -16,16 +16,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
package org.libreccm.export.convert;
import com.arsdigita.domain.DomainObject;
/**
* Abstract class for converting all trunk objects of a certain class into
* objects of their corresponding ng classes.
*
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 2/7/18
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@uni-bremen.de">Jens Pelzetter</a>
*/
public abstract class AbstractConversion {
public abstract class AbstractDomainObjectsConverter {
public abstract String convertsType();
/**
* Retrieves all trunk objects of a certain class from the persistent

View File

@ -16,13 +16,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
package org.libreccm.export.convert;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers<\a>
* @version created the 7/28/17
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
*/
public abstract class AbstractExporter {
public abstract class AbstractExporterManager {
protected static Format format;
protected static String pathName;

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
package org.libreccm.export.convert;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@ -0,0 +1,113 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.export.convert;
import org.libreccm.categorization.Categorization;
import org.libreccm.categorization.Category;
import org.libreccm.categorization.Domain;
import org.libreccm.categorization.DomainOwnership;
import org.libreccm.core.CcmObject;
import org.libreccm.core.Resource;
import org.libreccm.core.ResourceType;
import org.libreccm.security.Group;
import org.libreccm.security.GroupMembership;
import org.libreccm.security.Party;
import org.libreccm.security.Permission;
import org.libreccm.security.Role;
import org.libreccm.security.RoleMembership;
import org.libreccm.security.User;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.AssignableTask;
import org.libreccm.workflow.Task;
import org.libreccm.workflow.TaskAssignment;
import org.libreccm.workflow.TaskComment;
import org.libreccm.workflow.TaskDependency;
import org.libreccm.workflow.Workflow;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Storage class for all ng-objects after conversion. This also helps for an
* easier access for the restoration of the dependencies.
*
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @author <a href="mailto:jens.pelzetter@googlemail.com">jens Pelzetter</a>
*/
public class CcmCoreEntities {
public final static Map<Long, Party> PARTIES = new HashMap<>();
public final static Map<Long, User> USERS = new HashMap<>();
public final static Map<Long, Group> GROUPS = new HashMap<>();
public final static Map<Long, GroupMembership> GROUP_MEMBERSHIPS
= new HashMap<>();
public final static Map<Long, Role> ROLES = new HashMap<>();
public final static Map<Long, RoleMembership> ROLE_MEMBERSHIPS
= new HashMap<>();
public final static Map<Long, CcmObject> CCM_OBJECTS = new HashMap<>();
public final static Map<Long, Category> CATEGORIES = new HashMap<>();
public final static Map<Long, Categorization> CATEGORIZATIONS
= new HashMap<>();
public final static Map<Long, Permission> PERMISSIONS = new HashMap<>();
public final static Map<Long, Workflow> WORKFLOWS = new HashMap<>();
public final static Map<Long, TaskComment> TASK_COMMENTS = new HashMap<>();
public final static Map<Long, Task> TASKS = new HashMap<>();
public final static Map<Long, AssignableTask> ASSIGNABLE_TASKS
= new HashMap<>();
public final static Map<Long, TaskDependency> TASK_DEPENDENCIES
= new HashMap<>();
public final static Map<Long, TaskAssignment> TASK_ASSIGNMENTS
= new HashMap<>();
public final static Map<Long, ResourceType> RESOURCE_TYPES = new HashMap<>();
public final static Map<Long, Resource> resources = new HashMap<>();
public final static Map<Long, CcmApplication> CCM_APPLICATIONS
= new HashMap<>();
public final static Map<Long, Domain> DOMAINS = new HashMap<>();
public final static Map<Long, DomainOwnership> DOMAIN_OWNERSHIPS
= new HashMap<>();
// in case maps need to be sorted for export
public static List<Category> SORTED_CATEGORIES = new ArrayList<>();
public static List<Workflow> SORTED_WORKFLOWS = new ArrayList<>();
public static List<AssignableTask> SORTED_ASSIGNABLE_TASKS
= new ArrayList<>();
public static List<CcmApplication> SORTED_CCM_APPLICATIONS
= new ArrayList<>();
/**
* Private constructor to prevent the instantiation of this class.
*/
private CcmCoreEntities() {
}
}

View File

@ -16,21 +16,26 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation.conversion;
package org.libreccm.export.convert;
import com.arsdigita.portation.AbstractConverter;
import com.arsdigita.portation.conversion.core.categorization.CategoryConversion;
import com.arsdigita.portation.conversion.core.categorization.DomainConversion;
import com.arsdigita.portation.conversion.core.core.ResourceTypeConversion;
import com.arsdigita.portation.conversion.core.security.GroupConversion;
import com.arsdigita.portation.conversion.core.security.PermissionConversion;
import com.arsdigita.portation.conversion.core.security.RoleConversion;
import com.arsdigita.portation.conversion.core.security.UserConversion;
import com.arsdigita.portation.conversion.core.web.CcmApplicationConversion;
import com.arsdigita.portation.conversion.core.workflow.AssignableTaskConversion;
import com.arsdigita.portation.conversion.core.workflow.TaskCommentConversion;
import com.arsdigita.portation.conversion.core.workflow.WorkflowConversion;
import com.arsdigita.portation.modules.core.security.Permission;
import org.libreccm.export.convert.categorization.CategoriesConverter;
import org.libreccm.export.convert.categorization.DomainsConverter;
import org.libreccm.export.convert.core.ResourceTypesConverter;
import org.libreccm.export.convert.security.GroupsConverter;
import org.libreccm.export.convert.security.PermissionsConverter;
import org.libreccm.export.convert.security.RolesConverter;
import org.libreccm.export.convert.security.UsersConverter;
import org.libreccm.export.convert.web.CcmApplicationsConverter;
import org.libreccm.export.convert.workflow.AssignableTasksConverter;
import org.libreccm.export.convert.workflow.TaskCommentsConverter;
import org.libreccm.export.convert.workflow.WorkflowsConverter;
import org.libreccm.security.Permission;
/**
@ -42,7 +47,7 @@ import com.arsdigita.portation.modules.core.security.Permission;
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 6/27/16
*/
public class CoreConverter extends AbstractConverter {
public class CoreConverter extends AbstractDomainObjectConverter {
private static CoreConverter instance;
@ -66,20 +71,20 @@ public class CoreConverter extends AbstractConverter {
*/
@Override
public void startConversions() {
UserConversion.getInstance().convertAll();
GroupConversion.getInstance().convertAll();
RoleConversion.getInstance().convertAll();
UsersConverter.getInstance().convertAll();
GroupsConverter.getInstance().convertAll();
RolesConverter.getInstance().convertAll();
CategoryConversion.getInstance().convertAll();
CategoriesConverter.getInstance().convertAll();
PermissionConversion.getInstance().convertAll();
PermissionsConverter.getInstance().convertAll();
WorkflowConversion.getInstance().convertAll();
TaskCommentConversion.getInstance().convertAll();
AssignableTaskConversion.getInstance().convertAll();
WorkflowsConverter.getInstance().convertAll();
TaskCommentsConverter.getInstance().convertAll();
AssignableTasksConverter.getInstance().convertAll();
ResourceTypeConversion.getInstance().convertAll();
CcmApplicationConversion.getInstance().convertAll();
DomainConversion.getInstance().convertAll();
ResourceTypesConverter.getInstance().convertAll();
CcmApplicationsConverter.getInstance().convertAll();
DomainsConverter.getInstance().convertAll();
}
}

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
package org.libreccm.export.convert;
/**
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>

View File

@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package com.arsdigita.portation;
package org.libreccm.export.convert;
/**
* Interface for the ex-/import routine. With this interface any object class

Some files were not shown because too many files have changed in this diff Show More