use of org.bedework.calfacade.base.BwShareableContainedDbentity in project bw-calendar-engine by Bedework.
the class AccessUtil method getAclChars.
/* ====================================================================
* Private methods
* ==================================================================== */
/* If the entity is not a collection we merge the access in with the container
* access then return the merged aces. We do this because we call getPathInfo
* with a collection entity. That method will recurse up to the root.
*
* For a calendar we just use the access for the calendar.
*
* The calendar/container access might be cached in the pathInfoTable.
*/
private char[] getAclChars(final BwShareableDbentity<?> ent) throws CalFacadeException {
if ((!(ent instanceof BwEventProperty)) && (ent instanceof BwShareableContainedDbentity)) {
BwCalendar container;
if (ent instanceof BwCalendar) {
container = (BwCalendar) ent;
} else {
container = getParent((BwShareableContainedDbentity<?>) ent);
}
if (container == null) {
return null;
}
final String path = container.getPath();
CalendarWrapper wcol = (CalendarWrapper) container;
String aclStr;
char[] aclChars = null;
/* Get access for the parent first if we have one */
BwCalendar parent = getParent(wcol);
if (parent != null) {
aclStr = new String(merged(getAclChars(parent), parent.getPath(), wcol.getAccess()));
} else if (wcol.getAccess() != null) {
aclStr = wcol.getAccess();
} else {
// At root
throw new CalFacadeException("Collections must have default access set at root");
}
if (aclStr != null) {
aclChars = aclStr.toCharArray();
}
if (ent instanceof BwCalendar) {
return aclChars;
}
return merged(aclChars, path, ent.getAccess());
}
/* This is a way of making other objects sort of shareable.
* The objects are locations, sponsors and categories.
* (also calsuite)
*
* We store the default access in the owner principal and manipulate that to give
* us some degree of sharing.
*
* In effect, the owner becomes the container for the object.
*/
String aclString = null;
String entAccess = ent.getAccess();
BwPrincipal owner = (BwPrincipal) cb.getPrincipal(ent.getOwnerHref());
if (ent instanceof BwCategory) {
aclString = owner.getCategoryAccess();
} else if (ent instanceof BwLocation) {
aclString = owner.getLocationAccess();
} else if (ent instanceof BwContact) {
aclString = owner.getContactAccess();
}
if (aclString == null) {
if (entAccess == null) {
if (ent.getPublick()) {
return Access.getDefaultPublicAccess().toCharArray();
}
return Access.getDefaultPersonalAccess().toCharArray();
}
return entAccess.toCharArray();
}
if (entAccess == null) {
return aclString.toCharArray();
}
try {
Acl acl = Acl.decode(entAccess.toCharArray());
acl = acl.merge(aclString.toCharArray(), "/owner");
return acl.getEncoded();
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
use of org.bedework.calfacade.base.BwShareableContainedDbentity in project bw-calendar-engine by Bedework.
the class ContainerPathRule method field.
public void field(String name) throws Throwable {
if (name.equals("path")) {
/* If the top is an override skip this - container is set already. */
BwEventAnnotation ann = null;
BwEvent e = null;
if (top() instanceof EventInfo) {
EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
e = ei.getEvent();
if (e instanceof BwEventProxy) {
ann = ((BwEventProxy) e).getRef();
if (ann.getOverride()) {
// Overrides have everything set already
return;
}
}
}
BwCalendar cal = globals.rintf.getCalendar(stringFld());
if (cal == null) {
error("No calendar for path " + stringFld());
}
if (top() instanceof BwShareableContainedDbentity) {
BwShareableContainedDbentity scde = (BwShareableContainedDbentity) top();
scde.setColPath(stringFld());
} else if (top() instanceof EventInfo) {
if (ann != null) {
/* Could be target or master */
String match = getDigester().getMatch();
if (match.contains("/target/")) {
ann.getTarget().setColPath(stringFld());
} else if (match.contains("/master/")) {
ann.getMaster().setColPath(stringFld());
} else {
ann.setColPath(stringFld());
}
}
e.setColPath(stringFld());
} else {
handleException(new Exception("Unexpected stack top "));
}
} else {
unknownTag(name);
}
}
Aggregations