Expand my Community achievements bar.

SOLVED

What are the best practices for uploading JSON files for Metadata Schema form used for metadata field definition?

Avatar

Level 2

I have written a Python script that converts metadata configuration captured in a MindMap file into JSON files that can be referenced in the JSON Path data entry box found in the Settings for a metadata field. The content of the JSON file has the format below:

{
    "jcr:primaryType": "nt:unstructured",
    "fieldLabel": "Asset Type",
    "fieldType": "dropdown",
    "required": true,
    "options": [
        {
            "value": "Audio",
            "text": "Audio"
        },
        {
            "value": "Document",
            "text": "Document"
        },
        {
            "value": "Image",
            "text": "Image"
        },
        {
            "value": "Packaging",
            "text": "Packaging"
        },
        {
            "value": "Template",
            "text": "Template"
        },
        {
            "value": "Video",
            "text": "Video"
        }
    ]
}
I have added my files to my instance using Git (commited and pushed) under:
ui.content\src\main\content\jcr_root\dam\myprogram\json_metadata_field_config_files
 
If my file name is 001-Asset-Type.json what do I enter in the JSON Path data entry box?
/content/dam/myprogram/json_metadata_field_config_files/001-Asset-Type.json
 
Having done so do I then kick off a deployment pipeline to have my uploaded files be available and useable in the configuration?

If there is a better way to be doing this that is "Best Practice" please advise as I want this to be as easy for maintenance as possible while leveraging scripting to populate dropdown choices and visibility configuration to avoid lots of manual work.

Thanks in advance for your help!
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 2

I finally figured out how to complete this task. The steps once understood are fairly straight forward, I just was not able to find information in the documentation as easily as I had hoped.

In the end I used these steps:

  1. Place JSON Files in the Project:

    • Typically, JSON files used for configuration are placed in the ui.apps module of your AEM project.
    • You can create a folder structure like ui.apps/src/main/content/jcr_root/apps/<your-project>/config to store your JSON files.
  2. Reference JSON Files in Metadata Schema:

    • In AEM, navigate to Tools > Assets > Metadata Schemas.
    • Select or create a metadata schema where you want to use the JSON configuration.
    • Add a new field or edit an existing field where you want to reference the JSON file.
    • In the field configuration, set the JSON Path to the path of your JSON file within the repository. For example, if your JSON file is located at /apps/<your-project>/config/metadata-config.json, you would use this path.
  3. Example Configuration:

    • Suppose you have a JSON file named metadata-config.json with the following content:
      {
        "properties": {
          "title": "Title",
          "description": "Description"
        }
      }
    • Place this file in your project at ui.apps/src/main/content/jcr_root/apps/<your-project>/config/metadata-config.json.
    • In the metadata schema editor, configure the field to reference this JSON file by setting the JSON Path to /apps/<your-project>/config/metadata-config.json.

Further, the filter.xml file needed to be updated to include the directory created to store the JSON files such that the Jackrabbit plugin configuration would recognize it and not fail the build because they are considered to be foreign. This was done following these steps:

  1. Locate the filter.xml File:

    • The filter.xml file is typically located in the META-INF/vault directory of your AEM project.
  2. Edit the filter.xml File:

    • Open the filter.xml file in your preferred text editor or IDE.
    • Add a new <filter> element for the directory you want to include. Each <filter> element specifies a root path in the JCR repository.
  3. Example Configuration:

    • Here is an example of how to add a new directory to the filter.xml file:
      <?xml version="1.0" encoding="UTF-8"?>
      <workspaceFilter version="1.0">
          <filter root="/apps/your-project"/>
          <filter root="/etc/your-project"/>
          <!-- Add your new directory here -->
          <filter root="/content/dam/your-new-directory"/>
      </workspaceFilter>
  4. Save and Commit:

    • Save the changes to the filter.xml file.
    • Commit the changes to your version control system and push them to the server.

Once I had done these steps, my configured pipelines were able to build and then deploy the updates I made.

 

Thanks for the help @SreenivasBr , you got me thinking differently which allowed me to find what I needed. Hopefully these steps will help someone else in future.

View solution in original post

6 Replies

Avatar

Level 5

Can AEM not access the mindmap directly? If yes, then AEM can process it and store the JSON for use within author.

If authoring the options is the problem, you can consider this - https://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists/index.html

The authors can make use of this feature to author the options and this can be referred in metadata schema options.

Avatar

Level 2

We are using OOTB AEM Experience Manager Cloud and want to keep things as close to OOTB as possible. To this end we are attempting to use the functions of the existing application rather than add ACS AEM Commons.

As to the commit, push and build of the project with the JSON files added to the repository, I had the jackrabbit-filter throw an error for where I added the files to the repo. So first things first, I need to understand better how to add the JSON files to the instance so that they are accepted as part of the project. Any suggestions to point me in the right direction there are welcome!

Avatar

Correct answer by
Level 2

I finally figured out how to complete this task. The steps once understood are fairly straight forward, I just was not able to find information in the documentation as easily as I had hoped.

In the end I used these steps:

  1. Place JSON Files in the Project:

    • Typically, JSON files used for configuration are placed in the ui.apps module of your AEM project.
    • You can create a folder structure like ui.apps/src/main/content/jcr_root/apps/<your-project>/config to store your JSON files.
  2. Reference JSON Files in Metadata Schema:

    • In AEM, navigate to Tools > Assets > Metadata Schemas.
    • Select or create a metadata schema where you want to use the JSON configuration.
    • Add a new field or edit an existing field where you want to reference the JSON file.
    • In the field configuration, set the JSON Path to the path of your JSON file within the repository. For example, if your JSON file is located at /apps/<your-project>/config/metadata-config.json, you would use this path.
  3. Example Configuration:

    • Suppose you have a JSON file named metadata-config.json with the following content:
      {
        "properties": {
          "title": "Title",
          "description": "Description"
        }
      }
    • Place this file in your project at ui.apps/src/main/content/jcr_root/apps/<your-project>/config/metadata-config.json.
    • In the metadata schema editor, configure the field to reference this JSON file by setting the JSON Path to /apps/<your-project>/config/metadata-config.json.

