use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCREditorSessionStoreFactory method getSessionStore.
public static MCREditorSessionStore getSessionStore() {
MCRSession session = MCRSessionMgr.getCurrentSession();
MCREditorSessionStore store = (MCREditorSessionStore) (session.get(XEDITORS_CACHE_KEY));
if (store == null) {
store = new MCREditorSessionStore();
session.put(XEDITORS_CACHE_KEY, store);
}
return store;
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRPersistenceServletFilter method getURL.
private String getURL(HttpServletRequest req) {
String servletPath = req.getServletPath();
String[] pathElements = servletPath.split("/");
String type = pathElements[2];
String operation = pathElements[3];
// get session for DB access
MCRSession session = MCRServlet.getSession(req);
MCRSessionMgr.setCurrentSession(session);
session.beginTransaction();
try {
String url;
String mcrId = MCRServlet.getProperty(req, "id");
if (mcrId == null) {
String collection = getCollection(req);
url = MCRURLRetriever.getURLforCollection(operation, collection, false);
} else {
url = MCRURLRetriever.getURLforID(operation, mcrId, false);
}
LOGGER.info("Matched URL: {}", url);
return url;
} finally {
session.commitTransaction();
MCRSessionMgr.releaseCurrentSession();
}
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRWebCLIResource method start.
@GET
@MCRRestrictedAccess(MCRWebCLIPermission.class)
@Produces(MediaType.TEXT_HTML)
public Response start() {
InputStream mainGui = getClass().getResourceAsStream("/META-INF/resources/modules/webcli/index.html");
MCRSession mcrSession = MCRSessionMgr.getCurrentSession();
LOGGER.info("MyCore Session REST ID: {}", mcrSession.getID());
LOGGER.info("REST ThreadID: {}", Thread.currentThread().getName());
return Response.ok(mainGui).build();
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRAccessCacheManager method sessionEvent.
@Override
@SuppressWarnings("unchecked")
public void sessionEvent(MCRSessionEvent event) {
MCRCache<MCRPermissionHandle, Boolean> cache;
MCRSession session = event.getSession();
switch(event.getType()) {
case created:
case activated:
break;
case passivated:
accessCache.remove();
break;
case destroyed:
cache = (MCRCache<MCRPermissionHandle, Boolean>) session.get(key);
if (cache != null) {
cache.close();
}
break;
default:
break;
}
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRAccessRule method validate.
@Override
public boolean validate() {
MCRSession session = MCRSessionMgr.getCurrentSession();
String userID = session.getUserInformation().getUserID();
MCRIPAddress mcripAddress;
try {
mcripAddress = new MCRIPAddress(session.getCurrentIP());
} catch (UnknownHostException e) {
LogManager.getLogger(MCRAccessRule.class).warn("Error while checking rule.", e);
return false;
}
return checkAccess(userID, new Date(), mcripAddress);
}
Aggregations