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;
}
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);
}
}
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());
}
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);
}
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());
}
Aggregations