Skifteri
Skifteri

Reputation: 1

Import content to AEM

We have a lot content that need to be imported in AEM. what is best way to import it? Is that any possibilities to import from excel file?

check this example

An good example for exporting is here /etc/importers/bulkeditor.html we can export the file with single "Properties / Columns" where i can define the Root Path and Properties.

I tried this packet but dos not contain what I like. https://helpx.adobe.com/experience-manager/using/creating-custom-excel-service-experience.html

Upvotes: 0

Views: 5097

Answers (3)

ccpizza
ccpizza

Reputation: 31676

Content can be imported via the SlingPostServlet with :operation=import: https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#importing-content-structures. Here is an example adapted from the page:

curl -u admin:admin http://localhost:4502/content/mysite/mypage \ 
    -F":operation=import" \
    -F":contentType=json" 
    -F":name=sample" \    
    -F":content={ 'jcr:primaryType': 'nt:unstructured', 'propOne' : 'propOneValue', 'childOne' : { 'childPropOne' : true } }"

Another author-friendly option is the CSV Asset Importer included with the ACS AEM Tools package. You can save an Excel file to CSV so this should be the easy option.

Upvotes: 0

Oliver Gebert
Oliver Gebert

Reputation: 1176

Importing data to AEM can be done in lots of ways.

What is the "right" way for you, depends on your specific requirements.

  • Is this a one time import, or are you rather planning to write a reusable import tool?
  • Is the import done by programmers or admins, or rather by editors?
  • Do you need fault tolerance or a rollback? Are you working on productive instances?
  • ...

Here are a few of the more or less common ways (ordered from cheap/fast to extensive/comfortable) along with links to the documentation or examples:

  1. Write a bash-script and post values with cURL requests (1)
  2. Upload data in DAM, write EventHandler (2), (7) or a workflow (3) with a workflow launcher (4) and parse the data, afterwards change the repository.
  3. Upload data in separate file in an own component with a file upload section (5), parse the data and change the repository.

For parsing excel data I would suggest you use apache poi (6), which is already included in AEM. But using formats like csv, json or xml will maybe save you lots of parsing efforts.

(1): http://www.aemcq5tutorials.com/tutorials/adobe-cq5-aem-curl-commands/

(2): https://osgi.org/javadoc/r4v42/index.html?org/osgi/service/event/EventHandler.html

(3): https://docs.adobe.com/docs/en/aem/6-1/develop/extending/workflows/wf-extending.html

(4): https://docs.adobe.com/docs/en/aem/6-1/administer/operations/workflows/wf-start.html

(5): https://helpx.adobe.com/experience-manager/using/uploading-files-aem1.html

(6): https://poi.apache.org/spreadsheet/index.html

(7): code example

@Service
@Component(immediate = true, policy = ConfigurationPolicy.OPTIONAL, description = "Listen to page modification events and track them.")
@Properties(value = { @Property(name = "event.topics", value = { PageEvent.EVENT_TOPIC, DamEvent.EVENT_TOPIC}, propertyPrivate = true),
                      @Property(name = JobConsumer.PROPERTY_TOPICS, value = ModificationEventHandler.JOB_TOPICS, propertyPrivate = true) })
public class ModificationEventHandler implements EventHandler, JobConsumer {
@Override public void handleEvent(Event event) {
    logger.trace("Checking event.");
    PageEvent pageEvent = PageEvent.fromEvent(event);
    DamEvent damEvent = DamEvent.fromEvent(event);
    Map<String, Object> properties = new HashMap<>();
    if (damEvent != null) {
        // DamEvent is not serializable, so we cannot add the complete event to the map.
        logger.trace("Event on {} is a dam event ({}).", damEvent.getAssetPath(), damEvent.getType().name());
        properties.put(DAM_EVENT_ASSET_PATH, damEvent.getAssetPath());
    }
    if (pageEvent != null) {
        logger.trace("Event is a page event.");
        properties.put(PAGE_EVENT, pageEvent);
    }
    logger.trace("Adding new job.");
    jobManager.addJob(JOB_TOPICS, properties);
}

Upvotes: 0

Isa&#237;as Sosa
Isa&#237;as Sosa

Reputation: 113

http://localhost:4502/etc/importers/bulkeditor.html

documentation

I just made a test following the instructions on the link above and it worked.

My test:

Root path = /content/myapp-path/rootpage

Query parameters = "jcr:title": Title of pages that I what to include in the search

Content mode = unchecked

Properties / Columnos = sling:resourceType and jcr:title

Custom properties / Columns = landingTags

Clicked Search... and worked.

Upvotes: 0

Related Questions