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

The PTC Community email address has changed to community-mailer@ptc.com. Learn more.

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%"

 

 

4 Comments
MikeLockwood
22-Sapphire I

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.

cfrancis
5-Regular Member

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);

 

 

PTCModerator
Emeritus
Status changed to: Acknowledged
 
yadavankur
11-Garnet

At the very least the system should gracefully handle the absence of folder. This OIR option SelectGeneratedFolderByDefaultshould have a sibling Argument SelectServerAssignedIfDefaultDoesNotExist (maybe with a better name)

 

<Value algorithm="com.ptc.core.rule.server.impl.GetServerPreGeneratedValue"/>

  <Value algorithm="com.ptc.core.rule.server.impl.GetRendererConstraint">

    <Arg>SelectGeneratedFolderByDefault</Arg>

    <Arg>SelectServerAssignedIfDefaultDoesNotExist </Arg> <!-- just create where the user launched the button from -->

  </Value> 

</Value>