@Override public ProcessStatus startSourceDocCreationOrUpdate( final String idNoSlash, final String projectSlug, final String iterationSlug, final Resource resource, final Set<String> extensions, final boolean copytrans) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(projectSlug, iterationSlug, true); resourceUtils.validateExtensions(extensions); // gettext, comment String name = "SourceDocCreationOrUpdate: " + projectSlug + "-" + iterationSlug + "-" + idNoSlash; AsyncTaskHandle<HDocument> handle = new AsyncTaskHandle<HDocument>(); Serializable taskId = asyncTaskHandleManager.registerTaskHandle(handle); documentServiceImpl.saveDocumentAsync( projectSlug, iterationSlug, resource, extensions, copytrans, true, handle); return getProcessStatus(taskId.toString()); // TODO Change to return 202 // Accepted, // with a url to get the // progress }
@Override public ProcessStatus startSourceDocCreation( final String idNoSlash, final String projectSlug, final String iterationSlug, final Resource resource, final Set<String> extensions, final boolean copytrans) { HProjectIteration hProjectIteration = retrieveAndCheckIteration(projectSlug, iterationSlug, true); resourceUtils.validateExtensions(extensions); // gettext, comment HDocument document = documentDAO.getByDocIdAndIteration(hProjectIteration, resource.getName()); // already existing non-obsolete document. if (document != null) { if (!document.isObsolete()) { // updates must happen through PUT on the actual resource ProcessStatus status = new ProcessStatus(); status.setStatusCode(ProcessStatusCode.Failed); status.getMessages().add("A document with name " + resource.getName() + " already exists."); return status; } } String name = "SourceDocCreation: " + projectSlug + "-" + iterationSlug + "-" + idNoSlash; AsyncTaskHandle<HDocument> handle = new AsyncTaskHandle<HDocument>(); Serializable taskId = asyncTaskHandleManager.registerTaskHandle(handle); documentServiceImpl.saveDocumentAsync( projectSlug, iterationSlug, resource, extensions, copytrans, true, handle); return getProcessStatus(taskId.toString()); // TODO Change to return 202 // Accepted, // with a url to get the // progress }