use of com.enonic.xp.branch.Branch in project xp by enonic.
the class UnpublishContentHandler method execute.
public List<String> execute() {
final Branch targetBranch = ContentConstants.BRANCH_MASTER;
final Context context = ContextBuilder.from(ContextAccessor.current()).branch(targetBranch).build();
final List<ContentId> contentIds = context.callWith(this::resolveContentIds);
final UnpublishContentParams unpublishContentParams = UnpublishContentParams.create().contentIds(ContentIds.from(contentIds)).unpublishBranch(targetBranch).includeChildren(true).build();
final UnpublishContentsResult result = this.contentService.unpublishContent(unpublishContentParams);
return result.getUnpublishedContents().stream().map(ContentId::toString).collect(Collectors.toList());
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class ReindexResultJson method create.
public static ReindexResultJson create(final ReindexResult result) {
final ReindexResultJson json = new ReindexResultJson();
json.duration = result.getDuration().toString();
json.startTime = result.getStartTime();
json.endTime = result.getEndTime();
json.repositoryId = result.getRepositoryId().toString();
json.numberReindexed = result.getReindexNodes().getSize();
json.branches = new ArrayList<>();
for (final Branch branch : result.getBranches()) {
json.branches.add(branch.getValue());
}
return json;
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class RepositoryJson method create.
public static RepositoryJson create(final Repository repository) {
final RepositoryJson json = new RepositoryJson();
json.id = repository.getId().toString();
json.branches = new ArrayList<>();
for (final Branch branch : repository.getBranches()) {
json.branches.add(branch.getValue());
}
return json;
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class CreateBranchHandler method doCreateBranch.
private BranchMapper doCreateBranch() {
final CreateBranchParams createBranchParams = CreateBranchParams.from(branchId);
final Branch createdBranch = repositoryServiceSupplier.get().createBranch(createBranchParams);
return createdBranch == null ? null : new BranchMapper(createdBranch);
}
use of com.enonic.xp.branch.Branch in project xp by enonic.
the class ContextBuilderTest method copyConstructWithOverwrite.
@Test
public void copyConstructWithOverwrite() throws Exception {
final Context old = ContextBuilder.create().repositoryId("repository").branch("branch").attribute("key1", "value1").build();
final Branch newWS = Branch.from("new");
final Context newContext = ContextBuilder.from(old).branch(newWS).build();
assertEquals(newWS, newContext.getBranch());
assertEquals("repository", newContext.getRepositoryId().toString());
}
Aggregations