use of com.enonic.xp.repository.Repository in project xp by enonic.
the class ProjectServiceImplTest method create_with_data.
@Test
void create_with_data() {
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final String displayName = "test display name";
final String description = "test description";
final PropertyTree data = new PropertyTree();
final PropertySet projectData = data.addSet(ProjectConstants.PROJECT_DATA_SET_NAME);
projectData.setString(ProjectConstants.PROJECT_DISPLAY_NAME_PROPERTY, displayName);
projectData.setString(ProjectConstants.PROJECT_DESCRIPTION_PROPERTY, description);
adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), displayName, description));
adminContext().runWith(() -> {
final Repository projectRepo = repositoryService.get(projectRepoId);
assertEquals(data, projectRepo.getData());
});
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class ProjectServiceImplTest method create_in_non_master_node.
@Test
void create_in_non_master_node() {
IndexServiceInternal indexServiceInternalMock = Mockito.mock(IndexServiceInternal.class);
when(indexServiceInternalMock.waitForYellowStatus()).thenReturn(true);
indexService.setIndexServiceInternal(indexServiceInternalMock);
final RepositoryId projectRepoId = RepositoryId.from("com.enonic.cms.test-project");
final Project project = adminContext().callWith(() -> doCreateProject(ProjectName.from(projectRepoId), null, true, null));
assertNotNull(project);
assertEquals("test-project", project.getName().toString());
final NodeBranchEntry nodeBranchEntry = this.branchService.get(Node.ROOT_UUID, InternalContext.create(adminContext()).repositoryId(projectRepoId).build());
assertNotNull(nodeBranchEntry);
adminContext().runWith(() -> {
final Repository pro = repositoryService.get(projectRepoId);
assertNotNull(pro);
});
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class ImportRunnableTask method initializeStoredRepositories.
private void initializeStoredRepositories() {
this.repositoryService.invalidateAll();
for (Repository repository : repositoryService.list()) {
if (!this.nodeRepositoryService.isInitialized(repository.getId())) {
final CreateRepositoryParams createRepositoryParams = CreateRepositoryParams.create().repositoryId(repository.getId()).repositorySettings(repository.getSettings()).data(repository.getData()).build();
this.nodeRepositoryService.create(createRepositoryParams);
}
}
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class LoadRunnableTask method doLoadFromExport.
private SystemLoadResultJson doLoadFromExport(final Path rootDir) {
final SystemLoadResult.Builder builder = SystemLoadResult.create();
final Repositories repositories = repositoryService.list();
final long branchesCount = repositories.stream().flatMap(repository -> repository.getBranches().stream()).count();
loadDumpListener.totalBranches(branchesCount);
builder.add(importSystemRepo(rootDir));
this.repositoryService.invalidateAll();
for (Repository repository : repositories) {
initializeRepo(repository);
builder.add(importRepoBranches(rootDir, repository));
}
return SystemLoadResultJson.from(builder.build());
}
use of com.enonic.xp.repository.Repository in project xp by enonic.
the class DumpServiceImplTest method dumpAndLoadWithAttachments.
@Test
public void dumpAndLoadWithAttachments() throws Exception {
NodeHelper.runAsAdmin(() -> {
final Repository newRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo"), AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build(), ChildOrder.manualOrder()));
final PropertyTree data = new PropertyTree();
data.addBinaryReference("attachmentName", BinaryReference.from("image.png"));
final UpdateRepositoryEntryParams updateParams = UpdateRepositoryEntryParams.create().repositoryId(newRepo.getId()).repositoryData(data).attachments(ImmutableList.of(new BinaryAttachment(BinaryReference.from("image.png"), ByteSource.wrap("attachmentName".getBytes())))).build();
repositoryEntryService.updateRepositoryEntry(updateParams);
});
NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().dumpName("testDump").build()));
NodeHelper.runAsAdmin(() -> {
dumpDeleteAndLoad(true);
final AttachedBinaries attachedBinaries = repositoryEntryService.getRepositoryEntry(RepositoryId.from("new-repo")).getAttachments();
assertEquals(1, attachedBinaries.getSize());
assertNotNull(attachedBinaries.getByBinaryReference(BinaryReference.from("image.png")));
});
}
Aggregations