Skip to content
masonwolf edited this page Dec 15, 2016 · 11 revisions

JSON formatting for imported files

The import tool expects to receive JSON files with particular formatting. They can be bundled together as .zip files or loaded individually as JSON. In order to take advantage of importing many different files simultaneously within a zip file, the file paths of files within the archive must match the relative jcr paths of the components being populated relative to a provided base path.

To help understand, suppose you want to simultaneously populate 4 discussion forums that all sit within different directories. If the last common path between each of the forums were "/content/sites/mysite/en" then you would create an archive like:

*Insert directory image here*

Within each file, the entire contents are wrapped in a single JSON obect containing exactly 2 parameters - the type of resource being uploaded and the contents.

The type is transmitted with the label: "ugcExport:contentType"

The following values for the type are supported:

  • forum
  • qnaForum
  • comments
  • calendar
  • journal
  • fileLibrary

The second field "ugcExport:content" contains the content as an object wherein an identifier label (not actually used by the importer, so feel free to name it any way you like) refers to an object representing a piece of ugc, together with any replies, translations, and attachments.

Common Properties for all Content Types

Each object must define the following fields, and they must be url-encoded. Other object types will possibly require additional fields.

 Required Fields

name description

userIdentifier

The login id of the content creator

jcr:title

The subject / title / name of the content - this field will be searchable as "subject" in the ugc search component

jcr:description

The description / body of the content - the field will be searchable as "body" in the ugc search component

social:rootCommentSystem

The path of the ugc component that the content is associated with

sling:resourceType

This value will be different depending on the type of content being imported - see content types below

 

Optional Fields

name description

added

The UNIX timestamp, in milliseconds, representing the time the content was published. If omitted, the time of import will be used.

approved

If "true" the content will be shown to all users. If omitted or false, the content will only be visible for administrators until approved in the moderation dashboard.
isDraft "true" for content that should not be visible because it's not published yet
isFlaggedHidden "true" for content that should be hidden as a result of user moderation
isClosed "true" if the comments thread is closed
publishDate If omitted, the "added" value will be used (either one provided explicitly or the import time). However, if you want to specify a future publication date, you can use this field to do so, and the content will not be viewable until that date.

cq:tags

Should be a JSON array of strings containing tags already created in /etc/tags.
mtlanguage The language code of the post. For example, English is "en". *<-- Need a link to other language codes here*
(your custom fields) Any custom fields you want to store. Just be sure they come before ugcExport:timestampFields.

ugcExport:timestampFields

An array in JSON containing the names of all fields that contain dates. At a minimum, this will normally include "added", unless using the import time. Other fields may include start and end dates of calendar events, or publish dates for content that isn't supposed to be visible until a future date, together with any custom fields that need to be treated as dates. The "ugcExport:timestampFields" should always come after the list of properties.

Child Objects:

Attachments:

Attachments are connected to content as lists of JSON objects. They are referenced with the field name "ugcExport:attachments". Each attachment object must define the following 3 fields:

filename

the name of the file, including extension

jcr:mimeType

the associated mime type

jcr:data

the binary data of the file, converted into base64

Attachments can only be imported if the underlying component permits them. The "allowUploads" field must be set to true. Attempting to import ugc content with an attachment will fail if it isn't.

Replies:

Replies are contained inside objects where each label refers to another piece of ugc content, contained in an object almost identical in schema to the parent, and including its own properties, attachments, tags, and replies. They are referenced with the field name "ugcExport:replies". However, replies do not need to specify "jcr:title".

Votes and Ratings:

lorem ipsum placeholder text

Translations:

lorem ipsum placeholder text

Implementation for Specific UGC Types

Forum:

Resource Types:

Topic - social/forum/components/hbs/topic

Reply - social/forum/components/hbs/post

Example:

{
  "ugcExport:contentType": "forum",
  "ugcExport:content": {
    "hello": {
      "added": 1458862740264,
      "sling:resourceType": "social/commons/components/comments/comment",
      "jcr:title": "hello+world",
      "approved": "true",
      "userIdentifier": "admin",
      "jcr:description": "hello",
      "ugcExport:timestampFields": ["added"],
      "ugcExport:replies": {
        "reply1": {
          "added": 1458862774304,
          "sling:resourceType": "social/commons/components/comments/comment",
          "approved": "true",
          "userIdentifier": "testuserhbsforumcgitmtinubko",
          "jcr:description": "hello%26nbsp%3Btestuserhbsforumcgitmtinubko",
          "ugcExport:timestampFields": ["added"]
        }
      }
    }
  }
}

QnA:

Resource Types:

Question - social/qna/components/hbs/topic

Answer - social/qna/components/hbs/post

Special Tags:

 name  description

forum:topic/answered

Used to mark a question as having been answered

forum:topic/chosenanswer

