use of com.enonic.xp.node.NodeId in project xp by enonic.
the class SetPublishInfoCommand method execute.
public void execute() {
final NodeIds nodeIdsToUpdate = findNodesWithoutPublishFirstAndFrom(nodeIds);
if (nodeIdsToUpdate.getSize() == 0) {
return;
}
final Instant now = Instant.now();
final Instant publishFrom = contentPublishInfo.getFrom() == null ? now : contentPublishInfo.getFrom();
final Instant publishTo = contentPublishInfo.getTo();
for (final NodeId id : nodeIdsToUpdate) {
this.nodeService.update(UpdateNodeParams.create().editor(toBeEdited -> {
PropertySet publishInfo = toBeEdited.data.getSet(ContentPropertyNames.PUBLISH_INFO);
if (publishInfo == null) {
publishInfo = toBeEdited.data.addSet(ContentPropertyNames.PUBLISH_INFO);
}
if (publishInfo.getInstant(ContentPropertyNames.PUBLISH_FIRST) == null) {
final Instant publishFromPropertyValue = publishInfo.getInstant(ContentPropertyNames.PUBLISH_FROM);
if (publishFromPropertyValue == null) {
publishInfo.setInstant(ContentPropertyNames.PUBLISH_FIRST, publishFrom);
} else {
// TODO Special case for Enonic XP 6.7 and 6.8 contents. Remove after 7.0
publishInfo.setInstant(ContentPropertyNames.PUBLISH_FIRST, publishFromPropertyValue);
}
}
if (publishInfo.getInstant(ContentPropertyNames.PUBLISH_FROM) == null) {
publishInfo.setInstant(ContentPropertyNames.PUBLISH_FROM, publishFrom);
if (publishTo == null) {
if (publishInfo.hasProperty(ContentPropertyNames.PUBLISH_TO)) {
publishInfo.removeProperty(ContentPropertyNames.PUBLISH_TO);
}
} else {
publishInfo.setInstant(ContentPropertyNames.PUBLISH_TO, publishTo);
}
}
}).id(id).build());
if (publishContentListener != null) {
publishContentListener.contentPushed(1);
}
}
this.nodeService.refresh(RefreshMode.ALL);
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class CreateContentCommandTest method mockNodeServiceCreate.
private Node mockNodeServiceCreate(final InvocationOnMock invocation) throws Throwable {
CreateNodeParams params = (CreateNodeParams) invocation.getArguments()[0];
final AccessControlList permissions = AccessControlList.create().add(AccessControlEntry.create().allowAll().principal(PrincipalKey.ofAnonymous()).build()).build();
return Node.create().id(params.getNodeId() != null ? params.getNodeId() : new NodeId()).parentPath(params.getParent()).name(NodeName.from(params.getName())).data(params.getData()).indexConfigDocument(params.getIndexConfigDocument()).childOrder(params.getChildOrder() != null ? params.getChildOrder() : ChildOrder.defaultOrder()).permissions(permissions).inheritPermissions(params.inheritPermissions()).nodeType(params.getNodeType() != null ? params.getNodeType() : NodeType.DEFAULT_NODE_COLLECTION).timestamp(Instant.now()).build();
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class InputValidatorTest method validate_correct_input_types.
@Test
public void validate_correct_input_types() {
// Creates a property set
final PropertySet propertySet = new PropertySet();
propertySet.addString("setString", "ost");
propertySet.addDouble("setDouble", 123d);
// Creates the correct data to validate
final PropertyTree data = new PropertyTree();
data.addString("textLine", "textLine");
data.addString("color", "#12345");
data.addString("comboBox", "value2");
data.addBoolean("checkbox", true);
data.addString("phone", "+4797773223");
data.addString("tag", "myTag");
data.addReference("contentSelector", new Reference(new NodeId()));
data.addString("contentTypeFilter", "article");
data.addString("siteConfigurator", "my config here");
data.addDouble("double", 1.1d);
data.addLong("long", 12345678910L);
data.addStrings("stringArray", "a", "b", "c");
data.addLocalDateTime("localDateTime", LocalDateTime.parse("2015-01-14T10:00:00"));
data.addInstant("dateTime", DateTimeFormatter.ISO_DATE_TIME.parse("2015-01-15T10:15:00+02:00", Instant::from));
data.addLocalDate("date", LocalDate.parse("2015-01-15"));
data.addLocalTime("time", LocalTime.parse("10:00:32.123"));
data.addGeoPoint("geoPoint", GeoPoint.from("-45,34"));
data.addString("htmlArea", "<stuff>staff</stuff>");
// Validates the correct data
inputValidator.validate(data);
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class BranchServiceImpl method delete.
@Override
public void delete(final NodeIds nodeIds, final InternalContext context) {
final NodeBranchEntries nodeBranchEntries = getIgnoreOrder(nodeIds, context);
nodeBranchEntries.forEach(entry -> pathCache.evict(createPath(entry.getNodePath(), context)));
storageDao.delete(DeleteRequests.create().forceRefresh(false).ids(nodeIds.stream().map(nodeId -> new BranchDocumentId(nodeId, context.getBranch()).toString()).collect(Collectors.toList())).settings(createStorageSettings(context)).build());
}
use of com.enonic.xp.node.NodeId in project xp by enonic.
the class RepoDumper method dumpBranch.
private void dumpBranch(final BranchDumpResult.Builder dumpResult, Consumer<NodeId> nodeIdsAccumulator) {
final Node rootNode = this.nodeService.getRoot();
final FindNodesByParentResult children = this.nodeService.findByParent(FindNodesByParentParams.create().parentId(rootNode.id()).recursive(true).childOrder(ChildOrder.from("_path asc")).build());
final Branch branch = ContextAccessor.current().getBranch();
this.listener.dumpingBranch(repository.getId(), branch, children.getTotalHits() + 1);
LOG.info("Dumping repository [{}], branch [{}]", repository.getId(), branch);
doDumpNode(rootNode.id(), dumpResult);
nodeIdsAccumulator.accept(rootNode.id());
for (final NodeId child : children.getNodeIds()) {
doDumpNode(child, dumpResult);
nodeIdsAccumulator.accept(child);
}
}
Aggregations