cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Allow OIR to auto-create folder locations if they don't exist rather than failing

Allow OIR to auto-create folder locations if they don't exist rather than failing

Common issue I've seen many times, someone deletes or renames a folder in their product and the OIR can no longer send objects to that folder. Rather than fail, a process should be started to add the folder.

 

Most people get around this by not allowing users to create/edit folders, but that's not very user friendly.

It would also allow a change in OIR to re-direct all new items to a new folder location without having to go add it to all the products. I can't see a good reason why anyone would want an OIR to purposely fail if given a reasonable folder location.

 

IF NOT EXIST "%folder%" md "%folder%"

 

 

3 Comments
Alexandrite

Completely agree.  One more use case: Create new Product or Library from existing template that does not include the folder required by an Org-level OIR.  Fails creation only in that context.  Would be great if the system created the folder.

Participant

This can be done by creating your own FolderPathAttributeAlgorithm and referencing that in the OIR shown in red below.

<AttrValue
    id="folder.id"
    algorithm="ext.oir.FolderPathAttributeAlgorithm"
    ignore="false"
    force="false"
    final="false">
    <Arg>/Default/aNewFolder</Arg>
  </AttrValue>

In your FolderPathAttributeAlgorithm.java try the original method and catch any error. If you catch an error then you know the folder does not exist. At this point you can parse the folder name to look for each folder in the path one by one by using:
FolderHelper.service.getFolder( pathString, container);

to see if the folder exists. If it does not you can create the path one folder at a time:

returnFolder = FolderHelper.service.createSubFolder( pathString, null, container);

 

 

Community Manager
Status changed to: Acknowledged