Package org.exist.dom

Examples of org.exist.dom.DocumentMetadata


                    w.flush();
                    w.close();
                   
                    is = new FileInputStream(tempFile);
                   
                    final DocumentMetadata meta = doc.getMetadata();
                   
                    final Date created = new Date(meta.getCreated());
                    final Date lastModified = new Date(meta.getLastModified());
   
                    BinaryDocument binary = destination.validateBinaryResource(txn, broker, newName, is, mimeType.getName(), -1, created, lastModified);
                   
                    binary = destination.addBinaryResource(txn, broker, binary, is, mimeType.getName(), -1, created, lastModified);
                   
View Full Code Here


          // store as xml resource
         
          final IndexInfo info = currentCollection.validateXMLResource(txn, broker, docUri, is);
         
          resource = info.getDocument();
          final DocumentMetadata meta = resource.getMetadata();
          meta.setMimeType(mimetype);
          meta.setCreated(date_created.getTime());
          meta.setLastModified(date_modified.getTime());
         
                  if((publicid != null) || (systemid != null)) {
                    final DocumentType docType = new DocumentTypeImpl(namedoctype, publicid, systemid);
                    meta.setDocType(docType);
                  }

          rh.startDocumentRestore(resource, atts);

          currentCollection.store(txn, broker, info, is, false);
View Full Code Here

   
    public static CompiledXQuery compile(final DBBroker broker, final DocumentImpl document) throws RestXqServiceCompilationException {
       
        try {
            if(document instanceof BinaryDocument) {
                final DocumentMetadata metadata = document.getMetadata();
                if(metadata.getMimeType().equals(XQUERY_MIME_TYPE)){
           
                    //compile the query
                    final XQuery xquery = broker.getXQueryService();
                    final XQueryContext context = xquery.newContext(AccessContext.REST);
                    final Source source = new DBSource(broker, (BinaryDocument)document, true);

                    //set the module load path for any module imports that are relative
                    context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI_PREFIX + ((XmldbURI)source.getKey()).removeLastSegment());
                   
                    return broker.getXQueryService().compile(context, source);
                } else {
                    throw new RestXqServiceCompilationException("Invalid mimetype '" +  metadata.getMimeType() + "' for XQuery: "  + document.getURI().toString().toString());
                }
            } else {
                throw new RestXqServiceCompilationException("Invalid document location for XQuery: " + document.getURI().toString());
            }
        } catch(XPathException xpe) {
View Full Code Here

            if (resource != null) {
                if (!resource.getPermissions().validate(broker.getSubject(), Permission.READ)) {
                    throw new PermissionDeniedException(
                            "Permission to read resource " + path + " denied");
                }
                final DocumentMetadata metadata = resource.getMetadata();
                response.setContentType(metadata.getMimeType());
                // As HttpServletResponse.setContentLength is limited to integers,
                // (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4187336)
                // next sentence:
                //  response.setContentLength(resource.getContentLength());
                // must be set so
                response.addHeader("Content-Length", Long.toString(resource.getContentLength()));
                setCreatedAndLastModifiedHeaders(response, metadata.getCreated(), metadata.getLastModified());
            } else {
                final Collection col = broker.getCollection(pathUri);
                //no resource or collection
                if (col == null) {
                    response.sendError(HttpServletResponse.SC_NOT_FOUND, "No resource at location: " + path);
View Full Code Here

        if (!resource.getPermissions().validate(broker.getSubject(), Permission.READ)) {
            throw new PermissionDeniedException("Not allowed to read resource");
        }

        //get the document metadata
        final DocumentMetadata metadata = resource.getMetadata();
        final long lastModified = metadata.getLastModified();
        setCreatedAndLastModifiedHeaders(response, metadata.getCreated(), lastModified);


        /**
         * HTTP 1.1 RFC 2616 Section 14.25 *
         */
 
View Full Code Here

            for (final Iterator<DocumentImpl> i = collection.iterator(broker); i.hasNext();) {
                final DocumentImpl doc = i.next();
                if (doc.getPermissions().validate(broker.getSubject(), Permission.READ)) {
                    final XmldbURI resource = doc.getFileURI();
                    final DocumentMetadata metadata = doc.getMetadata();
                    attrs.clear();
                    attrs.addAttribute("", "name", "name", "CDATA", resource.toString());

                    // add an attribute for the creation date as an xs:dateTime
                    try {
                        final DateTimeValue dtCreated =
                                new DateTimeValue(new Date(metadata.getCreated()));
                        attrs.addAttribute("", "created", "created", "CDATA",
                                dtCreated.getStringValue());
                    } catch (final XPathException e) {
                        // fallback to long value
                        attrs.addAttribute("", "created", "created", "CDATA",
                                String.valueOf(metadata.getCreated()));
                    }

                    // add an attribute for the last modified date as an
                    // xs:dateTime
                    try {
                        final DateTimeValue dtLastModified = new DateTimeValue(
                                new Date(metadata.getLastModified()));
                        attrs.addAttribute("", "last-modified",
                                "last-modified", "CDATA", dtLastModified.getStringValue());
                    } catch (final XPathException e) {
                        // fallback to long value
                        attrs.addAttribute("", "last-modified",
                                "last-modified", "CDATA", String.valueOf(metadata.getLastModified()));
                    }

                    addPermissionAttributes(attrs, doc.getPermissions());
                    serializer.startElement(Namespaces.EXIST_NS, "resource", "exist:resource", attrs);
                    serializer.endElement(Namespaces.EXIST_NS, "resource", "exist:resource");
View Full Code Here

TOP

Related Classes of org.exist.dom.DocumentMetadata

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.