use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.
the class AbstractScheduler method getSvci.
/**
* Get an svci object as a different user.
*
* @param principalHref
* @return CalSvcI
* @throws CalFacadeException
*/
protected CalSvcI getSvci(final String principalHref) throws CalFacadeException {
CalSvcI svci;
/* account is what we authenticated with.
* user, if non-null, is the user calendar we want to access.
*/
CalSvcIPars runAsPars = CalSvcIPars.getServicePars("scheduler", // principal.getAccount(),
principalHref, // publicAdmin
false, // allow SuperUser
"/principals/users/root".equals(principalHref));
svci = new CalSvcFactoryDefault().getSvc(runAsPars);
setSvc(svci);
svci.open();
svci.beginTransaction();
return svci;
}
use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.
the class CalSvc method init.
private void init(final CalSvcIPars parsParam, final boolean creating) throws CalFacadeException {
pars = (CalSvcIPars) parsParam.clone();
this.creating = creating;
debug = getLogger().isDebugEnabled();
final long start = System.currentTimeMillis();
fixUsers();
try {
if (configs == null) {
// Try again - failed at static init?
configs = new CalSvcFactoryDefault().getSystemConfig();
}
open();
beginTransaction();
if (userGroups != null) {
userGroups.init(getGroupsCallBack(), configs);
}
if (adminGroups != null) {
adminGroups.init(getGroupsCallBack(), configs);
}
final SystemProperties sp = getSystemProperties();
if (tzserverUri == null) {
tzserverUri = sp.getTzServeruri();
if (tzserverUri == null) {
throw new CalFacadeException("No timezones server URI defined");
}
Timezones.initTimezones(tzserverUri);
Timezones.setSystemDefaultTzid(sp.getTzid());
}
/* Some checks on parameter validity
*/
// BwUser =
tzstore = new TimeZonesStoreImpl(this);
/* Nominate our timezone registry */
System.setProperty("net.fortuna.ical4j.timezone.registry", "org.bedework.icalendar.TimeZoneRegistryFactoryImpl");
if (!creating) {
final String tzid = getPrefsHandler().get().getDefaultTzid();
if (tzid != null) {
Timezones.setThreadDefaultTzid(tzid);
}
// if (pars.getCaldav() && !pars.isGuest()) {
if (!pars.isGuest()) {
/* Ensure scheduling resources exist */
// getCal().getSpecialCalendar(getPrincipal(), BwCalendar.calTypeInbox,
// true, PrivilegeDefs.privAny);
// getCal().getSpecialCalendar(getPrincipal(), BwCalendar.calTypeOutbox,
// true, PrivilegeDefs.privAny);
}
}
if ((pars.getPublicAdmin() || pars.getAllowSuperUser()) && (pars.getAuthUser() != null)) {
((SvciPrincipalInfo) principalInfo).setSuperUser(getSysparsHandler().isRootUser(principalInfo.getAuthPrincipal()));
}
postNotification(SysEvent.makePrincipalEvent(SysEvent.SysCode.USER_SVCINIT, getPrincipal(), System.currentTimeMillis() - start));
} catch (final CalFacadeException cfe) {
rollbackTransaction();
cfe.printStackTrace();
throw cfe;
} catch (final Throwable t) {
rollbackTransaction();
t.printStackTrace();
throw new CalFacadeException(t);
} finally {
try {
endTransaction();
} catch (final Throwable ignored) {
}
try {
close();
} catch (final Throwable ignored) {
}
}
}
use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.
the class RestoreGlobals method init.
/**
* @throws Throwable
*/
public void init() throws Throwable {
Configurations conf = new CalSvcFactoryDefault().getSystemConfig();
basicProps = conf.getBasicSystemProperties();
syspars = conf.getSystemProperties();
}
use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.
the class BwDumpRestore method getSvci.
/**
* Get an svci object and return it. Also embed it in this object.
*
* @return svci object
* @throws CalFacadeException on fatal error
*/
private CalSvcI getSvci(final String owner, final boolean publick) throws CalFacadeException {
if ((svci != null) && svci.isOpen()) {
return svci;
}
boolean publicAdmin = false;
if ((curSvciOwner == null) || !curSvciOwner.equals(owner)) {
svci = null;
curSvciOwner = owner;
publicAdmin = publick;
}
if (svci == null) {
final CalSvcIPars pars = CalSvcIPars.getIndexerPars(curSvciOwner, publicAdmin);
// CalSvcIPars pars = CalSvcIPars.getServicePars(curSvciOwner,
// publicAdmin, // publicAdmin
// true); // Allow super user
svci = new CalSvcFactoryDefault().getSvc(pars);
}
svci.open();
svci.beginTransaction();
return svci;
}
use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getSvci.
private CalSvcI getSvci(final String account, final String runAs, final boolean service, final boolean publicAdmin, final String clientId, final boolean allowCreateEprops) throws WebdavException {
try {
/* account is what we authenticated with.
* user, if non-null, is the user calendar we want to access.
*/
final boolean possibleSuperUser = // allow SuperUser
"root".equals(account) || "admin".equals(account);
String runAsUser = null;
String clientIdent = null;
if (possibleSuperUser) {
runAsUser = runAs;
clientIdent = clientId;
}
final CalSvcIPars pars = CalSvcIPars.getCaldavPars("bwcaldav", account, runAsUser, clientIdent, // allow SuperUser
possibleSuperUser, service, publicAdmin, allowCreateEprops);
svci = new CalSvcFactoryDefault().getSvc(pars);
svci.open();
svci.beginTransaction();
trans = new IcalTranslator(svci.getIcalCallback());
} catch (Throwable t) {
throw new WebdavException(t);
}
return svci;
}
Aggregations