Search in sources :

Example 36 with MCRSession

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;
}
Also used : MCRSession(org.mycore.common.MCRSession)

Example 37 with MCRSession

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();
    }
}
Also used : MCRSession(org.mycore.common.MCRSession)

Example 38 with MCRSession

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();
}
Also used : MCRSession(org.mycore.common.MCRSession) InputStream(java.io.InputStream) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) MCRRestrictedAccess(org.mycore.frontend.jersey.filter.access.MCRRestrictedAccess)

Example 39 with MCRSession

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;
    }
}
Also used : MCRSession(org.mycore.common.MCRSession)

Example 40 with MCRSession

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);
}
Also used : MCRSession(org.mycore.common.MCRSession) UnknownHostException(java.net.UnknownHostException) Date(java.util.Date)

Aggregations

MCRSession (org.mycore.common.MCRSession)63 IOException (java.io.IOException)15 MCRUserInformation (org.mycore.common.MCRUserInformation)10 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)10 MCRPath (org.mycore.datamodel.niofs.MCRPath)6 SignedJWT (com.nimbusds.jwt.SignedJWT)5 Date (java.util.Date)5 EntityManager (javax.persistence.EntityManager)5 Path (java.nio.file.Path)4 Response (javax.ws.rs.core.Response)4 Test (org.junit.Test)4 MCRRestAPIException (org.mycore.restapi.v1.errors.MCRRestAPIException)4 SAXException (org.xml.sax.SAXException)4 UnknownHostException (java.net.UnknownHostException)3 Document (org.jdom2.Document)3 MCRAccessException (org.mycore.access.MCRAccessException)3 MCRException (org.mycore.common.MCRException)3 MCRPersistenceException (org.mycore.common.MCRPersistenceException)3 MCRDerivate (org.mycore.datamodel.metadata.MCRDerivate)3 MCRRestAPIError (org.mycore.restapi.v1.errors.MCRRestAPIError)3