use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class SnapshotServiceImpl method doRestore.
private RestoreResult doRestore(final RestoreParams restoreParams) {
checkSnapshotRepository();
final String snapshotName = restoreParams.isLatest() ? determineNameOfLatestSnapshot() : restoreParams.getSnapshotName();
validateSnapshot(snapshotName);
final RepositoryId repositoryToRestore = restoreParams.getRepositoryId();
boolean restoreAll = repositoryToRestore == null;
final RepositoryIds repositoriesBeforeRestore = restoreAll ? repositoryEntryService.findRepositoryEntryIds() : null;
this.eventPublisher.publish(RepositoryEvents.restoreInitialized());
if (restoreAll) {
LOG.info("Restoring all repositories from snapshot");
} else {
LOG.info("Restoring repository {} from snapshot", repositoryToRestore);
}
final RestoreResult result = SnapshotRestoreExecutor.create().snapshotName(snapshotName).repositoriesToClose(restoreAll ? repositoriesBeforeRestore : RepositoryIds.from(repositoryToRestore)).repositoriesToRestore(restoreAll ? RepositoryIds.empty() : RepositoryIds.from(repositoryToRestore)).client(this.client).snapshotRepositoryName(SNAPSHOT_REPOSITORY_NAME).indexServiceInternal(this.indexServiceInternal).build().execute();
if (restoreAll) {
final RepositoryIds repositoriesAfterRestore = repositoryEntryService.findRepositoryEntryIds();
repositoriesBeforeRestore.stream().filter(Predicate.not(repositoriesAfterRestore::contains)).forEach(repositoryId -> {
LOG.info("Deleting repository {} indices missing in snapshot", repositoryId);
indexServiceInternal.deleteIndices(IndexNameResolver.resolveIndexNames(repositoryId).toArray(String[]::new));
});
}
LOG.info("Snapshot Restore completed");
this.eventPublisher.publish(RepositoryEvents.restored());
return result;
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class IndexServiceImpl method updateIndexSettings.
@Override
public UpdateIndexSettingsResult updateIndexSettings(final UpdateIndexSettingsParams params) {
final UpdateIndexSettingsResult.Builder result = UpdateIndexSettingsResult.create();
final UpdateIndexSettings updateIndexSettings = UpdateIndexSettings.from(params.getSettings());
for (final RepositoryId repositoryId : params.getRepositoryIds()) {
updateIndexSettings(repositoryId, updateIndexSettings, params.isRequireClosedIndex(), result);
}
return result.build();
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class DuplicateNodeCommand method attachBinaries.
private void attachBinaries(final Node node, final CreateNodeParams.Builder paramsBuilder) {
for (final AttachedBinary attachedBinary : node.getAttachedBinaries()) {
final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
paramsBuilder.attachBinary(attachedBinary.getBinaryReference(), this.binaryService.get(repositoryId, attachedBinary));
}
}
use of com.enonic.xp.repository.RepositoryId 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.RepositoryId in project xp by enonic.
the class AbstractNodeEventHandler method createNodeContext.
InternalContext createNodeContext(final Map<Object, Object> map, final InternalContext context) {
final InternalContext.Builder nodeContext = InternalContext.create(context);
final RepositoryId repositoryId = getRepositoryId(map);
if (repositoryId != null) {
nodeContext.repositoryId(repositoryId);
}
final Branch branch = getBranch(map);
if (branch != null) {
nodeContext.branch(branch);
}
return nodeContext.build();
}
Aggregations