public static MetaDataQueryResult createResultSet( List<List<?>> records, ResultSetMetaData resultSetMetaData ) throws SQLException { try { return new MetaDataQueryResult(records, resultSetMetaData); } catch (RepositoryException e) { if (e.getCause() instanceof SQLException) throw (SQLException)e.getCause(); throw new SQLException(e); } }
public static MetaDataQueryResult createResultSet( List<List<?>> records, ResultSetMetaData resultSetMetaData ) throws SQLException { try { return new MetaDataQueryResult(records, resultSetMetaData); } catch (RepositoryException e) { if (e.getCause() instanceof SQLException) throw (SQLException)e.getCause(); throw new SQLException(e); } }
protected void registerNodeTypes() throws Exception { if ( !nodeTypeDefinitionProviders.isEmpty() ) { Session session = null; try { session = getAdminSession(); Workspace ws = session.getWorkspace(); NodeTypeManager ntMgr = ws.getNodeTypeManager(); ValueFactory vFac = session.getValueFactory(); List<NodeTypeDefinition> ntds = new ArrayList<NodeTypeDefinition>(); for ( NodeTypeDefinitionProvider nodeTypeDefinitionProvider : nodeTypeDefinitionProviders ) { ntds.add( nodeTypeDefinitionProvider.getNodeTypeDefinition( ntMgr, vFac ) ); } ntMgr.registerNodeTypes( ntds.toArray( new NodeTypeDefinition[ 0 ] ), true ); } catch ( RepositoryException ex ) { LOG.error( "Error registering nodetypes ", ex.getCause() ); } finally { if ( session != null ) { session.logout(); } } } }
private void visitChildren(final Node node) throws RepositoryException { NodeIterator children = null; try { children = node.getNodes(); } catch (RepositoryException e) { if (e.getCause() instanceof ItemNotFoundException) { debug("Node no longer exists: " + node.getIdentifier()); } else { throw e; } } if (children == null) { return; } for (Node child : new NodeIterable(children)) { if (child != null && !isVirtual(child)) { visit(child); } } }
/** * check is either the node or property exists with the specified path and user has access to it. If at least READ permission is not * granted or not running in SystemContext, the method will return false even if the node in question exists. */ @Override public boolean isExist(String path) { if (!PermissionUtil.isGranted(jcrSession, path, Session.ACTION_READ)) { return false; } try { this.getJcrSession().refresh(true); return this.getJcrSession().itemExists(path); } catch (RepositoryException re) { // do not create hard dependency on JR API. The path validity check is not exposed via JCR API if (re.getCause().getClass().getName().equals("org.apache.jackrabbit.spi.commons.conversion.MalformedPathException")) { // do not log invalid path by default log.debug("{} is not valid jcr path.", path); } else { log.error("Exception caught", re); } return false; } }
/** * Create a login exception from a repository exception. If the repository * exception is a {@link javax.jcr.LoginException} a {@link LoginException} * is created with the same information. Otherwise a {@link LoginException} * is created which wraps the repository exception. * * @param re * The repository exception. * @return The login exception. */ private static LoginException getLoginException(final RepositoryException re) { if (re instanceof javax.jcr.LoginException) { return new LoginException(re.getMessage(), re.getCause()); } return new LoginException("Unable to login " + re.getMessage(), re); }
/** Test for same node type name on node type import. */ public void testInvalidCNDNodeTypes() throws Exception { JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager(); try { ntm.registerNodeTypes( TestAll.class.getResourceAsStream(TEST_SAME_NT_NAME_CND_NODETYPES), JackrabbitNodeTypeManager.TEXT_X_JCR_CND); fail("Importing multiple node types with the same name must fail"); } catch (RepositoryException e) { if (e.getCause() instanceof InvalidNodeTypeDefException) { // Expected } else { throw e; } } }
/** Test for same node type name on node type import. */ public void testInvalidXMLNodeTypes() throws Exception { JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager(); try { ntm.registerNodeTypes( TestAll.class.getResourceAsStream(TEST_SAME_NT_NAME_XML_NODETYPES), JackrabbitNodeTypeManager.TEXT_XML); fail("Importing multiple node types with the same name must fail"); } catch (RepositoryException e) { if (e.getCause() instanceof InvalidNodeTypeDefException) { // Expected } else { throw e; } } }
Throwable cause = e.getCause(); if (!(cause instanceof NoSuchItemStateException)) { log.warn("Unexpected RepositoryException caught", e);
private static void assertCyclicCommitFailed(RepositoryException e) { Throwable th = e.getCause(); if (th != null) { assertTrue(th instanceof CommitFailedException); assertEquals(31, ((CommitFailedException) th).getCode()); } }
public void start() { if (LOG.isDebugEnabled()) { LOG.debug("start"); } try { if (indexingTree == null) { NodeData indexingRootNodeData = (NodeData)itemMgr.getItemData(Constants.ROOT_UUID); indexingTree = new IndexingTree(indexingRootNodeData, isSystem ? Constants.JCR_SYSTEM_PATH : null); } initializeQueryHandler(); } catch (RepositoryException e) { LOG.error(e.getLocalizedMessage()); handler = null; throw new RuntimeException(e.getLocalizedMessage(), e.getCause()); } catch (RepositoryConfigurationException e) { LOG.error(e.getLocalizedMessage()); handler = null; throw new RuntimeException(e.getLocalizedMessage(), e.getCause()); } }
@Test public void shouldNotAllowInternalNodesAsReferrers() throws Exception { federationManager.createProjection("/testRoot", SOURCE_NAME, MockConnector.DOC1_LOCATION, "federated1"); Node doc1Federated = session.getNode("/testRoot/federated1"); Node externalNode = doc1Federated.addNode("federated1_1", null); externalNode.addMixin("mix:referenceable"); session.save(); Value weakRef = session.getValueFactory().createValue(externalNode, true); testRoot.setProperty("weakRef", weakRef); try { session.save(); fail("It should not be possible to create weak references from internal nodes to external nodes"); } catch (RepositoryException e) { assertTrue(e.getCause() instanceof ConnectorException); } Value strongRef = session.getValueFactory().createValue(externalNode, false); testRoot.setProperty("strongRef", strongRef); try { session.save(); fail("It should not be possible to create strong references from internal nodes to external nodes"); } catch (RepositoryException e) { assertTrue(e.getCause() instanceof ConnectorException); } }
fail("Expected save operation to fail"); } catch (RepositoryException e) { assertTrue(e.getCause() instanceof IllegalStateException); session.refresh(false);
@Test public void testRegisterPrivilegeAggregatingJcrAll() throws Exception { privilegeManager.registerPrivilege("customPriv", false, null); try { privilegeManager.registerPrivilege("customPriv2", false, new String[]{"customPriv", Privilege.JCR_ALL}); fail("Aggregation containing jcr:all is invalid."); } catch (RepositoryException e) { // success Throwable cause = e.getCause(); assertTrue(cause instanceof CommitFailedException); assertEquals(53, ((CommitFailedException) cause).getCode()); } finally { superuser.refresh(false); } } }
fail("Expected save operation to fail"); } catch (RepositoryException e) { assertTrue(e.getCause() instanceof IllegalStateException); session.refresh(false);