use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRCommandLineInterface method processCommand.
/**
* Processes a command entered by searching a matching command in the list
* of known commands and executing its method.
*
* @param command
* The command string to be processed
*/
protected static void processCommand(String command) {
MCRSession session = MCRSessionMgr.getSession(sessionId.get());
MCRSessionMgr.setCurrentSession(session);
try {
session.beginTransaction();
List<String> commandsReturned = knownCommands.invokeCommand(expandCommand(command));
session.commitTransaction();
addCommandsToQueue(commandsReturned);
} catch (Exception ex) {
MCRCLIExceptionHandler.handleException(ex);
rollbackTransaction(session);
if (SKIP_FAILED_COMMAND) {
saveFailedCommand(command);
} else {
saveQueue(command);
if (!interactiveMode) {
System.exit(1);
}
commandQueue.clear();
}
} finally {
MCRSessionMgr.releaseCurrentSession();
}
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRCommandLineInterface method initSession.
private static void initSession() {
MCRSession session = MCRSessionMgr.getCurrentSession();
session.setCurrentIP("127.0.0.1");
session.setUserInformation(MCRSystemUserInformation.getSuperUserInstance());
MCRSessionMgr.setCurrentSession(session);
sessionId.set(session.getID());
MCRSessionMgr.releaseCurrentSession();
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRUploadHandlerManager method getHandler.
public static MCRUploadHandler getHandler(String uploadID) {
long yesterday = System.currentTimeMillis() - 86400000;
MCRUploadHandlerCacheEntry entry = HANDLERS.getIfUpToDate(uploadID, yesterday);
if (entry == null)
throw new MCRUsageException("Upload session " + uploadID + " timed out");
String sessionID = entry.getSessionID();
if (!sessionID.equals(MCRSessionMgr.getCurrentSessionID())) {
MCRSession session = MCRSessionMgr.getSession(sessionID);
if (session != null)
MCRSessionMgr.setCurrentSession(session);
}
return entry.getUploadHandler();
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRSessionHookFilter method filter.
@Override
public void filter(ContainerRequestContext request) throws IOException {
MCRSession session = MCRServlet.getSession(httpRequest);
MCRSessionMgr.setCurrentSession(session);
LOGGER.info(MessageFormat.format("{0} ip={1} mcr={2} user={3}", request.getUriInfo().getPath(), MCRFrontendUtil.getRemoteAddr(httpRequest), session.getID(), session.getUserInformation().getUserID()));
MCRFrontendUtil.configureSession(session, httpRequest, httpResponse);
}
use of org.mycore.common.MCRSession in project mycore by MyCoRe-Org.
the class MCRFrontendUtil method getBaseURL.
/**
* returns the base URL of the mycore system
*/
public static String getBaseURL() {
if (MCRSessionMgr.hasCurrentSession()) {
MCRSession session = MCRSessionMgr.getCurrentSession();
Object value = session.get(BASE_URL_ATTRIBUTE);
if (value != null) {
LOGGER.debug("Returning BaseURL {} from user session.", value);
return value.toString();
}
}
return BASE_URL;
}
Aggregations