Package org.internna.iwebmvc.model

Examples of org.internna.iwebmvc.model.Document


    @RequestMapping(method = RequestMethod.GET)
    public void serve(@RequestParam("file") String file, @RequestParam(required = false, value = "width") String width, @RequestParam(required = false, value = "height") String height, @RequestParam(required = false, value = "escape") String escape, HttpServletRequest request, HttpServletResponse response) throws IOException {
        if (hasText(file)) {
            if (decipherer.isEncrypted(file)) {
                Document doc = dao.find(Document.class, new UUID(decipherer.decrypt(file)));
                response.setContentType(doc.getMimeType());
                if (logger.isDebugEnabled()) logger.debug("Setting MIME type [" + doc.getMimeType() + "] to document [" + doc.getId() + "]");
                if (doc.isText()) sendText(doc, escape, response);
                else send(new ByteArrayInputStream(doc.getContents()), doc.getMimeType(), response.getOutputStream(), width, height);
            } else {
                if (file.contains("..")) throw new IllegalArgumentException("Security alert: Will not serve file [" + file + "]");
                InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF" + (file.startsWith("/") ? file : "/" + file));
                String ext = StringUtils.getFilenameExtension(file);
                String mimeType = null;
View Full Code Here


            Set<Document> keep = new HashSet<Document>();
            Set<Document> remove = new HashSet<Document>();
            for (Document doc : docs)
                if ((doc != null) && (doc.getId() != null)) {
                    if (md.getId() == null) {
                        Document kept = documentParser.parse(doc);
                        kept.setDocumentGroup(md);
                        keep.add(kept);
                    }
                } else remove.add(doc);
            md.removeDocuments(remove);
            if (md.getId() == null) md.setDocuments(keep);
View Full Code Here

                UUID id = up.getId();
                if (id != null) {
                    MultiDocument old = getDao().find(MultiDocument.class, id);
                    old.removeAll();
                    for (Document doc : up.getDocuments()) {
                        Document parsed = documentParser.parse(doc);
                        parsed.setDocumentGroup(old);
                        old.addDocument(parsed);
                    }
                    if (old.getDocuments().size() == 0) {
                        getDao().remove(old);
                        return null;
View Full Code Here

    @Override public Document parse(Document up) {
        if (up != null) {
            UUID id = up.getId();
            if (id != null) {
                Document doc = getDao().find(Document.class, id);
                doc.setTemporal(false);
                doc.setIdentifier(up.getIdentifier());
                if ((doc.getAuthor() == null) && (userManager != null)) {
                    User user = userManager.getActiveUser();
                    if ((user != null) && (!GuestUser.GUEST_USER.equals(user.getName())))
                        doc.setAuthor((UserImpl) user);
                }
                return doc;
            } else return null;
        }
        return up;
View Full Code Here

        if (pk != null) {
            DomainEntity entity = dao.find(entityClass, pk);
            if (entity != null) {
                PropertyDescriptor property = BeanUtils.getPropertyDescriptor(entityClass, path);
                if ((property != null) && (Document.class.isAssignableFrom(property.getPropertyType()))) {
                    Document doc = (Document) property.getReadMethod().invoke(entity);
                    if (doc != null) {
                        doc.setTemporal(true);
                        dao.update(doc);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.internna.iwebmvc.model.Document

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.