本文整理汇总了Java中org.jcrom.util.PathUtils类的典型用法代码示例。如果您正苦于以下问题:Java PathUtils类的具体用法?Java PathUtils怎么用?Java PathUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathUtils类属于org.jcrom.util包,在下文中一共展示了PathUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapSingleReference
import org.jcrom.util.PathUtils; //导入依赖的package包/类
private void mapSingleReference(JcrReference jcrReference, Object referenceObject, Node containerNode, String propertyName) throws IllegalAccessException, RepositoryException {
if (jcrReference.byPath()) {
String referencePath = mapper.getNodePath(referenceObject);
if (referencePath != null && !referencePath.equals("")) {
if (containerNode.getSession().getRootNode().hasNode(PathUtils.relativePath(referencePath))) {
containerNode.setProperty(propertyName, containerNode.getSession().getValueFactory().createValue(referencePath));
}
}
} else {
String referenceId = mapper.getNodeId(referenceObject);
if (referenceId != null && !referenceId.equals("")) {
//Node referencedNode = containerNode.getSession().getNodeByUUID(referenceUUID);
Node referencedNode = PathUtils.getNodeById(referenceId, containerNode.getSession());
if (jcrReference.weak()) {
containerNode.setProperty(propertyName, containerNode.getSession().getValueFactory().createValue(referencedNode, true));
} else {
containerNode.setProperty(propertyName, referencedNode);
}
} else {
// remove the reference
containerNode.setProperty(propertyName, (Value) null);
}
}
}
示例2: testAdobeCQ
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Test
public void testAdobeCQ() throws RepositoryException {
Jcrom jcrom = new Jcrom();
jcrom.map(PageContentNode.class);
Node rootNode = session.getRootNode().addNode("root");
String name = "Page Content Node 1";
String title = "this is page content node 1";
String description = "Description: page content node 1";
String resourceType = "resourceType 1";
String[] tags = new String[] { "new tag 1", "new tag 2" };
PageContentNode pcn = createPageContentNode(name, title, description, resourceType, tags);
Node newNode = jcrom.addNode(rootNode, pcn);
assertNotNull(newNode);
PageContentNode fromNode = jcrom.fromNode(PageContentNode.class, newNode);
assertNotNull(fromNode);
assertEquals(PathUtils.createValidName(name), fromNode.getName());
assertEquals(title, fromNode.getTitle());
assertEquals(description, fromNode.getDescription());
assertEquals(resourceType, fromNode.getResourceType());
assertNotNull(fromNode.getTags());
assertEquals(tags.length, fromNode.getTags().length);
}
示例3: testAdobeCQ
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Test
public void testAdobeCQ() throws RepositoryException {
Jcrom jcrom = new Jcrom();
jcrom.map(PageContentNode.class);
Node rootNode = ((Session) session).getRootNode().addNode("root");
String name = "Page Content Node 1";
String title = "this is page content node 1";
String description = "Description: page content node 1";
String resourceType = "resourceType 1";
String[] tags = new String[] { "new tag 1", "new tag 2" };
PageContentNode pcn = createPageContentNode(name, title, description, resourceType, tags);
Node newNode = jcrom.addNode(rootNode, pcn);
assertNotNull(newNode);
PageContentNode fromNode = jcrom.fromNode(PageContentNode.class, newNode);
assertNotNull(fromNode);
assertEquals(PathUtils.createValidName(name), fromNode.getName());
assertEquals(title, fromNode.getTitle());
assertEquals(description, fromNode.getDescription());
assertEquals(resourceType, fromNode.getResourceType());
assertNotNull(fromNode.getTags());
assertEquals(tags.length, fromNode.getTags().length);
}
示例4: doLoadObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Lazy loading single child for " + containerPath);
}
Node node;
if (pathIsContainer) {
node = PathUtils.getNode(containerPath, session).getNodes().nextNode();
} else {
node = PathUtils.getNode(containerPath, session);
}
return mapper.getChildNodeMapper().getSingleChild(objectClass, node, parentObject, mapper, depth, nodeFilter);
}
示例5: getReferenceValues
import org.jcrom.util.PathUtils; //导入依赖的package包/类
private List<Value> getReferenceValues(List<?> references, Session session, JcrReference jcrReference) throws IllegalAccessException, RepositoryException {
List<Value> refValues = new ArrayList<Value>();
for (Object reference : references) {
if (jcrReference.byPath()) {
String referencePath = mapper.getNodePath(reference);
if (referencePath != null && !referencePath.equals("")) {
if (session.getRootNode().hasNode(PathUtils.relativePath(referencePath))) {
refValues.add(session.getValueFactory().createValue(referencePath));
}
}
} else {
String referenceId = mapper.getNodeId(reference);
if (referenceId != null && !referenceId.equals("")) {
//Node referencedNode = session.getNodeByUUID(referenceUUID);
Node referencedNode = PathUtils.getNodeById(referenceId, session);
Value value;
if (jcrReference.weak()) {
value = session.getValueFactory().createValue(referencedNode, true);
} else {
value = session.getValueFactory().createValue(referencedNode);
}
refValues.add(value);
}
}
}
return refValues;
}
示例6: getSingleReferencedNode
import org.jcrom.util.PathUtils; //导入依赖的package包/类
private Node getSingleReferencedNode(JcrReference jcrReference, Value value, Session session) throws RepositoryException {
if (jcrReference.byPath()) {
if (session.getRootNode().hasNode(PathUtils.relativePath(value.getString()))) {
return PathUtils.getNode(value.getString(), session);
}
} else {
//return session.getNodeByUUID(value.getString());
return PathUtils.getNodeById(value.getString(), session);
}
return null;
}
示例7: createReferencedObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
Object createReferencedObject(Field field, Value value, Object obj, Session session, Class<?> referenceObjClass, int depth, NodeFilter nodeFilter, Mapper mapper) throws ClassNotFoundException, InstantiationException, RepositoryException, IllegalAccessException, IOException {
JcrReference jcrReference = mapper.getJcrom().getAnnotationReader().getAnnotation(field, JcrReference.class);
Node referencedNode = null;
if (jcrReference.byPath()) {
if (session.getRootNode().hasNode(PathUtils.relativePath(value.getString()))) {
referencedNode = PathUtils.getNode(value.getString(), session);
}
} else {
//referencedNode = session.getNodeByUUID(value.getString());
referencedNode = PathUtils.getNodeById(value.getString(), session);
}
if (referencedNode != null) {
Object referencedObject = mapper.createInstanceForNode(referenceObjClass, referencedNode);
if (nodeFilter.isIncluded(field.getName(), depth)) {
// load and map the object, we don't send the current object as parent
referencedObject = mapper.mapNodeToClass(referencedObject, referencedNode, nodeFilter, null, depth + 1);
} else {
if (jcrReference.byPath()) {
// just store the path
mapper.setNodePath(referencedObject, value.getString());
} else {
// just store the Identifier
mapper.setUUID(referencedObject, value.getString());
mapper.setId(referencedObject, value.getString());
}
}
// support JcrFileNode annotation for references
if (field.isAnnotationPresent(JcrFileNode.class) && referencedObject instanceof JcrFile) {
JcrFileNode fileNode = field.getAnnotation(JcrFileNode.class);
FileNodeMapper.addFileProperties((JcrFile) referencedObject, referencedNode, fileNode, depth, nodeFilter);
}
return referencedObject;
} else {
return null;
}
}
示例8: exists
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
public boolean exists(String path) {
try {
return getSession().getRootNode().hasNode(PathUtils.relativePath(path));
} catch (RepositoryException e) {
throw new JcrMappingException("Could not check if node exists", e);
}
}
示例9: doLoadObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Lazy loading children list for " + containerPath);
}
Node childrenContainer = PathUtils.getNode(containerPath, session);
return mapper.getChildNodeMapper().getChildrenList(objectClass, childrenContainer, parentObject, mapper, depth, nodeFilter, jcrChildNode);
}
示例10: doLoadObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Lazy loading single reference for " + nodePath + " " + propertyName);
}
Node node = PathUtils.getNode(nodePath, session);
return mapper.getReferenceMapper().createReferencedObject(field, node.getProperty(propertyName).getValue(), parentObject, session, objClass, depth, nodeFilter, mapper);
}
示例11: doLoadObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Lazy loading file list for " + fileContainerPath);
}
Node fileContainer = PathUtils.getNode(fileContainerPath, session);
return mapper.getFileNodeMapper().getFileList(objectClass, fileContainer, parentObject, jcrFileNode, depth, nodeFilter, mapper);
}
示例12: doLoadObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Lazy loading reference list for " + nodePath + " " + propertyName);
}
Node node = PathUtils.getNode(nodePath, session);
return mapper.getReferenceMapper().getReferenceList(field, propertyName, objClass, node, parentObject, depth, nodeFilter, mapper);
}
示例13: doLoadObject
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Override
protected Object doLoadObject(Session session, Mapper mapper) throws Exception {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Lazy loading file node for " + fileContainerPath);
}
Node fileContainer = PathUtils.getNode(fileContainerPath, session);
return mapper.getFileNodeMapper().getSingleFile(objectClass, fileContainer, parentObject, jcrFileNode, depth, nodeFilter, mapper);
}
示例14: parentInterface
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Test
public void parentInterface() throws Exception {
final Jcrom jcrom = new Jcrom(true, true);
jcrom.map(Square.class).map(WithParentInterface.class).map(Parent.class).map(Child.class);
final Node parentNode = this.session.getRootNode().addNode("mynode");
WithParentInterface child = new WithParentInterface();
child.setName("child");
Square square = new Square(3, 3);
square.setName("square");
square.setChild(child);
Node newNode = jcrom.addNode(parentNode, square);
Square fromNode = jcrom.fromNode(Square.class, newNode);
assertTrue(square.getArea() == fromNode.getChild().getParent().getArea());
// add unit test to check if we retrieve the parent node after calling method fromNode
WithParentInterface child2 = new WithParentInterface();
child2.setName("child2");
Node newNode2 = jcrom.addNode(newNode, child2);
WithParentInterface fromNode2 = jcrom.fromNode(WithParentInterface.class, newNode2);
assertEquals(0, Double.compare(square.getArea(), fromNode2.getParent().getArea()));
Parent parent3 = createParent("daddy");
Child child3 = createChild("child");
parent3.addChild(child3);
Node parentNode3 = jcrom.addNode(parentNode, parent3);
Node childNode3 = parentNode3.getNode("children/" + PathUtils.createValidName(child3.getName()));
Child fromNode3 = jcrom.fromNode(Child.class, childNode3);
assertTrue(parent3.getHeight() == fromNode3.getParent().getHeight());
assertTrue(parent3.getTitle() == fromNode3.getParent().getTitle());
}
示例15: testPathUtils
import org.jcrom.util.PathUtils; //导入依赖的package包/类
@Test
public void testPathUtils() {
String path1 = " Hello, world!";
assertEquals("Hello_world", PathUtils.createValidName(path1));
String path2 = "how_are_you?";
assertEquals("how_are_you", PathUtils.createValidName(path2));
}