Skip to Content
0
Oct 02 at 10:11 PM

Unable to create/save security permission on a folder using the Java SDK.

295 Views Last edit Oct 02 at 10:15 PM 4 rev

We are creating universes, (site) folders, etc., for SAP 4.3 Business Object application using the java sdk. The folder is getting created successfully in the CMC console, but for some reason the permission are not getting assigned correctly/saved for that folder. This is the code generating the folders and attempting to create the permissions on it. I believe this code works for 3.1 version of the BO jars, and we just upgraded the jars to 4.3. I am not sure if we are missing anything. I tried to follow the documentation from the SAP SDK Developer guide, but have not had any luck yet:

https://help.sap.com/viewer/0225aa3e7b4b4b17b2d4a882e6f2de96/4.3.1/en-US/45a879976e041014910aba7db0e91070.html

For reference, this is the code where we look up the existing folder (that we create initially), and then pass it to the addAccessLevel method below which should assign the security on the folder.

// IFolder siteFolder = getBoxiConnection().lookupFolder(siteFolderName); // method to lookup the folder
// The IInfoObject item passed in the method below is this IFolder siteFolder which has been created successfully

public void addAccessLevel(IInfoObject item, int principalId, int accessLevelId) throws SDKException {

ISecurityInfo2 secInfo = item.getSecurityInfo2();
IExplicitPrincipals principals = secInfo.getExplicitPrincipals();
IExplicitPrincipal viewerPrincipal = principals.add(principalId); // principalId is the viewer group Id
IExplicitRoles iexplicitRoles = viewerPrincipal.getRoles();
viewerPrincipal.getRoles().add(accessLevelId); // accessLevelId is the viewer access level id
item.save();
}

It seems like this save is not actually saving the above security/permission on the item/folder, as the permissions in the CMC console on the folder don't seem to have changed to include this new one. Is there something extra that needs to be done to get it to save?