Package org.apache.jackrabbit.vault.fs.api

Examples of org.apache.jackrabbit.vault.fs.api.Artifact


            }
        } else {
            node = node.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
        }

        Artifact a = info.artifacts.get(0);
        // Keep track of whether this file got modified
        boolean modified = false;
        // Set the jcr:data property
        ValueFactory factory = node.getSession().getValueFactory();
        Value value = factory.createValue(a.getInputStream());
        if (node.hasProperty(JcrConstants.JCR_DATA)) {
            Property data = node.getProperty(JcrConstants.JCR_DATA);
            if (!value.equals(data.getValue())) {
                data.setValue(value);
                // mark jcr:data as modified.
                importInfo.onModified(data.getPath());
                modified = true;
            }
        } else {
            Property data = node.setProperty(JcrConstants.JCR_DATA, value);
            // mark jcr:data as created
            importInfo.onCreated(data.getPath());
            modified = true;
        }

        // always update last modified if binary was modified (bug #22969)
        if (!node.hasProperty(JcrConstants.JCR_LASTMODIFIED) || modified) {
            Calendar lastModified = Calendar.getInstance();
            node.setProperty(JcrConstants.JCR_LASTMODIFIED, lastModified);
            modified = true;
        }
        // do not overwrite mimetype
        if (!node.hasProperty(JcrConstants.JCR_MIMETYPE)) {
            String mimeType = a.getContentType();
            if (mimeType == null) {
                mimeType = Text.getName(a.getRelativePath(), '.');
                mimeType = MimeTypes.getMimeType(mimeType, MimeTypes.APPLICATION_OCTET_STREAM);
            }
            node.setProperty(JcrConstants.JCR_MIMETYPE, mimeType);
            modified = true;
        }
View Full Code Here


        public Value[] getValues(Session session)
                throws RepositoryException, IOException {
            Value[] values = new Value[artifacts.size()];
            for (int i=0; i<values.length; i++) {
                Artifact a = artifacts.get(i);
                values[i] = session.getValueFactory().createValue(a.getInputStream());
            }
            return values;
        }
View Full Code Here

            return values;
        }

        public Value getValue(Session session)
                throws RepositoryException, IOException {
            Artifact a = artifacts.get(0);
            return session.getValueFactory().createValue(a.getInputStream());
        }
View Full Code Here

        // add directory
        ArtifactType type = ArtifactType.PRIMARY;
        String name = aggregate.getName();
        String ext = ".xml";
        Artifact parent = null;
        if (!hasFullCoverage()) {
            parent = new DirectoryArtifact(name);
            artifacts.add(parent);
            name = "";
            ext = Constants.DOT_CONTENT_XML;
View Full Code Here

    }

    public void writeFile(VaultFile file, String relPath)
            throws RepositoryException, IOException {
        ZipEntry e = new ZipEntry(getPlatformFilePath(file, relPath));
        Artifact a = file.getArtifact();
        if (a.getLastModified() > 0) {
            e.setTime(a.getLastModified());
        }
        track("A", relPath);
        exportInfo.update(ExportInfo.Type.ADD, e.getName());
        jOut.putNextEntry(e);
        switch (a.getPreferredAccess()) {
            case NONE:
                throw new RepositoryException("Artifact has no content.");

            case SPOOL:
                OutputStream nout = new CloseShieldOutputStream(jOut);
                a.spool(nout);
                break;

            case STREAM:
                nout = new CloseShieldOutputStream(jOut);
                InputStream in = a.getInputStream();
                IOUtils.copy(in, nout);
                in.close();
                break;
        }
        jOut.closeEntry();
View Full Code Here

                content.getProperty(JcrConstants.JCR_DATA), lastModified);

        // create .dir artifact
        if (needsDir) {
            // in this case, we create a directory artifact
            Artifact parent = new DirectoryArtifact(name, ".dir");
            artifacts.add(parent);
            // and extra
            Serializer ser = new DocViewSerializer(aggregate);
            // hack: do better
            artifacts.add(parent, "", Constants.DOT_CONTENT_XML, ArtifactType.PRIMARY, ser, 0);
View Full Code Here

                    repoName = repoName.substring(0, repoName.length() - 4);
                    repoPath = parentInfo.path + "/" + repoName;
                }
                TxInfo info = parentInfo.addChild(new TxInfo(parentInfo, repoPath));
                log.debug("Creating directory artifact for {}", repoName);
                Artifact parent = new DirectoryArtifact(repoName);
                info.artifacts.add(parent);

                Archive.Entry contentXml = file.getChild(Constants.DOT_CONTENT_XML);
                if (contentXml != null) {
                    if (contentXml.isDirectory()) {
View Full Code Here

            }
            if ((flags & F_FLAG_TYPE) > 0) {
                if (f.getArtifacts().isEmpty()) {
                    row.addCol("???");
                } else {
                    Artifact primary = f.getArtifacts().getPrimaryData();
                    if (primary == null) {
                        row.addCol("");
                    } else {
                        row.addCol(primary.getSerializationType().toString());
                    }
                }
            }
            row.addCol(f.getRelPath() + (isDir ? "/" : ""));
        } catch (RepositoryException e) {
View Full Code Here

        }
        return copy;
    }

    private void run() throws IOException, RepositoryException {
        Artifact a = remoteFile.getArtifact();
        if (a.getPreferredAccess() == AccessType.NONE) {
            throw new IOException("Artifact has no content.");
        }
        OutputStream base;
        if (digest == null) {
            base = new FileOutputStream(localFile);
        } else {
            base = new DigestOutputStream(
                    new FileOutputStream(localFile), digest);
        }
        if (lineFeed != null) {
            base = new LineOutputStream(base, lineFeed);
        }
        BinaryCheckOutputStream out = new BinaryCheckOutputStream(base);
        switch (a.getPreferredAccess()) {
            case SPOOL:
                a.spool(out);
                out.close();
                break;
            case STREAM:
                InputStream in = a.getInputStream();
                byte[] buffer = new byte[8192];
                int read;
                while ((read = in.read(buffer)) >= 0) {
                    out.write(buffer, 0, read);
                }
View Full Code Here

     *
     * @param file the file
     * @throws IOException if an I/O error occurs.
     */
    public VaultFileInputStream(VaultFile file) throws IOException {
        Artifact a = file.getArtifact();
        if (a == null || a.getPreferredAccess() == AccessType.NONE) {
            throw new IOException("invalid access.");
        }
        try {
            if (a.getPreferredAccess() == AccessType.STREAM) {
                base = a.getInputStream();
            } else {
                tmpFile = File.createTempFile("vltfs", ".spool");
                FileOutputStream out = new FileOutputStream(tmpFile);
                a.spool(out);
                out.close();
                base = new FileInputStream(tmpFile);
            }
        } catch (RepositoryException e) {
            throw new IOException(e.toString());
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.vault.fs.api.Artifact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.