/** {@inheritDoc} */ @Override public InsertNewDigitalObjectResult execute( InsertNewDigitalObjectAction action, ExecutionContext context) throws ActionException { HttpSession ses = httpSessionProvider.get(); ServerUtils.checkExpiredSession(ses); NewDigitalObject object = action.getObject(); if (object == null) throw new NullPointerException("object"); if (LOGGER.isInfoEnabled()) { LOGGER.debug("Inserting digital object: " + object.getName()); } boolean ingestSuccess; boolean reindexSuccess; String pid = null; try { ingestSuccess = CreateObjectUtils.insertAllTheStructureToFOXMLs(object); if (object.getUuid() != null && object.getUuid().contains(Constants.FEDORA_UUID_PREFIX)) { pid = object.getUuid(); } else { pid = Constants.FEDORA_UUID_PREFIX + object.getUuid(); } reindexSuccess = ServerUtils.reindex(pid); if (ingestSuccess) { String username; try { username = userDAO.getName( String.valueOf(String.valueOf(ses.getAttribute(HttpCookies.SESSION_ID_KEY))), true); } catch (DatabaseException e) { throw new ActionException(e); } try { inputQueueItemDAO.updateIngestInfo(true, action.getInputPath()); } catch (DatabaseException e) { throw new ActionException(e); } createInfoXml( username, pid.substring(Constants.FEDORA_UUID_PREFIX.length()), config.getScanInputQueuePath() + action.getInputPath()); } } catch (CreateObjectException e) { throw new ActionException(e.getMessage()); } return new InsertNewDigitalObjectResult(ingestSuccess, reindexSuccess, pid); }
/* * (non-Javadoc) * @see * com.gwtplatform.dispatch.server.actionhandler.ActionHandler#execute(com * .gwtplatform.dispatch.shared.Action, * com.gwtplatform.dispatch.server.ExecutionContext) */ @Override public GetAllRolesResult execute(final GetAllRolesAction action, final ExecutionContext context) throws ActionException { LOGGER.debug("Processing action: GetAllRolesResult"); ServerUtils.checkExpiredSession(httpSessionProvider); try { return new GetAllRolesResult(userDAO.getRoles()); } catch (DatabaseException e) { throw new ActionException(e); } }
/* * (non-Javadoc) * @see * com.gwtplatform.dispatch.server.actionhandler.ActionHandler#execute(com * .gwtplatform.dispatch.shared.Action, * com.gwtplatform.dispatch.server.ExecutionContext) */ @Override public StoreTreeStructureResult execute( final StoreTreeStructureAction action, final ExecutionContext context) throws ActionException { switch (action.getVerb()) { case PUT: if (action.getBundle() == null || action.getBundle().getInfo() == null || action.getBundle().getNodes() == null) { throw new NullPointerException("bundle"); } break; case DELETE: if (action.getId() == null) { throw new NullPointerException("id"); } break; case GET: if (action.getId() == null && action.isAll()) { throw new NullPointerException("id"); } break; default: throw new IllegalArgumentException("bad verb"); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Processing action: StoreTreeStructureResult role:" + action); } HttpSession session = httpSessionProvider.get(); ServerUtils.checkExpiredSession(session); long userId = 0; try { userId = userDAO.getUsersId(String.valueOf(session.getAttribute(HttpCookies.SESSION_ID_KEY))); } catch (DatabaseException e) { throw new ActionException(e); } try { switch (action.getVerb()) { case PUT: DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, new Locale("cs", "CZ")); action.getBundle().getInfo().setCreated(dateFormatter.format(new Date())); treeDAO.saveStructure( userId, action.getBundle().getInfo(), action.getBundle().getNodes()); return new StoreTreeStructureResult(null, null); case GET: if (action.isAll()) { // for all users return new StoreTreeStructureResult(treeDAO.getAllSavedStructures(), null); } else if (action.getId() == null) { // for all objects of particular user return new StoreTreeStructureResult(treeDAO.getAllSavedStructuresOfUser(userId), null); } else if (action.getBundle() == null) { // for user's objects of particular user return new StoreTreeStructureResult( treeDAO.getSavedStructuresOfUser(userId, action.getId()), null); } else { // tree nodes return new StoreTreeStructureResult( null, treeDAO.loadStructure(Long.parseLong(action.getId()))); } case DELETE: treeDAO.removeSavedStructure(Long.parseLong(action.getId())); break; } } catch (DatabaseException e) { LOGGER.error(e.getMessage()); e.printStackTrace(); throw new ActionException(e.getMessage(), e); } return new StoreTreeStructureResult(null, null); }