use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRLayoutUtilities method itemAccess.
/**
* Verifies a single item on access according to $permission and for a given
* user
*
* @param permission an ACL permission
* @param item element to check
* @param access
* initial value
* @param userID a user id
*/
public static boolean itemAccess(String permission, Element item, boolean access, String userID) {
MCRAccessInterface am = MCRAccessManager.getAccessImpl();
String objID = getWebpageACLID(item);
if (am.hasRule(objID, permission)) {
access = am.checkPermission(objID, permission, userID);
}
return access;
}
use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRAccessCommands method permissionDeleteAllForID.
/**
* delete all permissions for a given id
*
* @param id
* String the id of the object the rule is assigned to
*/
@MCRCommand(syntax = "delete all permissions for id {1}", help = "The command delete all access rules for a given id", order = 120)
public static void permissionDeleteAllForID(String id) {
MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
AI.removeAllRules(id);
}
use of org.mycore.access.MCRAccessInterface in project mycore by MyCoRe-Org.
the class MCRSwordUtil method createDerivate.
public static MCRDerivate createDerivate(String documentID) throws MCRPersistenceException, IOException, MCRAccessException {
final String projectId = MCRObjectID.getInstance(documentID).getProjectId();
MCRObjectID oid = MCRObjectID.getNextFreeId(projectId, "derivate");
final String derivateID = oid.toString();
MCRDerivate derivate = new MCRDerivate();
derivate.setId(oid);
derivate.setLabel("data object from " + documentID);
String schema = CONFIG.getString("MCR.Metadata.Config.derivate", "datamodel-derivate.xml").replaceAll(".xml", ".xsd");
derivate.setSchema(schema);
MCRMetaLinkID linkId = new MCRMetaLinkID();
linkId.setSubTag("linkmeta");
linkId.setReference(documentID, null, null);
derivate.getDerivate().setLinkMeta(linkId);
MCRMetaIFS ifs = new MCRMetaIFS();
ifs.setSubTag("internal");
ifs.setSourcePath(null);
derivate.getDerivate().setInternals(ifs);
LOGGER.debug("Creating new derivate with ID {}", derivateID);
MCRMetadataManager.create(derivate);
if (CONFIG.getBoolean("MCR.Access.AddDerivateDefaultRule", true)) {
MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
Collection<String> configuredPermissions = AI.getAccessPermissionsFromConfiguration();
for (String permission : configuredPermissions) {
MCRAccessManager.addRule(derivateID, permission, MCRAccessManager.getTrueRule(), "default derivate rule");
}
}
final MCRPath rootDir = MCRPath.getPath(derivateID, "/");
if (Files.notExists(rootDir)) {
rootDir.getFileSystem().createRoot(derivateID);
}
return derivate;
}
Aggregations