use of org.bedework.calfacade.BwGroup in project bw-calendar-engine by Bedework.
the class Users method getPrincipal.
@Override
public BwPrincipal getPrincipal(final String val) throws CalFacadeException {
if (val == null) {
return null;
}
final String href;
if (val.endsWith("/")) {
href = val.substring(0, val.length() - 1);
} else {
href = val;
}
final BwPrincipal p = mappedPrincipal(href);
if (p != null) {
return p;
}
setRoots(getSvc());
if (!href.startsWith(principalRoot)) {
return null;
}
if (href.startsWith(userPrincipalRoot)) {
final BwPrincipal u = getSvc().getPrincipal(href);
if (u != null) {
principalMap.put(href, u);
}
return u;
}
if (href.startsWith(groupPrincipalRoot)) {
final BwGroup g = getSvc().getDirectories().findGroup(href.substring(groupPrincipalRootLen));
if (g != null) {
principalMap.put(href, g);
}
return g;
}
return null;
}
use of org.bedework.calfacade.BwGroup in project bw-calendar-engine by Bedework.
the class PrincipalsAndPrefsDAO method findGroup.
public BwGroup findGroup(final String account, final boolean admin) throws CalFacadeException {
final HibSession sess = getSess();
if (admin) {
sess.createQuery(getAdminGroupQuery);
} else {
sess.createQuery(getGroupQuery);
}
sess.setString("account", account);
return (BwGroup) sess.getUnique();
}
use of org.bedework.calfacade.BwGroup in project bw-calendar-engine by Bedework.
the class PrincipalsAndPrefsDAO method getGroups.
@SuppressWarnings("unchecked")
public Collection<BwGroup> getGroups(final BwPrincipal val, final boolean admin) throws CalFacadeException {
final HibSession sess = getSess();
if (admin) {
sess.createQuery(getAdminGroupsQuery);
} else {
sess.createQuery(getGroupsQuery);
}
sess.setInt("entId", val.getId());
/* This is what I want to do but it inserts 'true' or 'false'
sess.setBool("isgroup", (val instanceof BwGroup));
*/
if (val.getKind() == WhoDefs.whoTypeGroup) {
sess.setString("isgroup", "T");
} else {
sess.setString("isgroup", "F");
}
final Set<BwGroup> gs = new TreeSet<>(sess.getList());
if (admin && (val.getKind() == WhoDefs.whoTypeUser)) {
/* Event owner for group is implicit member of group. */
sess.createQuery(getAdminGroupsByEventOwnerQuery);
sess.setString("ownerHref", val.getPrincipalRef());
gs.addAll(sess.getList());
}
return gs;
}
use of org.bedework.calfacade.BwGroup in project bw-calendar-engine by Bedework.
the class PrincipalsAndPrefsDAO method removeMember.
public void removeMember(final BwGroup group, final BwPrincipal val, final boolean admin) throws CalFacadeException {
final HibSession sess = getSess();
if (admin) {
sess.createQuery(findAdminGroupEntryQuery);
} else {
sess.createQuery(findGroupEntryQuery);
}
sess.setEntity("grp", group);
sess.setInt("mbrId", val.getId());
/* This is what I want to do but it inserts 'true' or 'false'
sess.setBool("isgroup", (val instanceof BwGroup));
*/
if (val instanceof BwGroup) {
sess.setString("isgroup", "T");
} else {
sess.setString("isgroup", "F");
}
final Object ent = sess.getUnique();
if (ent == null) {
return;
}
sess.delete(ent);
}
use of org.bedework.calfacade.BwGroup in project bw-calendar-engine by Bedework.
the class AdminGroupsDbImpl method getAllGroups.
@Override
public Collection<BwGroup> getAllGroups(final BwPrincipal val) throws CalFacadeException {
final Collection<BwGroup> groups = getGroups(val);
final Collection<BwGroup> allGroups = new TreeSet<>(groups);
for (final BwGroup adgrp : groups) {
// BwGroup grp = new BwGroup(adgrp.getAccount());
final Collection<BwGroup> gg = getAllGroups(adgrp);
if (!gg.isEmpty()) {
allGroups.addAll(gg);
}
}
return allGroups;
}
Aggregations