Search in sources :

Example 1 with IRepositoryManager

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());
}
Also used : IUserContext(org.eclipse.vorto.repository.core.IUserContext) IRepositoryManager(org.eclipse.vorto.repository.core.IRepositoryManager)

Example 2 with IRepositoryManager

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);
    }
}
Also used : IRepositoryManager(org.eclipse.vorto.repository.core.IRepositoryManager) IOException(java.io.IOException) GenericApplicationException(org.eclipse.vorto.repository.web.GenericApplicationException) Namespace(org.eclipse.vorto.repository.domain.Namespace) GenericApplicationException(org.eclipse.vorto.repository.web.GenericApplicationException) IOException(java.io.IOException)

Example 3 with IRepositoryManager

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());
}
Also used : IRepositoryManager(org.eclipse.vorto.repository.core.IRepositoryManager)

Aggregations

IRepositoryManager (org.eclipse.vorto.repository.core.IRepositoryManager)3 IOException (java.io.IOException)1 IUserContext (org.eclipse.vorto.repository.core.IUserContext)1 Namespace (org.eclipse.vorto.repository.domain.Namespace)1 GenericApplicationException (org.eclipse.vorto.repository.web.GenericApplicationException)1