Search in sources :

Example 1 with Branch

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());
}
Also used : BeanContext(com.enonic.xp.script.bean.BeanContext) Context(com.enonic.xp.context.Context) Branch(com.enonic.xp.branch.Branch) UnpublishContentParams(com.enonic.xp.content.UnpublishContentParams) UnpublishContentsResult(com.enonic.xp.content.UnpublishContentsResult) ContentId(com.enonic.xp.content.ContentId)

Example 2 with Branch

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;
}
Also used : Branch(com.enonic.xp.branch.Branch)

Example 3 with Branch

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;
}
Also used : Branch(com.enonic.xp.branch.Branch)

Example 4 with Branch

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);
}
Also used : Branch(com.enonic.xp.branch.Branch) CreateBranchParams(com.enonic.xp.repository.CreateBranchParams) BranchMapper(com.enonic.xp.lib.repo.mapper.BranchMapper)

Example 5 with Branch

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());
}
Also used : Branch(com.enonic.xp.branch.Branch) Test(org.junit.jupiter.api.Test)

Aggregations

Branch (com.enonic.xp.branch.Branch)52 Test (org.junit.jupiter.api.Test)19 Node (com.enonic.xp.node.Node)13 RepositoryId (com.enonic.xp.repository.RepositoryId)12 Context (com.enonic.xp.context.Context)10 NodeId (com.enonic.xp.node.NodeId)8 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)8 Repository (com.enonic.xp.repository.Repository)7 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 ContentId (com.enonic.xp.content.ContentId)4 PropertyTree (com.enonic.xp.data.PropertyTree)4 CreateBranchParams (com.enonic.xp.repository.CreateBranchParams)4 ContentConstants (com.enonic.xp.content.ContentConstants)3 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)3 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)3 GetActiveNodeVersionsResult (com.enonic.xp.node.GetActiveNodeVersionsResult)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodePath (com.enonic.xp.node.NodePath)3 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)3