use of org.eclipse.vorto.repository.core.IRepositoryManager in project vorto by eclipse.
the class ModelRepositoryEventListener method createWorkspace.
private void createWorkspace(AppEvent event) {
IUserContext userContext = event.getUserContext();
IRepositoryManager repoMgr = repositoryFactory.getRepositoryManager(userContext.getWorkspaceId(), userContext.getAuthentication());
repoMgr.createWorkspace(userContext.getWorkspaceId());
}
use of org.eclipse.vorto.repository.core.IRepositoryManager in project vorto by eclipse.
the class BackupRestoreService method restoreRepository.
@Override
public Collection<Namespace> restoreRepository(byte[] backupFile, Predicate<Namespace> namespaceFilter) {
Preconditions.checkNotNull(backupFile, "Backup file must not be null");
try {
Collection<Namespace> namespacesRestored = Lists.newArrayList();
Map<String, byte[]> backups = getBackups(backupFile);
backups.forEach((namespaceName, backup) -> {
LOGGER.info(String.format("Restoring backup for [%s]", namespaceName));
Namespace namespace = namespaceRepository.findByName(namespaceName);
if (null != namespace && namespaceFilter.test(namespace)) {
try {
String workspaceId = namespace.getWorkspaceId();
IRepositoryManager repoMgr = modelRepositoryFactory.getRepositoryManager(workspaceId, authSupplier.get());
if (!repoMgr.exists(workspaceId)) {
repoMgr.createWorkspace(workspaceId);
} else {
repoMgr.removeWorkspace(workspaceId);
repoMgr.createWorkspace(workspaceId);
}
repoMgr.restore(backup);
this.modelRepositoryFactory.getPolicyManager(workspaceId, SecurityContextHolder.getContext().getAuthentication()).restorePolicyEntries();
namespacesRestored.add(namespace);
} catch (Exception e) {
LOGGER.error(String.format("Error while restoring [%s]", namespaceName), e);
}
} else {
LOGGER.info(String.format("Skipping restoration of [%s] either because the namespace could not be found, or was filtered out.", namespaceName));
}
});
if (!namespacesRestored.isEmpty()) {
indexingService.reindexAllModels();
}
return namespacesRestored;
} catch (IOException e) {
throw new GenericApplicationException("Problem while reading zip file during restore", e);
}
}
use of org.eclipse.vorto.repository.core.IRepositoryManager in project vorto by eclipse.
the class NamespaceService method deleteModeshapeWorkspace.
private void deleteModeshapeWorkspace(Namespace currentNamespace) {
IRepositoryManager repoMgr = repositoryFactory.getRepositoryManager(currentNamespace.getWorkspaceId(), SecurityContextHolder.getContext().getAuthentication());
repoMgr.removeWorkspace(currentNamespace.getWorkspaceId());
}
Aggregations