/** * List publishing log. * * @return the list * @throws PublisherException * the publisher exception */ public List<PublishLogDefinition> listPublishingLog() throws PublisherException { List<PublishLogDefinition> publishLogDefinitions = publishCoreService.getPublishLogs(); return publishLogDefinitions; }
/** * Gets the pending published requests. * * @return the pending published requests * @throws PublisherException * the publisher exception */ private List<PublishRequestDefinition> getPendingPublishedRequests() throws PublisherException { Timestamp timestamp = publishCoreService.getLatestPublishLog(); List<PublishRequestDefinition> publishRequestDefinitions = publishCoreService.getPublishRequestsAfter(timestamp); return publishRequestDefinitions; }
@Override public PublishRequestDefinition createPublishRequest(String workspace, String path) throws PublisherException { return createPublishRequest(workspace, path, IRepositoryStructure.PATH_REGISTRY_PUBLIC); }
/** * Clear publishing log. * * @throws PublisherException * the publisher exception */ public void clearPublishingLog() throws PublisherException { List<PublishLogDefinition> publishLogDefinitions = publishCoreService.getPublishLogs(); for (PublishLogDefinition publishLogDefinition : publishLogDefinitions) { publishCoreService.removePublishLog(publishLogDefinition.getId()); } }
/** * Gets the publishing request. * * @param id * the id * @return the publishing request * @throws PublisherException * the publisher exception */ public PublishRequestDefinition getPublishingRequest(long id) throws PublisherException { PublishRequestDefinition publishRequestDefinition = publishCoreService.getPublishRequest(id); return publishRequestDefinition; }
/** * Removes the processed requests. * * @param publishRequestDefinitions * the publish request definitions * @throws PublisherException * the publisher exception */ private void removeProcessedRequests(List<PublishRequestDefinition> publishRequestDefinitions) throws PublisherException { for (PublishRequestDefinition publishRequestDefinition : publishRequestDefinitions) { publishCoreService.removePublishRequest(publishRequestDefinition.getId()); } }
/** * Publish resource. * * @param entry * the entry * @throws SynchronizationException * the synchronization exception */ private void publishResource(Map.Entry<String, String> entry) throws SynchronizationException { String sourceLocation = entry.getKey(); String targetLocation = entry.getValue(); IResource sourceResource = getRepository().getResource(sourceLocation); IResource targetResource = getRepository().getResource(targetLocation); if (targetResource.exists()) { java.util.Date lastModified = targetResource.getInformation().getModifiedAt(); if ((lastModified == null) || (currentRequestTime.getTime() > lastModified.getTime())) { targetResource.setContent(sourceResource.getContent()); } } else { getRepository().createResource(targetLocation, sourceResource.getContent()); } try { publishCoreService.createPublishLog(sourceResource.getPath(), targetResource.getPath()); } catch (PublisherException e) { throw new SynchronizationException(e); } }
/** * Request publishing. * * @param user * the user * @param workspace * the workspace * @param path * the path * @return the long * @throws PublisherException * the publisher exception */ public long requestPublishing(String user, String workspace, String path) throws PublisherException { StringBuilder workspacePath = generateWorkspacePath(user, workspace, null, null); if ("*".equals(path)) { path = ""; } PublishRequestDefinition publishRequestDefinition = publishCoreService.createPublishRequest(workspacePath.toString(), path, IRepositoryStructure.PATH_REGISTRY_PUBLIC); logger.info("Publishing request created [{}]", publishRequestDefinition.getId()); // force synchronization ? PublisherSynchronizer.forceSynchronization(); return publishRequestDefinition.getId(); }