Package org.jboss.seam.wiki.core.model

Examples of org.jboss.seam.wiki.core.model.WikiUpload


                                .setParameter("id", 8l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 2;
                em.clear();

                WikiUpload f = (WikiUpload)
                        em.createQuery("select f from WikiUpload f left join fetch f.incomingLinks where f.id = :id")
                                .setParameter("id", 30l)
                                .getSingleResult();
                assert f.getIncomingLinks().size() == 1;
            }
        }.run();

    }
View Full Code Here


    public void uploadURL() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiUpload u = (WikiUpload)
                        em.createQuery("select u from WikiUpload u where u.id = :id")
                                .setParameter("id", 30l)
                                .getSingleResult();

                assert u.getPermURL(".lace").equals("service/File/30");
                assert u.getWikiURL().equals("service/File/30");

            }
        }.run();
    }
View Full Code Here

            return false; // Not supported
        }

        // This assumes that the wiki name is the zip entry filename without extension - maybe we should
        // support with extension as option, that's unique inside a zip archive so we fail too often
        WikiUpload tmp = new WikiUpload();
        tmp.setFilename(zipEntry.getName());
        return validateNewWikiname(zipFile, WikiUtil.convertToWikiName(tmp.getFilenameWithoutExtension()));
    }
View Full Code Here

        uploader.setContentType(contentType);

        // Get the right handler for that type and produce a WikiUpload instance
        UploadType uploadType = uploadTypes.get(contentType);
        if (uploadType == null) uploadType = uploadTypes.get(UploadTypes.GENERIC_UPLOAD_TYPE);
        WikiUpload wikiUpload = uploadType.getUploadHandler().handleUpload(uploader);

        // Now set the other properties so we can persist it directly
        wikiUpload.setName(wikiUpload.getFilenameWithoutExtension());
        wikiUpload.setWikiname(WikiUtil.convertToWikiName(wikiUpload.getName()));
        wikiUpload.setAreaNumber(zipFile.getAreaNumber());
        wikiUpload.setCreatedBy(zipFile.getCreatedBy());
        wikiUpload.setLastModifiedBy(wikiUpload.getCreatedBy());
        wikiUpload.setCreatedOn(new Date(zipEntry.getTime()));
        wikiUpload.setLastModifiedOn(wikiUpload.getCreatedOn());
        wikiUpload.setReadAccessLevel(zipFile.getReadAccessLevel());
        wikiUpload.setWriteAccessLevel(zipFile.getWriteAccessLevel());

        log.debug("created new file from zip entry: " + wikiUpload);

        return wikiUpload;
    }
View Full Code Here

            String id = request.getParameter("fileId");

            Contexts.getSessionContext().set("LAST_ACCESS_ACTION", "File: " + id);

            WikiUpload file = null;

            if (!"".equals(id)) {

                Long fileId = null;
                try {
                    fileId = Long.valueOf(id);
                } catch (NumberFormatException ex) {
                    response.sendError(HttpServletResponse.SC_NOT_FOUND, "File" + id);
                }

                WikiNodeDAO wikiNodeDAO = (WikiNodeDAO)org.jboss.seam.Component.getInstance(WikiNodeDAO.class);
                file = wikiNodeDAO.findWikiUpload(fileId);
            }

            String contentType = null;
            byte[] data = null;

            String thumbnail = request.getParameter("thumbnail");

            if (file != null
                && thumbnail != null
                && Boolean.valueOf(thumbnail)
                && file.isInstance(WikiUploadImage.class)
                && ((WikiUploadImage)file).getThumbnailData() != null
                && ((WikiUploadImage)file).getThumbnailData().length >0) {

                // Render thumbnail picture
                contentType = file.getContentType();
                data = ((WikiUploadImage)file).getThumbnailData();

            } else if (file != null && file.getData() != null && file.getData().length > 0) {

                // Render file regularly
                contentType = file.getContentType();
                data = file.getData();

            } else if (fileNotFoundImage != null) {

                contentType = "image/png";
                data = fileNotFoundImage;

            }

            if (data != null) {
                response.setContentType(contentType);
                response.setContentLength(data.length);
                // If it's not a picture or if it's a picture that is an attachment, tell the browser to download
                // the file instead of displaying it
                // TODO: What about PDFs? Lot's of people want to show PDFs inline...
                if ( file != null &&
                    ( !file.isInstance(WikiUploadImage.class) || file.isAttachedToDocuments() )
                   ) {
                    response.setHeader("Content-Disposition", "attachement; filename=\"" + file.getFilename() + "\"" );
                }
                response.getOutputStream().write(data);
            }

            response.getOutputStream().flush();
View Full Code Here

    public WikiUpload afterNodeCreated(WikiUpload ignoredNode) {
        if (uploader == null || uploader.getUpload() == null) {
            throw new RuntimeException("No uploader found for create");
        }
        getLog().debug("initializing with new uploaded file: " + uploader.getFilename());
        WikiUpload upload = uploader.getUpload();
        upload = super.afterNodeCreated(upload);
        initUploadEditor(upload);

        tagEditor.setTags(upload.getTags());

        return upload;
    }
View Full Code Here

TOP

Related Classes of org.jboss.seam.wiki.core.model.WikiUpload

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.