本文整理汇总了Java中javax.jcr.PathNotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java PathNotFoundException类的具体用法?Java PathNotFoundException怎么用?Java PathNotFoundException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PathNotFoundException类属于javax.jcr包,在下文中一共展示了PathNotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrCreateAreaNode
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
private JCRNodeWrapper getOrCreateAreaNode(String areaPath, JCRSessionWrapper session) throws RepositoryException {
JCRNodeWrapper areaParentNode = session.getNode(StringUtils.substringBeforeLast(areaPath, "/"));
String areaName = StringUtils.substringAfterLast(areaPath, "/");
JCRNodeWrapper areaNode = null;
try {
areaNode = areaParentNode.getNode(areaName);
} catch (PathNotFoundException e) {
try {
areaNode = areaParentNode.addNode(areaName, areaType);
session.save();
} catch (ItemExistsException e1) {
// possible race condition when page is accessed concurrently in edit mode
areaNode = areaParentNode.getNode(areaName);
}
}
return areaNode;
}
示例2: curePhase
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
/**
* The purpose of this method is to check for some conditions which may break Phases.
*
* @param boardId
* @param phaseId
* @return
* @throws Exception
*/
@PreAuthorize("hasPermission(#boardId, 'BOARD', 'ADMIN')")
@RequestMapping(value = "/{phaseId}/cure", method=RequestMethod.GET)
public @ResponseBody Boolean curePhase(@PathVariable String boardId,
@PathVariable String phaseId) throws Exception {
Session session = ocmFactory.getOcm().getSession();
try{
Node node = session.getNode(String.format(URI.PHASES_URI, boardId, phaseId));
Property property = node.getProperty("cards");
// If there is a property we need to kill it.
property.remove();
session.save();
} catch (PathNotFoundException e){
// This is expected - there should be no property.
} finally {
session.logout();
}
this.cacheInvalidationManager.invalidate(BoardController.BOARD, boardId);
return true;
}
示例3: getIdFromRepository
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
/**
* This method
* @param session
* @param path
* @return
* @throws Exception
*/
public synchronized static Long getIdFromRepository( Session session, String path, String id) throws Exception {
Long returnId = null;
//LockManager lockManager = session.getWorkspace().getLockManager();
try{
//Lock lock = lockManager.lock(path, false, false, 30000l, "");
//Node node = lock.getNode();
Node node = session.getNode(path);
try {
Property property = node.getProperty(id);
returnId = property.getLong();
} catch (PathNotFoundException e) {
returnId = 10001l;
}
node.setProperty(id, returnId+1);
session.save();
} finally {
//lockManager.unlock(path);
}
return returnId;
}
示例4: ensurePresence
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
public void ensurePresence(Session session, String initialPath, String... nodeNames) throws PathNotFoundException, RepositoryException {
if (null != nodeNames) {
final String childNodeName = nodeNames[0];
final Node parentNode = session.getNode(initialPath);
final Node childNode;
if (parentNode.hasNode(childNodeName)) {
childNode = parentNode.getNode(childNodeName);
} else {
childNode = parentNode.addNode(childNodeName);
session.save();
}
if (nodeNames.length > 1) {
ensurePresence(session, childNode.getPath(), Arrays.copyOfRange(nodeNames, 1, nodeNames.length));
}
}
}
示例5: getStoragePolicy
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
private Response getStoragePolicy(final String nodeType) throws RepositoryException {
LOGGER.debug("Get storage policy for: {}", nodeType);
Response.ResponseBuilder response;
final Node node =
getJcrTools().findOrCreateNode(session, FEDORA_STORAGE_POLICY_PATH, "test");
final Property prop = node.getProperty(nodeType);
if (null == prop) {
throw new PathNotFoundException("StoragePolicy not found: " + nodeType);
}
final Value[] values = prop.getValues();
if (values != null && values.length > 0) {
response = ok(values[0].getString());
} else {
throw new PathNotFoundException("StoragePolicy not found: " + nodeType);
}
return response.build();
}
示例6: mapPropertyToField
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
void mapPropertyToField(Object obj, Field field, Node node, int depth, NodeFilter nodeFilter) throws RepositoryException, IllegalAccessException, IOException {
String name = getPropertyName(field);
if (nodeFilter == null || nodeFilter.isIncluded(NodeFilter.PROPERTY_PREFIX + field.getName(), node, depth)) {
if (isMap(field)) {
// map of properties
Class<?> valueType = ReflectionUtils.getParameterizedClass(field, 1);
try {
Node childrenContainer = node.getNode(name);
PropertyIterator propIterator = childrenContainer.getProperties();
mapPropertiesToMap(obj, field, valueType, propIterator, true);
} catch (PathNotFoundException pne) {
// ignore here as the Field could have been added to the model
// since the Node was created and not yet been populated.
}
} else {
mapToField(name, field, obj, node);
}
}
}
示例7: testAddMapToModel
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
/**
* Thanks to [email protected] for contributing this test case.
* Tests adding a Map field to a mapped class at a later date,
* fails with PathNotFoundException in JCROM 2.0
*/
@Test
public void testAddMapToModel() throws Exception {
final Jcrom jcrom = new Jcrom();
jcrom.map(EntityToBeModified.class);
jcrom.map(EntityModifiedMapFieldAdded.class);
EntityToBeModified entity = new EntityToBeModified();
entity.setName("original");
entity.setPath("original");
Node originalNode = jcrom.addNode(this.session.getRootNode(), entity);
try {
jcrom.fromNode(EntityModifiedMapFieldAdded.class, originalNode);
} catch (JcrMappingException e) {
if (e.getCause() instanceof PathNotFoundException) {
fail("PathNotFoundException thrown.");
} else {
throw e;
}
}
}
示例8: testNodeClassChange
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
@Test(expected = PathNotFoundException.class)
public void testNodeClassChange() throws Exception {
Jcrom jcrom = new Jcrom(true, true);
jcrom.map(Rectangle.class).map(Triangle.class);
Node rootNode = session.getRootNode().addNode("root");
// create the node
Triangle triangle = new Triangle(1, 1);
triangle.setName("test");
Node newNode = jcrom.addNode(rootNode, triangle);
// now switch to another class for the node
Rectangle rectangle = new Rectangle(2.5, 3.3);
rectangle.setName("test");
jcrom.updateNode(newNode, rectangle);
// finally make sure that the old properties have been removed,
// this should throw an exception:
newNode.getProperty("base");
}
示例9: testAddMapToModel
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
/**
* Thanks to [email protected] for contributing this test case.
* Tests adding a Map field to a mapped class at a later date,
* fails with PathNotFoundException in JCROM 2.0
*/
@Test
public void testAddMapToModel() throws Exception {
final Jcrom jcrom = new Jcrom();
jcrom.map(EntityToBeModified.class);
jcrom.map(EntityModifiedMapFieldAdded.class);
EntityToBeModified entity = new EntityToBeModified();
entity.setName("original");
entity.setPath("original");
Node originalNode = jcrom.addNode(((Session) session).getRootNode(), entity);
try {
jcrom.fromNode(EntityModifiedMapFieldAdded.class, originalNode);
} catch (JcrMappingException e) {
if (e.getCause() instanceof PathNotFoundException) {
fail("PathNotFoundException thrown.");
} else {
throw e;
}
}
}
示例10: testNodeClassChange
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
@Test(expected = PathNotFoundException.class)
public void testNodeClassChange() throws Exception {
Jcrom jcrom = new Jcrom(true, true);
jcrom.map(Rectangle.class).map(Triangle.class);
Node rootNode = ((Session) session).getRootNode().addNode("root");
// create the node
Triangle triangle = new Triangle(1, 1);
triangle.setName("test");
Node newNode = jcrom.addNode(rootNode, triangle);
// now switch to another class for the node
Rectangle rectangle = new Rectangle(2.5, 3.3);
rectangle.setName("test");
jcrom.updateNode(newNode, rectangle);
// finally make sure that the old properties have been removed,
// this should throw an exception:
newNode.getProperty("base");
}
示例11: getTree
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
@Nonnull
protected Tree getTree(@Nullable String oakPath, long permissions, boolean checkAcContent) throws RepositoryException {
Tree tree = (oakPath == null) ? root.getTree("/") : root.getTree(oakPath);
if (!tree.exists()) {
throw new PathNotFoundException("No tree at " + oakPath);
}
if (permissions != Permissions.NO_PERMISSION) {
// check permissions
checkPermissions((oakPath == null) ? null : tree, permissions);
}
// check if the tree defines access controlled content
if (checkAcContent && config.getContext().definesTree(tree)) {
throw new AccessControlException("Tree " + tree.getPath() + " defines access control content.");
}
return tree;
}
示例12: getRetentionPolicy
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
public RetentionPolicy getRetentionPolicy(String s) throws PathNotFoundException, AccessDeniedException, RepositoryException {
if(RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(session.getUserID())){
throw new AccessDeniedException("Read-only session doesn't have " +
"sufficient privileges to retrieve retention policy.");
}
//Invalid path check
if (!isPathValid(s)) {
throw new RepositoryException("Cannot apply invalid path for retention policies " + s);
}
// Node existance check
if (!isPathExists(s)) {
throw new PathNotFoundException("No such Path exists for apply retention: " + s);
}
RetentionPolicy persistedPolicy = EffectiveRetentionUtil.getRetentionPolicyFromRegistry(session, s);
if(persistedPolicy != null) {
return persistedPolicy;
} else {
return pendingRetentionPolicies.get(s);
}
}
示例13: setRetentionPolicy
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
public void setRetentionPolicy(String s, RetentionPolicy retentionPolicy) throws PathNotFoundException, AccessDeniedException, LockException, VersionException, RepositoryException {
if(session.getWorkspace().getLockManager().holdsLock(s)) {
throw new LockException("Cannot set retention policy on a locked node");
}
if(RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(session.getUserID())){
throw new AccessDeniedException("Read-only session doesn't have " +
"sufficient privileges to retrieve retention policy.");
}
//Invalid path check
if (!isPathValid(s)) {
throw new RepositoryException("Cannot apply invalid path for retention policies " + s);
}
if (!isValidJCRName(retentionPolicy.getName())) {
throw new RepositoryException("Cannot apply invalid name for retention policies " + s);
}
if (!isPathExists(s)) {
throw new PathNotFoundException("No such Path exists for apply retention: " + s);
}
pendingRetentionPolicies.put(s, retentionPolicy);
// EffectiveRetentionUtil.setRetentionPolicyToRegistry(session,s,retentionPolicy);
}
示例14: getMessage
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
/**
* Reads the message content from the <code>jcr:content/jcr:data</code>
* binary property.
*
* @param node
* mail node
* @return mail message
* @throws MessagingException
* if a messaging error occurs
* @throws RepositoryException
* if a repository error occurs
* @throws IOException
* if an IO error occurs
*/
private MimeMessage getMessage(Node node) throws MessagingException, RepositoryException, IOException {
try {
node = node.getNode("jcr:content");
} catch (PathNotFoundException e) {
node = node.getProperty("jcr:content").getNode();
}
InputStream stream = node.getProperty("jcr:data").getStream();
try {
Properties properties = System.getProperties();
return new MimeMessage(javax.mail.Session.getDefaultInstance(properties), stream);
} finally {
stream.close();
}
}
示例15: model
import javax.jcr.PathNotFoundException; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see Modelspace#model(String)
*/
@Override
public Model model( final String path ) throws ModelspaceException {
CheckArg.isNotEmpty( path, "path" );
return run( new TaskWithResult< Model >() {
@Override
public Model run( final Session session ) throws Exception {
try {
final String absPath = absolutePath( path );
final Node node = session.getNode( absPath );
if ( !node.isNodeType( ModelspaceLexicon.Model.MODEL_MIXIN ) )
throw new IllegalArgumentException( ModelspaceI18n.localize( "Not a path to a model: %s", absPath ) );
return new ModelImpl( ModelspaceImpl.this, absPath );
} catch ( final PathNotFoundException e ) {
return null;
}
}
} );
}