Java Code Examples for javax.jcr.Node#getSession()
The following examples show how to use
javax.jcr.Node#getSession() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AggregateManagerImpl.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
/** * Constructs the artifact manager. * * @param config the configuration * @param wspFilter the workspace filter * @param mountpoint the repository address of the mountpoint * @param rootNode the root node * @param ownSession indicates if the session can be logged out in unmount. * @throws RepositoryException if an error occurs. */ private AggregateManagerImpl(VaultFsConfig config, WorkspaceFilter wspFilter, RepositoryAddress mountpoint, Node rootNode, boolean ownSession) throws RepositoryException { session = rootNode.getSession(); this.mountpoint = mountpoint; this.ownSession = ownSession; this.config = config; workspaceFilter = wspFilter; aggregatorProvider = new AggregatorProvider(config.getAggregators()); artifactHandlers = Collections.unmodifiableList(config.getHandlers()); // init root node Aggregator rootAggregator = rootNode.getDepth() == 0 ? new RootAggregator() : getAggregator(rootNode, null); root = new AggregateImpl(this, rootNode.getPath(), rootAggregator); // setup node types initNodeTypes(); }
Example 2
Source File: FolderArtifactHandler.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
private Node modifyPrimaryType(Node node, ImportInfoImpl info) throws RepositoryException { String name = node.getName(); Node parent = node.getParent(); // check versionable ensureCheckedOut(node, info); ChildNodeStash recovery = new ChildNodeStash(node.getSession()); recovery.stashChildren(node); node.remove(); // now create the new node Node newNode = parent.addNode(name, nodeType); info.onReplaced(newNode.getPath()); // move the children back recovery.recoverChildren(newNode, info); return newNode; }
Example 3
Source File: JcrSysViewTransformer.java From jackrabbit-filevault with Apache License 2.0 | 6 votes |
JcrSysViewTransformer(Node node, String existingPath) throws RepositoryException, SAXException { Session session = node.getSession(); parent = node; handler = session.getImportContentHandler( node.getPath(), existingPath != null ? ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING : ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING ); // first define the current namespaces String[] prefixes = session.getNamespacePrefixes(); handler.startDocument(); for (String prefix: prefixes) { handler.startPrefixMapping(prefix, session.getNamespaceURI(prefix)); } this.existingPath = existingPath; if (existingPath != null) { // check if there is an existing node with the name recovery = new ChildNodeStash(session).excludeName("rep:cache"); recovery.stashChildren(existingPath); } excludeNode("rep:cache"); }
Example 4
Source File: NodeTypeAggregator.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public ImportInfo remove(Node node, boolean recursive, boolean trySave) throws RepositoryException { ImportInfo info = new ImportInfoImpl(); info.onDeleted(node.getPath()); Session s = node.getSession(); node.remove(); if (trySave) { s.save(); } return info; }
Example 5
Source File: FileAggregator.java From jackrabbit-filevault with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ public ImportInfo remove(Node node, boolean recursive, boolean trySave) throws RepositoryException { ImportInfo info = new ImportInfoImpl(); info.onDeleted(node.getPath()); Session s = node.getSession(); node.remove(); if (trySave) { s.save(); } return info; }
Example 6
Source File: JackrabbitACLImporter.java From jackrabbit-filevault with Apache License 2.0 | 4 votes |
public JackrabbitACLImporter(Node accessControlledNode, AccessControlHandling aclHandling) throws RepositoryException { this(accessControlledNode.getSession(), accessControlledNode.getPath(), aclHandling); }
Example 7
Source File: JcrPackageManagerImpl.java From jackrabbit-filevault with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void assemble(Node packNode, JcrPackageDefinition definition, ProgressTrackerListener listener) throws PackageException, RepositoryException, IOException { Calendar now = Calendar.getInstance(); JcrPackageDefinitionImpl def = (JcrPackageDefinitionImpl) definition; validateSubPackages(def); def.sealForAssembly(now); DefaultMetaInf inf = (DefaultMetaInf) def.getMetaInf(); CompositeExportProcessor processor = new CompositeExportProcessor(); // tweak filter for primary root, in case it contains sub-packages if (!registry.getPackRootPaths()[0].equals(DEFAULT_PACKAGE_ROOT_PATH)) { SubPackageExportProcessor sp = new SubPackageExportProcessor(this, packNode.getSession()); WorkspaceFilter newFilter = sp.prepare(inf.getFilter()); if (newFilter != null) { inf.setFilter(newFilter); processor.addProcessor(sp); } } ExportOptions opts = new ExportOptions(); opts.setMetaInf(inf); opts.setListener(listener); processor.addProcessor(def.getInjectProcessor()); opts.setPostProcessor(processor); VaultPackage pack = assemble(packNode.getSession(), opts, (File) null); PackageId id = pack.getId(); // update this content Node contentNode = packNode.getNode(JcrConstants.JCR_CONTENT); try (InputStream in = FileUtils.openInputStream(pack.getFile())){ // stay jcr 1.0 compatible //noinspection deprecation contentNode.setProperty(JcrConstants.JCR_DATA, in); contentNode.setProperty(JcrConstants.JCR_LASTMODIFIED, now); contentNode.setProperty(JcrConstants.JCR_MIMETYPE, JcrPackage.MIME_TYPE); packNode.getSession().save(); } catch (IOException e) { throw new PackageException(e); } pack.close(); dispatch(PackageEvent.Type.ASSEMBLE, id, null); }