Exporters for Images, some bug fixes

git-svn-id: https://svn.libreccm.org/ccm/trunk@5727 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2018-11-06 19:13:51 +00:00
parent a212bb7b37
commit 1594b79ce9
5 changed files with 362 additions and 130 deletions

View File

@ -29,15 +29,20 @@ import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.runtime.DomainInitEvent; import com.arsdigita.runtime.DomainInitEvent;
import org.libreccm.export.ExportManager;
import org.librecms.assets.ImageAttachmentsExporter;
/** /**
* Initializes the imagestep content item asset. * Initializes the imagestep content item asset.
* *
* @version $Id: ItemImageAttachmentInitializer.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: ItemImageAttachmentInitializer.java 287 2005-02-22 00:29:02Z
* sskracic $
*/ */
public class ItemImageAttachmentInitializer extends ContentAssetInitializer { public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
/** /**
* Constructor, sets its specific manifest file and delegates to super class. * Constructor, sets its specific manifest file and delegates to super
* class.
*/ */
public ItemImageAttachmentInitializer() { public ItemImageAttachmentInitializer() {
super("ccm-cms-assets-imagestep.pdl.mf"); super("ccm-cms-assets-imagestep.pdl.mf");
@ -53,9 +58,10 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
super.init(ev); super.init(ev);
DomainObjectFactory.registerInstantiator( DomainObjectFactory.registerInstantiator(
ItemImageAttachment.BASE_DATA_OBJECT_TYPE, ItemImageAttachment.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() { new DomainObjectInstantiator() {
@Override
@Override
protected DomainObject doNewInstance(DataObject obj) { protected DomainObject doNewInstance(DataObject obj) {
return new ItemImageAttachment(obj); return new ItemImageAttachment(obj);
} }
@ -70,13 +76,17 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
//register checker in ReusableImage //register checker in ReusableImage
ReusableImageAsset.registerImageInUseChecker(new ImageInUseCheck()); ReusableImageAsset.registerImageInUseChecker(new ImageInUseCheck());
ExportManager
.getInstance()
.registerExporter(new ImageAttachmentsExporter());
} }
/** /**
* The base type against which the asset is defined, * The base type against which the asset is defined, typically
* typically com.arsdigita.cms.ContentPage * com.arsdigita.cms.ContentPage
*/ */
@Override @Override
public String getBaseType() { public String getBaseType() {
return ContentPage.BASE_DATA_OBJECT_TYPE; return ContentPage.BASE_DATA_OBJECT_TYPE;
} }
@ -85,17 +95,17 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
* Returns the path to the XML file defintions for the asset, eg: * Returns the path to the XML file defintions for the asset, eg:
* /WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/FileAttachments.xml * /WEB-INF/traversal-adapters/com/arsdigita/cms/contentassets/FileAttachments.xml
*/ */
@Override @Override
public String getTraversalXML() { public String getTraversalXML() {
return "/WEB-INF/traversal-adapters/com/arsdigita/" + return "/WEB-INF/traversal-adapters/com/arsdigita/"
"cms/contentassets/ItemImageAttachment.xml"; + "cms/contentassets/ItemImageAttachment.xml";
} }
/** /**
* The name of the association between the item * The name of the association between the item and the asset, eg
* and the asset, eg 'fileAttachments'. * 'fileAttachments'.
*/ */
@Override @Override
public String getProperty() { public String getProperty() {
return "imageAttachments"; return "imageAttachments";
} }
@ -103,7 +113,7 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
/** /**
* The class of the authoring kit step * The class of the authoring kit step
*/ */
@Override @Override
public Class getAuthoringStep() { public Class getAuthoringStep() {
return ImageStep.class; return ImageStep.class;
} }
@ -111,25 +121,27 @@ public class ItemImageAttachmentInitializer extends ContentAssetInitializer {
/** /**
* The label for the authoring step * The label for the authoring step
*/ */
@Override @Override
public GlobalizedMessage getAuthoringStepLabel() { public GlobalizedMessage getAuthoringStepLabel() {
return new GlobalizedMessage("com.arsdigita.cms.contentassets.image_step_label", return new GlobalizedMessage(
"com.arsdigita.cms.contentassets.ImageStepResources"); "com.arsdigita.cms.contentassets.image_step_label",
"com.arsdigita.cms.contentassets.ImageStepResources");
} }
/** /**
* The description for the authoring step * The description for the authoring step
*/ */
@Override @Override
public GlobalizedMessage getAuthoringStepDescription() { public GlobalizedMessage getAuthoringStepDescription() {
return new GlobalizedMessage("com.arsdigita.cms.contentassets.image_step_description", return new GlobalizedMessage(
"com.arsdigita.cms.contentassets.ImageStepResources"); "com.arsdigita.cms.contentassets.image_step_description",
"com.arsdigita.cms.contentassets.ImageStepResources");
} }
/** /**
* The sort key for the authoring step * The sort key for the authoring step
*/ */
@Override @Override
public int getAuthoringStepSortKey() { public int getAuthoringStepSortKey() {
return ItemImageAttachmentConfig.instanceOf().getImageStepSortKey(); return ItemImageAttachmentConfig.instanceOf().getImageStepSortKey();
} }

View File

@ -0,0 +1,129 @@
package org.librecms.assets;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ReusableImageAsset;
import com.arsdigita.cms.contentassets.ItemImageAttachment;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
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 org.librecms.contentsection.AbstractAttachmentListsExporter;
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.List;
import java.util.UUID;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ImageAttachmentsExporter
extends AbstractDomainObjectsExporter<ContentItem> {
@Override
public Class<ContentItem> exportsType() {
return ContentItem.class;
}
@Override
public String exportsBaseDataObjectType() {
return ContentItem.BASE_DATA_OBJECT_TYPE;
}
@Override
public String convertsToType() {
return "org.librecms.contentsection.ItemAttachment";
}
@Override
protected boolean includeSubTypes() {
return true;
}
@Override
protected List<String> exportDomainObject(
final ContentItem item, final Path targetDir) {
final String listUuid = AbstractAttachmentListsExporter
.generateListUuid(item, "images");
final List<String> attachmentsUuids = new ArrayList<>();
final DataCollection imageAttachments = ItemImageAttachment
.getImageAttachments(item);
long sortKey = 0;
while (imageAttachments.next()) {
sortKey++;
final String uuid = exportImageAttachment(imageAttachments
.getDataObject(),
listUuid,
sortKey,
targetDir);
attachmentsUuids.add(uuid);
}
return attachmentsUuids;
}
private String exportImageAttachment(final DataObject dataObj,
final String listUuid,
final long sortKey,
final Path targetDir) {
final ItemImageAttachment imageAttachment = new ItemImageAttachment(
dataObj);
final ReusableImageAsset imageAsset = imageAttachment.getImage();
final String imageAssetUuid = generateUuid(imageAsset);
final byte[] uuidSource = String.format(
"%s/images/%s",
WebConfig.getInstanceOf().getSiteName(),
imageAttachment.getOID().toString())
.getBytes(StandardCharsets.UTF_8);
final String uuid = UUID.nameUUIDFromBytes(uuidSource).toString();
final Path targetFilePath = generateTargetFilePath(targetDir, uuid);
final File targetFile = targetFilePath.toFile();
final JsonFactory jsonFactory = new JsonFactory();
try (JsonGenerator jsonGenerator = jsonFactory
.createGenerator(targetFile, JsonEncoding.UTF8)) {
jsonGenerator.writeStartObject();
jsonGenerator.writeNumberField("attachmentId",
IdSequence.getInstance().nextId());
jsonGenerator.writeStringField("uuid", uuid);
jsonGenerator.writeStringField("attachmentList", listUuid);
jsonGenerator.writeStringField("asset", imageAssetUuid);
jsonGenerator.writeNumberField("sortKey", sortKey);
jsonGenerator.writeEndObject();
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
return uuid;
}
}

View File

@ -85,7 +85,14 @@ import com.arsdigita.xml.XML;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.libreccm.export.ExportManager; import org.libreccm.export.ExportManager;
import org.librecms.contentsection.AbstractAttachmentListsExporter; import org.librecms.assets.ImagesExporter;
import org.librecms.contentsection.ContentSectionsExporter;
import org.librecms.contentsection.ContentTypesExporter;
import org.librecms.contentsection.FoldersExporter;
import org.librecms.lifecycle.LifecycleDefinitionsExporter;
import org.librecms.lifecycle.LifecyclesExporter;
import org.librecms.lifecycle.PhaseDefinitionsExporter;
import org.librecms.lifecycle.PhasesExporter;
import org.librecms.workflow.CmsTasksExporter; import org.librecms.workflow.CmsTasksExporter;
/** /**
@ -97,9 +104,13 @@ import org.librecms.workflow.CmsTasksExporter;
*/ */
public class Initializer extends CompoundInitializer { public class Initializer extends CompoundInitializer {
/** Creates a s_logging category with name = to the full name of class */ /**
* Creates a s_logging category with name = to the full name of class
*/
private static Logger s_log = Logger.getLogger(Initializer.class); private static Logger s_log = Logger.getLogger(Initializer.class);
/** Configuration object for the CMS module */ /**
* Configuration object for the CMS module
*/
private static final CMSConfig s_conf = CMSConfig.getInstanceOf(); private static final CMSConfig s_conf = CMSConfig.getInstanceOf();
/** /**
@ -114,7 +125,8 @@ public class Initializer extends CompoundInitializer {
add(new PDLInitializer(new ManifestSource("ccm-cms.pdl.mf", add(new PDLInitializer(new ManifestSource("ccm-cms.pdl.mf",
new NameFilter(DbHelper new NameFilter(DbHelper
.getDatabaseSuffix(database), .getDatabaseSuffix(
database),
"pdl")))); "pdl"))));
add(new com.arsdigita.cms.contentsection.Initializer()); add(new com.arsdigita.cms.contentsection.Initializer());
@ -126,8 +138,8 @@ public class Initializer extends CompoundInitializer {
} }
/** /**
* Initializes domain-coupling machinery, usually consisting of * Initializes domain-coupling machinery, usually consisting of registering
* registering object instantiators and observers. * object instantiators and observers.
*/ */
@Override @Override
public void init(DomainInitEvent e) { public void init(DomainInitEvent e) {
@ -137,25 +149,29 @@ public class Initializer extends CompoundInitializer {
/* Register object instantiator for ContentCenter (Content Center) */ /* Register object instantiator for ContentCenter (Content Center) */
e.getFactory().registerInstantiator(ContentCenter.BASE_DATA_OBJECT_TYPE, e.getFactory().registerInstantiator(ContentCenter.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() { new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dobj) {
return new ContentCenter(dobj);
}
}); @Override
public DomainObject doNewInstance(
DataObject dobj) {
return new ContentCenter(dobj);
}
});
LanguageUtil.setSupportedLanguages( LanguageUtil.setSupportedLanguages(
Kernel.getConfig().getSupportedLanguages()); Kernel.getConfig().getSupportedLanguages());
/* Register object instantiator for CMS Service */ /* Register object instantiator for CMS Service */
e.getFactory().registerInstantiator(Service.BASE_DATA_OBJECT_TYPE, e.getFactory().registerInstantiator(Service.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() { new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dobj) {
return new Service(dobj);
}
}); @Override
public DomainObject doNewInstance(
DataObject dobj) {
return new Service(dobj);
}
});
URLService.registerFinder(ContentPage.BASE_DATA_OBJECT_TYPE, URLService.registerFinder(ContentPage.BASE_DATA_OBJECT_TYPE,
new ItemURLFinder()); new ItemURLFinder());
@ -167,22 +183,24 @@ public class Initializer extends CompoundInitializer {
new AssetURLFinder()); new AssetURLFinder());
URLService.registerFinder( URLService.registerFinder(
Link.BASE_DATA_OBJECT_TYPE, Link.BASE_DATA_OBJECT_TYPE,
new URLFinder() { new URLFinder() {
public String find(OID oid, String context) public String find(OID oid, String context)
throws NoValidURLException { throws NoValidURLException {
return find(oid); return find(oid);
} }
public String find(OID oid) public String find(OID oid)
throws NoValidURLException { throws NoValidURLException {
Link link; Link link;
try { try {
link = (Link) DomainObjectFactory.newInstance(oid); link = (Link) DomainObjectFactory.newInstance(oid);
} catch (DataObjectNotFoundException ex) { } catch (DataObjectNotFoundException ex) {
throw new NoValidURLException("Cannot find an object with oid: " + oid); throw new NoValidURLException(
"Cannot find an object with oid: " + oid);
} }
if (Link.EXTERNAL_LINK.equals(link.getTargetType())) { if (Link.EXTERNAL_LINK.equals(link.getTargetType())) {
@ -224,17 +242,20 @@ public class Initializer extends CompoundInitializer {
// Just set the class implementing methods run when for publishing // Just set the class implementing methods run when for publishing
// or unpublishing to file. No initialisation of the class here. // or unpublishing to file. No initialisation of the class here.
try { try {
QueueManager.setListener((PublishToFileListener) ContentSection.getConfig() QueueManager.setListener((PublishToFileListener) ContentSection
.getPublishToFileClass().newInstance()); .getConfig()
.getPublishToFileClass().newInstance());
} catch (InstantiationException ex) { } catch (InstantiationException ex) {
throw new UncheckedWrapperException("Failed to instantiate the listener class", ex); throw new UncheckedWrapperException(
"Failed to instantiate the listener class", ex);
} catch (IllegalAccessException ex) { } catch (IllegalAccessException ex) {
throw new UncheckedWrapperException("Couldn't access the listener class", ex); throw new UncheckedWrapperException(
"Couldn't access the listener class", ex);
} }
MetadataProviderRegistry.registerAdapter( MetadataProviderRegistry.registerAdapter(
FileAsset.BASE_DATA_OBJECT_TYPE, FileAsset.BASE_DATA_OBJECT_TYPE,
new AssetMetadataProvider()); new AssetMetadataProvider());
//Register the ApplicationManager implementations provided by this module //Register the ApplicationManager implementations provided by this module
ApplicationManagers.register(new ContentCenterAppManager()); ApplicationManagers.register(new ContentCenterAppManager());
@ -243,18 +264,28 @@ public class Initializer extends CompoundInitializer {
if (s_conf.getAttachPersonOrgaUnitsStep()) { if (s_conf.getAttachPersonOrgaUnitsStep()) {
AuthoringKitWizard.registerAssetStep( AuthoringKitWizard.registerAssetStep(
GenericPerson.BASE_DATA_OBJECT_TYPE, GenericPerson.BASE_DATA_OBJECT_TYPE,
GenericPersonOrgaUnitsStep.class, GenericPersonOrgaUnitsStep.class,
ContenttypesGlobalizationUtil.globalize("person.authoring.orgas.title"), ContenttypesGlobalizationUtil.globalize(
ContenttypesGlobalizationUtil.globalize("person.authoring.orgas.title"), "person.authoring.orgas.title"),
s_conf.getPersonOrgaUnitsStepSortKey()); ContenttypesGlobalizationUtil.globalize(
"person.authoring.orgas.title"),
s_conf.getPersonOrgaUnitsStepSortKey());
} }
ExportManager.getInstance().registerExporter(new CmsTasksExporter()); ExportManager.getInstance().registerExporter(new CmsTasksExporter());
// ExportManager ExportManager
// .getInstance() .getInstance()
// .registerExporter(new AbstractAttachmentListsExporter()); .registerExporter(new ContentSectionsExporter());
ExportManager.getInstance().registerExporter(new ContentTypesExporter());
ExportManager.getInstance().registerExporter(new FoldersExporter());
ExportManager.getInstance().registerExporter(new ImagesExporter());
ExportManager.getInstance().registerExporter(new LifecyclesExporter());
ExportManager.getInstance()
.registerExporter(new LifecycleDefinitionsExporter());
ExportManager.getInstance().registerExporter(
new PhaseDefinitionsExporter());
ExportManager.getInstance().registerExporter(new PhasesExporter());
s_log.debug("CMS.Initializer.init(DomainInitEvent) completed"); s_log.debug("CMS.Initializer.init(DomainInitEvent) completed");
} // END init(DomainInitEvent e) } // END init(DomainInitEvent e)
@ -263,12 +294,12 @@ public class Initializer extends CompoundInitializer {
*/ */
private void registerPatternGenerators() { private void registerPatternGenerators() {
PatternStylesheetResolver.registerPatternGenerator( PatternStylesheetResolver.registerPatternGenerator(
"item_template_oid", "item_template_oid",
new ItemTemplatePatternGenerator()); new ItemTemplatePatternGenerator());
PatternStylesheetResolver.registerPatternGenerator( PatternStylesheetResolver.registerPatternGenerator(
"item_delegated_url", "item_delegated_url",
new ItemDelegatedURLPatternGenerator()); new ItemDelegatedURLPatternGenerator());
} }
/** /**
@ -279,83 +310,98 @@ public class Initializer extends CompoundInitializer {
// Register the CMSTaskInstaniator // Register the CMSTaskInstaniator
f.registerInstantiator(CMSTask.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(CMSTask.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() { new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new CMSTask(dataObject);
}
}); @Override
public DomainObject doNewInstance(
DataObject dataObject) {
return new CMSTask(dataObject);
}
});
f.registerInstantiator(CMSTaskType.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(CMSTaskType.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() { new DomainObjectInstantiator() {
public DomainObject doNewInstance(DataObject dataObject) {
return new CMSTaskType(dataObject);
}
}); public DomainObject doNewInstance(
DataObject dataObject) {
return new CMSTaskType(dataObject);
}
});
f.registerInstantiator(TaskEventURLGenerator.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(TaskEventURLGenerator.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() { new DomainObjectInstantiator() {
public DomainObject doNewInstance(DataObject dataObject) {
return new TaskEventURLGenerator(dataObject);
}
}); public DomainObject doNewInstance(
DataObject dataObject) {
return new TaskEventURLGenerator(dataObject);
}
});
f.registerInstantiator(Workflow.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(Workflow.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() { new ACSObjectInstantiator() {
public DomainObject doNewInstance(DataObject dataObject) {
return new Workflow(dataObject);
}
}); public DomainObject doNewInstance(
DataObject dataObject) {
return new Workflow(dataObject);
}
});
f.registerInstantiator(WorkflowTemplate.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(WorkflowTemplate.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() { new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new WorkflowTemplate(dataObject);
}
}); @Override
public DomainObject doNewInstance(
DataObject dataObject) {
return new WorkflowTemplate(dataObject);
}
});
f.registerInstantiator(TemplateContext.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(TemplateContext.BASE_DATA_OBJECT_TYPE,
new DomainObjectInstantiator() { new DomainObjectInstantiator() {
public DomainObject doNewInstance(DataObject dataObject) {
return new TemplateContext(dataObject);
}
@Override public DomainObject doNewInstance(
public DomainObjectInstantiator resolveInstantiator(DataObject obj) { DataObject dataObject) {
return this; return new TemplateContext(dataObject);
} }
}); @Override
public DomainObjectInstantiator resolveInstantiator(
DataObject obj) {
return this;
}
});
f.registerInstantiator(RelationAttribute.BASE_DATA_OBJECT_TYPE, f.registerInstantiator(RelationAttribute.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() { new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new RelationAttribute(dataObject);
}
}); @Override
public DomainObject doNewInstance(
DataObject dataObject) {
return new RelationAttribute(dataObject);
}
});
} }
private void registerLuceneEngine() { private void registerLuceneEngine() {
QueryEngineRegistry.registerEngine(IndexerType.LUCENE, QueryEngineRegistry.registerEngine(IndexerType.LUCENE,
new FilterType[]{ new FilterType[]{
new CategoryFilterType(), new CategoryFilterType(),
new ContentSectionFilterType(), new ContentSectionFilterType(),
new CMSContentSectionFilterType(), new CMSContentSectionFilterType(),
new ContentTypeFilterType(), new ContentTypeFilterType(),
new CreationDateFilterType(), new CreationDateFilterType(),
new CreationUserFilterType(), new CreationUserFilterType(),
new LastModifiedDateFilterType(), new LastModifiedDateFilterType(),
new LastModifiedUserFilterType(), new LastModifiedUserFilterType(),
new ObjectTypeFilterType(), new ObjectTypeFilterType(),
new PermissionFilterType(), new PermissionFilterType(),
new VersionFilterType() new VersionFilterType()
}, },
new LuceneQueryEngine()); new LuceneQueryEngine());
} }
@ -363,19 +409,19 @@ public class Initializer extends CompoundInitializer {
QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA, QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA,
new FilterType[]{ new FilterType[]{
new CategoryFilterType(), new CategoryFilterType(),
new ContentSectionFilterType(), new ContentSectionFilterType(),
new CMSContentSectionFilterType(), new CMSContentSectionFilterType(),
new ContentTypeFilterType(), new ContentTypeFilterType(),
new CreationDateFilterType(), new CreationDateFilterType(),
new CreationUserFilterType(), new CreationUserFilterType(),
new LastModifiedDateFilterType(), new LastModifiedDateFilterType(),
new LastModifiedUserFilterType(), new LastModifiedUserFilterType(),
new LaunchDateFilterType(), new LaunchDateFilterType(),
new ObjectTypeFilterType(), new ObjectTypeFilterType(),
new PermissionFilterType(), new PermissionFilterType(),
new VersionFilterType() new VersionFilterType()
}, },
new IntermediaQueryEngine()); new IntermediaQueryEngine());
} }

View File

@ -0,0 +1,44 @@
package org.librecms.assets;
import com.arsdigita.cms.ReusableImageAsset;
import com.fasterxml.jackson.core.JsonGenerator;
import org.librecms.contentsection.AbstractBinaryAssetsExporter;
import java.io.IOException;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ImagesExporter
extends AbstractBinaryAssetsExporter<ReusableImageAsset> {
@Override
protected void exportBinaryAssetProperties(
final ReusableImageAsset asset, final JsonGenerator jsonGenerator)
throws IOException {
jsonGenerator.writeNumberField("width", asset.getWidth());
jsonGenerator.writeNumberField("height", asset.getHeight());
}
@Override
public Class<ReusableImageAsset> exportsType() {
return ReusableImageAsset.class;
}
@Override
public String exportsBaseDataObjectType() {
return ReusableImageAsset.BASE_DATA_OBJECT_TYPE;
}
@Override
public String convertsToType() {
return "org.librecms.assets.Image";
}
}

View File

@ -27,7 +27,8 @@ import java.util.UUID;
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
public class ContentTypesExporter extends AbstractDomainObjectsExporter<ContentType> { public class ContentTypesExporter
extends AbstractDomainObjectsExporter<ContentType> {
@Override @Override
public Class<ContentType> exportsType() { public Class<ContentType> exportsType() {