@Override public XmlWorkflowItem find(Context context, int id) throws SQLException { XmlWorkflowItem workflowItem = xmlWorkflowItemDAO.findByID(context, XmlWorkflowItem.class, id); if (workflowItem == null) { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_workflow_item", "not_found,workflowitem_id=" + id)); } } else { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_workflow_item", "workflowitem_id=" + id)); } } return workflowItem; }
/** * Generate the log header * * @param context the current Context - safe to pass in <code>null</code> * @param action string describing the action * @param extrainfo string with extra information, like parameters * @return the filled out log header */ public static String getHeader(Context context, String action, String extrainfo) { String email = "anonymous"; String contextExtraInfo; if (context != null) { EPerson e = context.getCurrentUser(); if (e != null) { email = e.getEmail(); } contextExtraInfo = context.getExtraLogInfo(); } else { contextExtraInfo = "no_context"; } StringBuilder result = new StringBuilder(); // Escape everthing but the extra context info because for some crazy reason two fields // are generated inside this entry one for the session id, and another for the ip // address. Everything else should be escaped. result.append(escapeLogField(email)).append(":").append(contextExtraInfo).append(":") .append(escapeLogField(action)).append(":").append(escapeLogField(extrainfo)); return result.toString(); }
@Override public BasicWorkflowItem find(Context context, int id) throws SQLException { BasicWorkflowItem workflowItem = workflowItemDAO.findByID(context, BasicWorkflowItem.class, id); if (workflowItem == null) { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_workflow_item", "not_found,workflow_id=" + id)); } } else { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_workflow_item", "workflow_id=" + id)); } } return workflowItem; }
@Override public DSpaceObject resolve(Context context, String identifier, String... attributes) { // We can do nothing with this, return null try { return handleService.resolveToObject(context, identifier); } catch (Exception e) { log.error(LogManager.getHeader(context, "Error while resolving handle to item", "handle: " + identifier), e); } return null; }
@Override public DSpaceObject resolve(Context context, String identifier, String... attributes) { // We can do nothing with this, return null try { return handleService.resolveToObject(context, identifier); } catch (Exception e) { log.error(LogManager.getHeader(context, "Error while resolving handle to item", "handle: " + identifier), e); } return null; }
@Override public WorkspaceItem find(Context context, int id) throws SQLException { WorkspaceItem workspaceItem = workspaceItemDAO.findByID(context, WorkspaceItem.class, id); if (workspaceItem == null) { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_workspace_item", "not_found,workspace_item_id=" + id)); } } else { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_workspace_item", "workspace_item_id=" + id)); } } return workspaceItem; }
@Override public DSpaceObject resolve(Context context, String identifier, String... attributes) { // We can do nothing with this, return null try { return handleService.resolveToObject(context, identifier); } catch (Exception e) { log.error(LogManager.getHeader(context, "Error while resolving handle to item", "handle: " + identifier), e); } // throw new IllegalStateException("Unsupported Handle Type " // + Constants.typeText[handletypeid]); return null; }
@Override public Bitstream find(Context context, UUID id) throws SQLException { Bitstream bitstream = bitstreamDAO.findByID(context, Bitstream.class, id); if (bitstream == null) { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_bitstream", "not_found,bitstream_id=" + id)); } return null; } // not null, return Bitstream if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_bitstream", "bitstream_id=" + id)); } return bitstream; }
@Override public Item find(Context context, UUID id) throws SQLException { Item item = itemDAO.findByID(context, Item.class, id); if (item == null) { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_item", "not_found,item_id=" + id)); } return null; } // not null, return item if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_item", "item_id=" + id)); } return item; }
@Override public Bundle find(Context context, UUID id) throws SQLException { // First check the cache Bundle bundle = bundleDAO.findByID(context, Bundle.class, id); if (bundle == null) { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_bundle", "not_found,bundle_id=" + id)); } return null; } else { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader(context, "find_bundle", "bundle_id=" + id)); } return bundle; } }
/** * Forwards control of the request to the display JSP passed in. * * @param request * current servlet request object * @param response * current servlet response object * @param jsp * the JSP page to display, relative to the webapps directory */ public static void showJSP(HttpServletRequest request, HttpServletResponse response, String jsp) throws ServletException, IOException { if (log.isDebugEnabled()) { log.debug(LogManager.getHeader((Context) request .getAttribute("dspace.context"), "view_jsp", jsp)); } // For the moment, a simple forward request.getRequestDispatcher(jsp).forward(request, response); }
protected void doDSGet(Context context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { // A GET displays the edit profile form. We assume the authentication // filter means we have a user. log.info(LogManager.getHeader(context, "view_profile", "")); request.setAttribute("eperson", context.getCurrentUser()); JSPManager.showJSP(request, response, "/register/edit-profile.jsp"); }
@Override public void delete(Context context, MetadataValue metadataValue) throws SQLException { log.info(LogManager.getHeader(context, "delete_metadata_value", " metadata_value_id=" + metadataValue.getID())); metadataValueDAO.delete(context, metadataValue); }
@Override public void update(Context context, MetadataValue metadataValue) throws SQLException { metadataValueDAO.save(context, metadataValue); log.info(LogManager.getHeader(context, "update_metadatavalue", "metadata_value_id=" + metadataValue.getID())); }
protected void doDSGet(Context context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, AuthorizeException { log.info(LogManager.getHeader(context, "logout", "")); Authenticate.loggedOut(context, request); // Display logged out message JSPManager.showJSP(request, response, "/login/logged-out.jsp"); } }
private Authentication createAuthenticationToken(final String password, final Context context, final List<SimpleGrantedAuthority> grantedAuthorities) { EPerson ePerson = context.getCurrentUser(); if (ePerson != null && StringUtils.isNotBlank(ePerson.getEmail())) { return new UsernamePasswordAuthenticationToken(ePerson.getEmail(), password, grantedAuthorities); } else { log.info( LogManager.getHeader(context, "failed_login", "No eperson with an non-blank e-mail address found")); throw new BadCredentialsException("Login failed"); } }
@Override public void reserve(Context context, DSpaceObject dso, String identifier) { try { handleService.createHandle(context, dso, identifier); } catch (Exception e) { log.error( LogManager.getHeader(context, "Error while attempting to create handle", "Item id: " + dso.getID()), e); throw new RuntimeException("Error while attempting to create identifier for Item id: " + dso.getID()); } }
public Set<String> getISSNs(Context context, Item item) { Set<String> issns = new LinkedHashSet<String>(); if (configuration.getIssnItemExtractors() == null) { log.warn(LogManager.getHeader(context, "searchRelatedJournals", "no issnItemExtractors defined")); return null; } for (ISSNItemExtractor extractor : configuration.getIssnItemExtractors()) { List<String> eIssns = extractor.getISSNs(context, item); if (eIssns != null) { for (String eIssn : eIssns) { issns.add(eIssn.trim()); } } } return issns; }
@Override public void reserve(Context context, DSpaceObject dso, String identifier) { try { handleService.createHandle(context, dso, identifier); } catch (Exception e) { log.error( LogManager.getHeader(context, "Error while attempting to create handle", "Item id: " + dso.getID()), e); throw new RuntimeException("Error while attempting to create identifier for Item id: " + dso.getID()); } }
@Override public void reserve(Context context, DSpaceObject dso, String identifier) { try { handleService.createHandle(context, dso, identifier); } catch (Exception e) { log.error( LogManager.getHeader(context, "Error while attempting to create handle", "Item id: " + dso.getID()), e); throw new RuntimeException("Error while attempting to create identifier for Item id: " + dso.getID()); } }