Used to mark the answer chosen

Extra Fields

name description

chosenAnswer_b

Set "true" on an accepted answer

Example

{
  "ugcExport:contentType": "qnaForum",
  "ugcExport:content": {
    "question": {
      "cq:tags": ["forum:topic/answered"],
      "userIdentifier": "admin",
      "jcr:title": "what+is+the+answer%3F",
      "social:isReply": "false",
      "jcr:description": "What%27s+the+answer%3F",
      "approved": "true",
      "added": 1470076876959,
      "sling:resourceType": "social%2Fqna%2Fcomponents%2Fhbs%2Ftopic",
      "ugcExport:timestampFields": ["added"],
      "ugcExport:replies": {
        "41": {
          "userIdentifier": "aparker%40geometrixx.info",
          "jcr:description": "41",
          "approved": "true",
          "added": 1470076894663,
          "sling:resourceType": "social%2Fqna%2Fcomponents%2Fhbs%2Fpost",
          "ugcExport:timestampFields": ["added"]
        },
        "42": {
          "userIdentifier": "jdoe%40geometrixx.info",
          "jcr:description": "42",
          "approved": "true",
          "chosenAnswer_b": "true",
          "cq:tags": ["forum:topic/chosenanswer"],
          "added": 1470076916286,
          "sling:resourceType": "social%2Fqna%2Fcomponents%2Fhbs%2Fpost",
          "ugcExport:timestampFields": ["added"]
        }
      }
    }
  }
}

Comments:

Resource Types:

Comment - social/commons/components/hbs/comments/comment

Reply - social/commons/components/hbs/comments/comment

Calendar:

Resource Types:

Event - social/calendar/components/hbs/event

Comment - social/commons/components/hbs/comments/comment

Extra Fields:

name description

calendar_event_start_dt

(required) The event start time expressed as a millisecond Unix timestamp

calendar_event_end_dt

(required) The event end time expressed as a millisecond Unix timestamp

isDate

"true" if the event is an all-day event, false otherwise

coverImage

This refers to an image object with filename, mimetype, and base 64 encoded binary data. The image will be displayed with the event in the main calendar listing.

location_t

A label for an event location

address_s

An address for an event location

timeZone

The timezone the event was created in, using IANA timezone labels (e.g. "America/Los_Angeles")

Note:

The calendar events get sent in as a JSON array rather than an object

Example:

{
  "ugcExport:contentType": "calendar",
  "ugcExport:content": [{
      "userIdentifier": "admin",
      "jcr:title": "hello+world",
      "timeZone": "America%2FLos_Angeles",
      "jcr:description": "this+is+an+event",
      "calendar_event_start_dt": 1469820240000,
      "approved": "true",
      "address_s": "123+my+street",
      "mtlanguage": "en",
      "added": 1469733888464,
      "isDate": "true",
      "sling:resourceType": "social/commons/components/comments/comment",
      "location_t": "my+house",
      "calendar_event_end_dt": 1469820240000,
      "ugcExport:timestampFields": ["calendar_event_start_dt","added","calendar_event_end_dt"],
      "coverimage": {
        "filename": "cover.jpg",
        "jcr:mimeType": "image/jpeg",
        "jcr:data":"/9j/4AAQSkZJRgABAQA...VUWiK1CELTT//Z"
      },
      "ugcExport:attachments": [{
          "filename": "attachment.jpg",
          "jcr:mimeType": "image/jpeg",
          "jcr:data":"/9j/4AAQSkZJRgABAAEAYABgAAD...//2Q=="
        }
      ],
      "ugcExport:replies": {
        "comment": {
          "userIdentifier": "admin",
          "jcr:description": "here+is+my+comment+on+your+event",
          "approved": "true",
          "mtlanguage": "en",
          "added": 1469733906652,
          "sling:resourceType": "social%2Fcalendar%2Fcomponents%2Fhbs%2Fevent_comment",
          "ugcExport:timestampFields": ["added"],
        }
      }
    }
  ]
}

Journal:

Resource Types:

Blog Entry - social/journal/components/hbs/entry_topic

Comment - social/journal/components/hbs/comment

Extra Fields:

name description

isScheduled

To indicate a future publication, set this field "true", set "isDraft" as "true", and provide a future value for "publishDate". The post will become visible on that date. Drafts and future entries should not have comments.

Example:

