use of com.enonic.xp.repository.Repository in project xp by enonic.
the class RepositoriesJson method create.
public static RepositoriesJson create(final Repositories repositories) {
final RepositoriesJson json = new RepositoriesJson();
json.repositories = new ArrayList<>();
for (final Repository repo : repositories) {
json.repositories.add(RepositoryJson.create(repo));
}
return json;
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class NodeServiceImpl method verifyRepositoryExists.
private void verifyRepositoryExists() {
NodeHelper.runAsAdmin(() -> {
final RepositoryId repoId = ContextAccessor.current().getRepositoryId();
final Repository repository = this.repositoryService.get(repoId);
if (repository == null) {
throw new RepositoryNotFoundException(repoId);
}
});
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class RepositoryEntryServiceImpl method updateRepositoryNode.
private Repository updateRepositoryNode(final UpdateNodeParams updateNodeParams) {
final Node updatedNode = createContext().callWith(() -> UpdateNodeCommand.create().params(updateNodeParams).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).binaryService(this.binaryService).build().execute());
eventPublisher.publish(NodeEvents.updated(updatedNode));
refresh();
Repository repository = RepositoryNodeTranslator.toRepository(updatedNode);
eventPublisher.publish(RepositoryEvents.updated(repository.getId()));
return repository;
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class RepositoryServiceImpl method doCreateRepo.
private Repository doCreateRepo(final CreateRepositoryParams params) {
final RepositoryId repositoryId = params.getRepositoryId();
final boolean repoAlreadyInitialized = this.nodeRepositoryService.isInitialized(repositoryId);
if (repoAlreadyInitialized) {
throw new RepositoryAlreadyExistException(repositoryId);
}
this.nodeRepositoryService.create(params);
createRootNode(params);
final Repository repository = createRepositoryObject(params);
repositoryEntryService.createRepositoryEntry(repository);
return repository;
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class VersionTableVacuumCommand method doProcessRepository.
private void doProcessRepository(final Repository repository) {
int counter = 0;
NodeVersionId lastVersionId = null;
NodeVersionQuery query = createQuery(lastVersionId);
NodeVersionQueryResult versionsResult = nodeService.findVersions(query);
long hits = versionsResult.getHits();
final long totalHits = versionsResult.getTotalHits();
if (listener != null) {
listener.stepBegin(repository.getId().toString(), totalHits);
}
while (hits > 0) {
final List<NodeVersionId> versionsToDelete = new ArrayList<>();
final Set<BlobKey> nodeBlobToCheckSet = new HashSet<>();
final Set<BlobKey> binaryBlobToCheckSet = new HashSet<>();
final NodeVersionsMetadata versions = versionsResult.getNodeVersionsMetadata();
for (NodeVersionMetadata version : versions) {
final boolean toDelete = processVersion(repository, version);
if (toDelete) {
result.deleted();
versionsToDelete.add(version.getNodeVersionId());
nodeBlobToCheckSet.add(version.getNodeVersionKey().getNodeBlobKey());
binaryBlobToCheckSet.addAll(version.getBinaryBlobKeys().getSet());
} else {
result.inUse();
}
lastVersionId = version.getNodeVersionId();
counter++;
}
versionService.delete(versionsToDelete, InternalContext.from(ContextAccessor.current()));
nodeBlobToCheckSet.stream().filter(blobKey -> !isBlobKeyUsed(blobKey, VersionIndexPath.NODE_BLOB_KEY)).forEach(blobKey -> removeNodeBlobRecord(repository.getId(), NodeConstants.NODE_SEGMENT_LEVEL, blobKey));
binaryBlobToCheckSet.stream().filter(blobKey -> !isBlobKeyUsed(blobKey, VersionIndexPath.BINARY_BLOB_KEYS)).forEach(blobKey -> removeNodeBlobRecord(repository.getId(), NodeConstants.BINARY_SEGMENT_LEVEL, blobKey));
query = createQuery(lastVersionId);
versionsResult = nodeService.findVersions(query);
hits = versionsResult.getHits();
}
if (listener != null) {
listener.processed(counter);
}
}
Aggregations