Search in sources :

Example 1 with MoveContentsResult

use of com.enonic.xp.content.MoveContentsResult in project xp by enonic.

the class ContentServiceImpl method move.

@Override
public MoveContentsResult move(final MoveContentParams params) {
    final MoveContentsResult result = MoveContentCommand.create(params).nodeService(this.nodeService).contentTypeService(this.contentTypeService).translator(this.translator).eventPublisher(this.eventPublisher).moveListener(params.getMoveContentListener()).build().execute();
    contentAuditLogSupport.move(params, result);
    return result;
}
Also used : MoveContentsResult(com.enonic.xp.content.MoveContentsResult)

Example 2 with MoveContentsResult

use of com.enonic.xp.content.MoveContentsResult in project xp by enonic.

the class MoveContentCommand method execute.

MoveContentsResult execute() {
    params.validate();
    try {
        final MoveContentsResult movedContents = doExecute();
        this.nodeService.refresh(RefreshMode.ALL);
        return movedContents;
    } catch (MoveNodeException e) {
        throw new MoveContentException(e.getMessage(), ContentPath.from(e.getPath().toString()));
    } catch (NodeAlreadyExistAtPathException e) {
        throw new ContentAlreadyExistsException(ContentPath.from(e.getNode().toString()), e.getRepositoryId(), e.getBranch());
    } catch (NodeAccessException e) {
        throw new ContentAccessException(e);
    }
}
Also used : MoveNodeException(com.enonic.xp.node.MoveNodeException) NodeAccessException(com.enonic.xp.node.NodeAccessException) MoveContentException(com.enonic.xp.content.MoveContentException) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) ContentAlreadyExistsException(com.enonic.xp.content.ContentAlreadyExistsException) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) ContentAccessException(com.enonic.xp.content.ContentAccessException)

Example 3 with MoveContentsResult

use of com.enonic.xp.content.MoveContentsResult in project xp by enonic.

the class ContentServiceImplTest_move method move_to_folder_starting_with_same_name.

@Test
public void move_to_folder_starting_with_same_name() throws Exception {
    final Content site = createContent(ContentPath.ROOT, "site");
    final Content child1 = createContent(site.getPath(), "child1");
    createContent(child1.getPath(), "child1_1");
    createContent(child1.getPath(), "child2_1");
    final Content site2 = createContent(ContentPath.ROOT, "site2");
    refresh();
    final MoveContentParams params = MoveContentParams.create().contentId(child1.getId()).parentContentPath(site2.getPath()).build();
    final MoveContentsResult result = this.contentService.move(params);
    final Content movedContent = contentService.getById(result.getMovedContents().first());
    assertEquals(1, result.getMovedContents().getSize());
    assertEquals(movedContent.getParentPath(), site2.getPath());
}
Also used : MoveContentParams(com.enonic.xp.content.MoveContentParams) Content(com.enonic.xp.content.Content) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) Test(org.junit.jupiter.api.Test)

Example 4 with MoveContentsResult

use of com.enonic.xp.content.MoveContentsResult in project xp by enonic.

the class ContentServiceImplTest_move method move_from_site_to_root.

@Test
public void move_from_site_to_root() throws Exception {
    final PropertyTree siteData = new PropertyTree();
    siteData.setSet("siteConfig", this.createSiteConfig());
    final Content site = createContent(ContentPath.ROOT, "site", siteData, ContentTypeName.site());
    final Content content = createContent(site.getPath(), "child", new PropertyTree(), this.createExtraDatas());
    refresh();
    final MoveContentParams params = MoveContentParams.create().contentId(content.getId()).parentContentPath(ContentPath.ROOT).build();
    final MoveContentsResult result = this.contentService.move(params);
    final Content movedContent = contentService.getById(result.getMovedContents().first());
    assertEquals(movedContent.getAllExtraData().getSize(), 1);
}
Also used : MoveContentParams(com.enonic.xp.content.MoveContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) Test(org.junit.jupiter.api.Test)

Example 5 with MoveContentsResult

use of com.enonic.xp.content.MoveContentsResult in project xp by enonic.

the class ContentServiceImplTest_move method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final Content site = createContent(ContentPath.ROOT, "site");
    final Content child1 = createContent(site.getPath(), "child1");
    final MoveContentParams params = MoveContentParams.create().contentId(child1.getId()).parentContentPath(ContentPath.ROOT).build();
    final MoveContentsResult result = this.contentService.move(params);
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(3)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(child1.getId().toString(), logResultSet.getStrings("movedContents").iterator().next());
}
Also used : MoveContentParams(com.enonic.xp.content.MoveContentParams) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) Content(com.enonic.xp.content.Content) MoveContentsResult(com.enonic.xp.content.MoveContentsResult) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Aggregations

MoveContentsResult (com.enonic.xp.content.MoveContentsResult)7 MoveContentParams (com.enonic.xp.content.MoveContentParams)5 Content (com.enonic.xp.content.Content)3 Test (org.junit.jupiter.api.Test)3 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)1 ContentAccessException (com.enonic.xp.content.ContentAccessException)1 ContentAlreadyExistsException (com.enonic.xp.content.ContentAlreadyExistsException)1 MoveContentException (com.enonic.xp.content.MoveContentException)1 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 MoveNodeException (com.enonic.xp.node.MoveNodeException)1 NodeAccessException (com.enonic.xp.node.NodeAccessException)1 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)1