use of com.enonic.xp.content.ContentId in project xp by enonic.
the class GetContentHandlerTest method getByIdAndVersionId_NotFound.
@Test
public void getByIdAndVersionId_NotFound() {
final ContentId contentId = ContentId.from("mycontentId");
final ContentVersionId versionId = ContentVersionId.from("versionId");
Mockito.when(this.contentService.getByIdAndVersionId(contentId, versionId)).thenThrow(new ContentNotFoundException(contentId, versionId, ContextAccessor.current().getBranch()));
runFunction("/test/GetContentHandlerTest.js", "getByIdAndVersionId_notFound");
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ContentOutboundDependenciesIdsResolverTest method resolve_content_processed_ids.
@Test
public void resolve_content_processed_ids() throws Exception {
final ContentId ref = ContentId.from("ref1");
final Content content = Content.create(createContent("folderRefContent1", new PropertyTree(), ContentTypeName.folder())).addProcessedReference(ref).build();
Mockito.when(contentService.getById(content.getId())).thenReturn(content);
final ContentIds result = resolver.resolve(content.getId());
assertEquals(result.getSize(), 1);
assertEquals(result.first(), ref);
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class FragmentComponentDataSerializer method fromData.
@Override
public FragmentComponent fromData(final PropertySet data) {
final FragmentComponent.Builder component = FragmentComponent.create();
final PropertySet specialBlockSet = data.getSet(FragmentComponentType.INSTANCE.toString());
if (specialBlockSet != null && specialBlockSet.isNotNull(ID)) {
final ContentId contentId = ContentId.from(specialBlockSet.getString(ID));
component.fragment(contentId);
}
return component.build();
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class ImageComponentDataSerializer method fromData.
@Override
public ImageComponent fromData(final PropertySet data) {
final ImageComponent.Builder component = ImageComponent.create();
final PropertySet specialBlockSet = data.getSet(ImageComponentType.INSTANCE.toString());
if (specialBlockSet != null) {
if (specialBlockSet.isNotNull(ID)) {
final ContentId contentId = ContentId.from(specialBlockSet.getString(ID));
component.image(contentId);
}
if (specialBlockSet.hasProperty(CAPTION)) {
final PropertyTree config = new PropertyTree();
config.addString(CAPTION, specialBlockSet.getString(CAPTION));
component.config(config);
}
}
return component.build();
}
use of com.enonic.xp.content.ContentId in project xp by enonic.
the class PublishContentHandler method publishContent.
private PublishContentResultMapper publishContent() {
final List<ContentPath> contentNotFound = new ArrayList<>();
final List<ContentId> contentIds = new ArrayList<>();
for (final String key : this.keys) {
if (key.startsWith("/")) {
final ContentPath path = ContentPath.from(key);
final Content content = getByPath(path);
if (content != null) {
contentIds.add(content.getId());
} else {
contentNotFound.add(path);
}
} else {
contentIds.add(ContentId.from(key));
}
}
final PushContentParams.Builder builder = PushContentParams.create();
builder.contentIds(ContentIds.from(contentIds));
builder.target(Branch.from(targetBranch));
if (this.contentPublishInfo != null) {
final Object from = this.contentPublishInfo.get("from");
final Object to = this.contentPublishInfo.get("to");
final ContentPublishInfo contentPublishInfo = ContentPublishInfo.create().from(from == null ? null : Instant.parse((String) from)).to(to == null ? null : Instant.parse((String) to)).build();
builder.contentPublishInfo(contentPublishInfo);
}
if (this.excludeChildrenIds != null) {
builder.excludeChildrenIds(ContentIds.from(this.excludeChildrenIds));
}
if (this.includeChildren != null) {
builder.includeChildren(this.includeChildren);
}
if (this.includeDependencies != null) {
builder.includeDependencies(includeDependencies);
}
builder.message(message);
final PublishContentResult result = this.contentService.publish(builder.build());
return result != null ? new PublishContentResultMapper(result, contentNotFound) : null;
}
Aggregations