{
  "ugcExport:contentType": "journal",
  "ugcExport:content": {
    "draft_entry": {
      "userIdentifier": "admin",
      "jcr:title": "draft+entry",
      "jcr:description": "draft+1",
      "isDraft": "true",
      "approved": "true",
      "added": 1470163686531,
      "sling:resourceType": "social%2Fjournal%2Fcomponents%2Fhbs%2Fentry_topic",
      "ugcExport:timestampFields": ["added"]
    },
    "future_entry": {
      "userIdentifier": "admin",
      "jcr:title": "future+entry",
      "jcr:description": "future+entry",
      "isScheduled": "true",
      "isDraft": "true",
      "approved": "true",
      "publishDate": 1475693220000,
      "added": 1470163673385,
      "sling:resourceType": "social%2Fjournal%2Fcomponents%2Fhbs%2Fentry_topic",
      "ugcExport:timestampFields": ["publishDate","added"]
    },
    "published_entry": {
      "userIdentifier": "admin",
      "jcr:title": "entry+1",
      "jcr:description": "entry+1",
      "approved": "true",
      "added": 1470163644610,
      "sling:resourceType": "social%2Fjournal%2Fcomponents%2Fhbs%2Fentry_topic",
      "ugcExport:timestampFields": ["added"],
      "ugcExport:replies": {
        "reply1": {
          "userIdentifier": "admin",
          "jcr:title": "entry+1",
          "social:isReply": "true",
          "jcr:description": "comment",
          "approved": "true",
          "added": 1470163715395,
          "sling:resourceType": "social%2Fjournal%2Fcomponents%2Fhbs%2Fcomment",
          "ugcExport:timestampFields": ["added"]
        }
      }
    }
  }
}

File Library:

Resource Types:

Folder - social/filelibrary/components/hbs/folder

File - social/filelibrary/components/hbs/document

Note:

When doing an import, nothing stops a folder from having an attachment, and nothing stops a file from having multiple attachments. But the file library component will only show attachments on "file" items, and only the first attachment will be available for download. The root level of a file library can contain either files or folders, and the replies object of a folder can contain either folders or files. The replies object of a file should never be set.

Example:

{
  "ugcExport:contentType": "fileLibrary",
  "ugcExport:content": {
    "folder1": {
      "userIdentifier": "admin",
      "jcr:title": "folder1",
      "jcr:description": "First+folder",
      "approved": "true",
      "added": 1470168476943,
      "sling:resourceType": "social%2Ffilelibrary%2Fcomponents%2Fhbs%2Ffolder",
      "ugcExport:timestampFields": ["added"],
      "ugcExport:replies": {
        "folder2": {
          "userIdentifier": "admin",
          "jcr:title": "Folder+2",
          "jcr:description": "Folder+2",
          "approved": "true",
          "added": 1470168497345,
          "sling:resourceType": "social%2Ffilelibrary%2Fcomponents%2Fhbs%2Ffolder",
          "ugcExport:timestampFields": ["added"],
          "ugcExport:replies": {
            "smile": {
              "userIdentifier": "admin",
              "jcr:title": "smiley.jpg",
              "jcr:description": "smile+again",
              "approved": "true",
              "added": 1470168552142,
              "sling:resourceType": "social%2Ffilelibrary%2Fcomponents%2Fhbs%2Fdocument",
              "ugcExport:timestampFields": ["added"],
              "ugcExport:attachments": [{
                  "filename": "smiley.jpg",
                  "jcr:mimeType": "image/jpeg",
                  "jcr:data":"/9j/4AAQSkZJR...FWSOUs1QH//2Q=="
                }
              ]
            }
          }
        },
        "hulk": {
          "userIdentifier": "admin",
          "jcr:title": "hulk.jpg",
          "jcr:description": "hulk",
          "approved": "true",
          "added": 1470168525170,
          "sling:resourceType": "social%2Ffilelibrary%2Fcomponents%2Fhbs%2Fdocument",
          "ugcExport:timestampFields": ["added"],
          "ugcExport:attachments": [{
              "filename": "hulk.jpg",
              "jcr:mimeType": "image/jpeg",
              "jcr:data":"/9j/4AAQSkZJR...EIVUWiK1CELTT//Z"
            }
          ]
        }
      }
    },
    "smile": {
      "userIdentifier": "admin",
      "jcr:title": "smiley.jpg",
      "jcr:description": "smile",
      "approved": "true",
      "added": 1470168462683,
      "sling:resourceType": "social%2Ffilelibrary%2Fcomponents%2Fhbs%2Fdocument",
      "ugcExport:timestampFields": ["added"],
      "ugcExport:attachments": [{
          "filename": "smiley.jpg",
          "jcr:mimeType": "image/jpeg",
          "jcr:data":"/9j/4AAQSkZJR...FWSOUs1QH//2Q=="
        }
      ]
    }
  }
}

Social Graph

This is a different type of migration file altogether. Instead of defining ugc nodes, this import defines follow relationships between users. Each entry in the object for import represents a user id followed by an array of user id's which the first id is following.

Example:

{
"follower-id-1":["userid-1", "userid-2", "userid-3"],
"follower-id-2":["userid-4", "userid-5", "userid-6"]
}