use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ContentAuditLogSupportImpl method doUndoPendingDelete.
private void doUndoPendingDelete(final UndoPendingDeleteContentParams params, final Contents contents, final Context rootContext) {
if (params.getContentIds() == null) {
return;
}
final PropertyTree data = new PropertyTree();
final PropertySet paramsSet = data.addSet("params");
paramsSet.addString("target", nullToNull(params.getTarget()));
paramsSet.addStrings("contentIds", params.getContentIds().stream().map(ContentId::toString).collect(Collectors.toList()));
addContents(data.getRoot(), contents, "result");
log("system.content.delete", data, contents.getIds(), rootContext);
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ContentAuditLogSupportImpl method doReprocess.
private void doReprocess(final Content content, final Context rootContext) {
final ContentId contentId = content.getId();
final PropertyTree data = new PropertyTree();
final PropertySet paramsSet = data.addSet("params");
final PropertySet resultSet = data.addSet("result");
paramsSet.addString("contentId", nullToNull(contentId));
addContent(resultSet, content);
log("system.content.reprocess", data, contentId, rootContext);
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ContentNodeTranslator method doTranslate.
private Content doTranslate(final Node node, final boolean hasChildren, final boolean allowAltRootPath) {
final ContentId contentId = ContentId.from(node.id().toString());
if (!allowAltRootPath && !(node.path().toString().startsWith(ContentNodeHelper.getContentRoot().toString() + "/") || node.path().equals(ContentNodeHelper.getContentRoot()))) {
throw new ContentNotFoundException(contentId, ContextAccessor.current().getBranch(), ContentNodeHelper.getContentRoot());
}
final ContentPath parentContentPath = getParent(node.path());
final Content.Builder<?> builder = contentDataSerializer.fromData(node.data().getRoot());
builder.id(contentId).parentPath(parentContentPath).name(node.name().toString()).childOrder(node.getChildOrder()).permissions(node.getPermissions()).inheritPermissions(node.inheritsPermissions()).hasChildren(hasChildren).contentState(ContentState.from(node.getNodeState().value())).manualOrderValue(node.getManualOrderValue());
final boolean isRoot = NodePath.ROOT.equals(node.parentPath());
if (isRoot) {
builder.root();
}
return builder.build();
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class GetNearestSiteCommandTest method get_nearest_site_content_is_site.
@Test
public void get_nearest_site_content_is_site() throws Exception {
final Node node = Node.create().id(NodeId.from("test")).name("myContent").parentPath(ContentConstants.CONTENT_ROOT_PATH).build();
final ContentId contentId = ContentId.from("aaa");
final Site site = Site.create().path("/mycontent").id(contentId).build();
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(node);
Mockito.when(this.translator.fromNode(node, true)).thenReturn(site);
assertEquals(site, createCommand(contentId).execute());
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class GetNearestSiteCommandTest method get_nearest_site_parent_is_site.
@Test
public void get_nearest_site_parent_is_site() throws Exception {
final ContentId contentId = ContentId.from("aaa");
final Node node = Node.create().id(NodeId.from("test")).name("myContent").parentPath(ContentConstants.CONTENT_ROOT_PATH).build();
final Content content = Content.create().id(contentId).name("name").parentPath(ContentPath.from("/aaa")).build();
final Site parent = Site.create().path("/mycontent").id(ContentId.from("bbb")).build();
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(node);
Mockito.when(this.nodeService.getByPath(Mockito.isA(NodePath.class))).thenReturn(node);
Mockito.when(this.translator.fromNode(node, true)).thenReturn(content, parent);
assertEquals(parent, createCommand(contentId).execute());
}
Aggregations