@Override public void onBeginRequest(RequestCycle cycle) { ApplicationContext ctx = ApplicationContextProvider.getApplicationContext(); try { DocumentService repo = ctx.getBean(DocumentService.class); MDC.put(Logging.KEY_REPOSITORY_PATH, repo.getDir().getAbsolutePath()); } catch (NoSuchBeanDefinitionException e) { // Well, if the document service is not there, then we don't need to // configure the logging placeholder } }
public static File getRecommendationDir(DocumentService dc, Project p) { if (dc == null || p == null) { logger.error("Cannot create file path. DocumentService or Project object is null"); return null; } File result = new File(dc.getDir(), "/" + ProjectService.PROJECT_FOLDER + "/"); result = new File(result, Long.toString(p.getId())); result = new File(result, RECOMMENDATION_DIR_NAME); return result; }
public static List<File> getRecommendationDirs(DocumentService dc) { if (dc == null) { logger.error("Cannot create file paths. DocumentService object is null"); return null; } File dir = new File(dc.getDir(), "/" + ProjectService.PROJECT_FOLDER + "/"); if (!dir.exists()) { return null; } List<File> result = new LinkedList<>(); for (File subDir : dir.listFiles()) { if (subDir.isDirectory()) { result.add(new File(subDir, RECOMMENDATION_DIR_NAME)); } } return result; }
@Override public void onBeginRequest(RequestCycle cycle) { ApplicationContext ctx = ApplicationContextProvider.getApplicationContext(); try { DocumentService repo = ctx.getBean(DocumentService.class); MDC.put(Logging.KEY_REPOSITORY_PATH, repo.getDir().getAbsolutePath()); } catch (NoSuchBeanDefinitionException e) { // Well, if the document service is not there, then we don't need to // configure the logging placeholder } }
@Override public void run() { File file; try { // We are in a new thread. Set up thread-specific MDC MDC.put(Logging.KEY_USERNAME, username); MDC.put(Logging.KEY_PROJECT_ID, String.valueOf(model.getProject().getId())); MDC.put(Logging.KEY_REPOSITORY_PATH, documentService.getDir().toString()); state = State.RUNNING; file = exportService.exportProject(model); fileName = file.getAbsolutePath(); projectName = model.getProject().getName(); state = State.COMPLETED; } catch (ClosedByInterruptException e) { cancel(); } catch (Throwable e) { LOG.error("Unexpected error during project export", e); model.addMessage(LogMessage.error(this, "Unexpected error during project export: %s", ExceptionUtils.getRootCauseMessage(e))); state = State.FAILED; // This marks the progression as complete and causes ProgressBar#onFinished // to be called where we display the messages model.progress = 100; } }
@Override public void run() { File file; try { // We are in a new thread. Set up thread-specific MDC MDC.put(Logging.KEY_USERNAME, username); MDC.put(Logging.KEY_PROJECT_ID, String.valueOf(model.getProject().getId())); MDC.put(Logging.KEY_REPOSITORY_PATH, documentService.getDir().toString()); state = State.RUNNING; file = exportService.exportProject(model); fileName = file.getAbsolutePath(); projectName = model.getProject().getName(); state = State.COMPLETED; } catch (ClosedByInterruptException e) { cancel(); } catch (Throwable e) { LOG.error("Unexpected error during project export", e); model.addMessage(LogMessage.error(this, "Unexpected error during project export: %s", ExceptionUtils.getRootCauseMessage(e))); state = State.FAILED; // This marks the progression as complete and causes ProgressBar#onFinished // to be called where we display the messages model.progress = 100; } }