Further, the filter.xml file needed to be updated to include the directory created to store the JSON files such that the Jackrabbit plugin configuration would recognize it and not fail the build because they are considered to be foreign. This was done following these steps:

  1. Locate the filter.xml File:

    • The filter.xml file is typically located in the META-INF/vault directory of your AEM project.
  2. Edit the filter.xml File:

    • Open the filter.xml file in your preferred text editor or IDE.
    • Add a new <filter> element for the directory you want to include. Each <filter> element specifies a root path in the JCR repository.
  3. Example Configuration:

    • Here is an example of how to add a new directory to the filter.xml file:
      <?xml version="1.0" encoding="UTF-8"?>
      <workspaceFilter version="1.0">
          <filter root="/apps/your-project"/>
          <filter root="/etc/your-project"/>
          <!-- Add your new directory here -->
          <filter root="/content/dam/your-new-directory"/>
      </workspaceFilter>
  4. Save and Commit:

    • Save the changes to the filter.xml file.
    • Commit the changes to your version control system and push them to the server.

Once I had done these steps, my configured pipelines were able to build and then deploy the updates I made.

 

Thanks for the help @SreenivasBr , you got me thinking differently which allowed me to find what I needed. Hopefully these steps will help someone else in future.

Avatar

Level 2

To use these configuration files as part of a metadata schema form's field configuration you will need to take a part of the full path to use in JSON Path field:


ui.apps/src/main/content/jcr_root/apps/<your-project>/config/metadata-config.json

 

I have highlighted above the section to use so that it is clear. In the UX it looks like this:

JayLe12_0-1736957314829.png

 

Avatar

Community Advisor

To upload and manage JSON files for metadata schema configuration in AEM, and follow best practices, here’s a streamlined process:
Best Practices for Uploading JSON Files for Metadata Configuration:

Location for JSON Files:

Use a dedicated folder under /content/dam for organizing metadata configuration files. You've already done this by adding your files under /content/dam/myprogram/json_metadata_field_config_files.

Ideally, store the files in a location like /content/dam/myprogram/json_metadata_field_config_files/ (as you have) so that they can be accessed by the JSON Path for metadata field definitions.

JSON Path:
In the JSON Path data entry box, you should reference the relative path from the root of the DAM to your file. Since the path you provided is /content/dam/myprogram/json_metadata_field_config_files/001-Asset-Type.json, you should enter that exact path:

/content/dam/myprogram/json_metadata_field_config_files/001-Asset-Type.json

Deployment and Availability:

After pushing the files via Git to the appropriate repository location (e.g., ui.content/src/main/content/jcr_root/dam/myprogram/json_metadata_field_config_files), the files need to be deployed to make them accessible in AEM.

Kick off the deployment pipeline in your AEM environment to push the files into the /content/dam/ directory. Once deployed, the metadata configuration (including the options) will be available for the metadata field definition.

Scripting and Automation:

To reduce manual work, your Python script is a great solution for generating the JSON files based on metadata configurations. If possible, set up an automated CI/CD pipeline that can handle changes in the configuration automatically, so the JSON files are updated and deployed without manual intervention.

Use a version-controlled repository (e.g., Git) for these JSON files so that they can be easily maintained and updated when changes are needed.

Maintainability and Versioning:
Keep JSON files well-organized and versioned in your Git repository. It’s a good practice to include the date or version information in the file name to easily track changes over time.
Example file naming convention: 001-Asset-Type-v1.json, 002-Category-v2.json, etc.

Error Handling and Validation:
Ensure your Python script validates the JSON file structure before generating it. This helps to avoid issues in AEM related to incorrect JSON formats or missing required fields.

Ease of Use for Authoring:
Once deployed, authors will be able to select these configurations via the Metadata Schema editor in AEM. It’s also possible to update the configurations without altering AEM directly, which provides a more efficient and scalable solution.

In Summary:

Enter Path in JSON Path Data Entry Box: /content/dam/myprogram/json_metadata_field_config_files/001-Asset-Type.json
Deploy JSON Files via Git: Commit, push, and deploy to make them accessible in AEM.
Automate: Use a script or CI/CD pipeline for easier maintenance.
Organize & Version: Store JSON files in a version-controlled manner.

Following these best practices will make it easier to maintain your metadata configurations while minimizing manual updates.

Avatar

Level 2

Hi @AmitVishwakarma,

 

Thanks for this information. I wonder if there is some documentation that shows everything that is possible to configure for the metadata schema within the JSON file. I have found one link in the Experience League that sheds a very small amount of light on the subject:

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/json-for-dropdown-field-in...

This was the information that Support supplied to me as documentation of all the possible configurations that can be done using JSON for metadata fields.
 
It is really so limited that only name/value pairs that define a metadata dropdown field choice are possible? Is there some way to configure cascading field value relationships using JSON format? If there are further options as to what can be configured using the JSON files it would make things much easier to have a consistent configuration. If I have understood correctly rules defining cascading visibility are reset when you change the JSON file to add new choices - however in my experience if your choices are in the JSON file using the JSON Path for config rather then to load the values then it is not possible to configure cascading relationships at all.
 
It would be great to have your experience shared on the topic to see if together we can't figure out more of what is possible.
 
Jay