use of ru.ydn.wicket.wicketorientdb.security.WicketOrientDbAuthorizationStrategy in project wicket-orientdb by OrienteerBAP.
the class OrientDbWebApplication method init.
@Override
protected void init() {
super.init();
Orient.instance().registerThreadDatabaseFactory(new DefaultODatabaseThreadLocalFactory(this));
Orient.instance().addDbLifecycleListener(new ODatabaseLifecycleListener() {
private ORecordHook createHook(Class<? extends ORecordHook> clazz, ODatabaseInternal iDatabase) {
if (!(iDatabase instanceof ODatabaseDocument))
return null;
try {
return (ORecordHook) clazz.getConstructor(ODatabaseDocument.class).newInstance(iDatabase);
} catch (Exception e) {
try {
return (ORecordHook) clazz.newInstance();
} catch (Exception e1) {
throw new IllegalStateException("Can't initialize hook " + clazz.getName(), e);
}
}
}
@Override
public void onOpen(ODatabaseInternal iDatabase) {
registerHooks(iDatabase);
}
@Override
public void onCreate(ODatabaseInternal iDatabase) {
registerHooks(iDatabase);
// Fix for "feature" appeared in OrientDB 2.1.1
// Issue: https://github.com/orientechnologies/orientdb/issues/4906
fixOrientDBRights(iDatabase);
}
public void registerHooks(ODatabaseInternal iDatabase) {
Set<ORecordHook> hooks = iDatabase.getHooks().keySet();
List<Class<? extends ORecordHook>> hooksToRegister = new ArrayList<Class<? extends ORecordHook>>(getOrientDbSettings().getORecordHooks());
for (ORecordHook hook : hooks) {
if (hooksToRegister.contains(hook.getClass()))
hooksToRegister.remove(hook.getClass());
}
for (Class<? extends ORecordHook> oRecordHookClass : hooksToRegister) {
ORecordHook hook = createHook(oRecordHookClass, iDatabase);
if (hook != null) {
if (hook instanceof IHookPosition) {
iDatabase.registerHook(hook, ((IHookPosition) hook).getPosition());
} else {
iDatabase.registerHook(hook);
}
}
}
}
@Override
public void onClose(ODatabaseInternal iDatabase) {
/*NOP*/
}
@Override
public void onDrop(ODatabaseInternal iDatabase) {
/*NOP*/
}
public PRIORITY getPriority() {
return PRIORITY.REGULAR;
}
@Override
public void onCreateClass(ODatabaseInternal iDatabase, OClass iClass) {
/*NOP*/
}
@Override
public void onDropClass(ODatabaseInternal iDatabase, OClass iClass) {
/*NOP*/
}
@Override
public void onLocalNodeConfigurationRequest(ODocument arg0) {
/*NOP*/
}
});
getRequestCycleListeners().add(newTransactionRequestCycleListener());
getRequestCycleListeners().add(new OrientDefaultExceptionsHandlingListener());
getSecuritySettings().setAuthorizationStrategy(new WicketOrientDbAuthorizationStrategy(this));
getApplicationListeners().add(new IApplicationListener() {
@Override
public void onAfterInitialized(Application application) {
Orient.instance().startup();
Orient.instance().removeShutdownHook();
}
@Override
public void onBeforeDestroyed(Application application) {
Orient.instance().shutdown();
}
});
getAjaxRequestTargetListeners().add(new FixFormEncTypeListener());
// workaround to support changing system users passwords in web interface
getOrientDbSettings().getORecordHooks().add(OUserCatchPasswordHook.class);
PropertyResolver.setLocator(this, new ODocumentPropertyLocator(new PropertyResolver.CachingPropertyLocator(new PropertyResolver.DefaultPropertyLocator())));
}
Aggregations