Package org.brixcms.jcr.wrapper

Examples of org.brixcms.jcr.wrapper.BrixFileNode


                    return;
                }

                // create initial node skeleton
                BrixNode node = (BrixNode) getContainer().addNode(fileName, "nt:file");
                BrixFileNode file = BrixFileNode.initialize(node, "text"); // temp-mime

                // save the node so brix assigns the correct jcr type to it
                getContainer().save();

                // populate node
View Full Code Here


        // can contribute lastmodified dates and we take the latest...
        // response.setLastModifiedTime(Time.valueOf(node.getObject().getLastModified()));
    }

    protected static String getMimeType(BrixNode brixNode) {
        BrixFileNode brixFileNode = new BrixFileNode(brixNode.getDelegate(), brixNode.getSession());

        String mimeType = null;
        mimeType = brixFileNode.getMimeType();

        if (mimeType == null || mimeType.trim().isEmpty()) {
            mimeType = "text/html";
        }
        return mimeType;
View Full Code Here

                Streams.copy(upload.getInputStream(), new FileOutputStream(temp));
                upload.closeStreams();

                String mime = upload.getContentType();

                BrixFileNode file = BrixFileNode.initialize(newNode, mime);
                file.setData(file.getSession().getValueFactory().createBinary(new FileInputStream(temp)));
                file.getParent().save();
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }
View Full Code Here

        super(id, nodeModel);

        add(new Label("mimeType", new Model<String>() {
            @Override
            public String getObject() {
                BrixFileNode node = (BrixFileNode) nodeModel.getObject();
                return node.getMimeType();
            }
        }));

        add(new Label("size", new Model<String>() {
            @Override
            public String getObject() {
                BrixFileNode node = (BrixFileNode) nodeModel.getObject();
                return node.getContentLength() + " bytes";
            }
        }));

        add(new Label("requiredProtocol", new Model<String>() {
            @Override
View Full Code Here

        super(id, model);

        IModel<String> labelModel = new Model<String>() {
            @Override
            public String getObject() {
                BrixFileNode node = (BrixFileNode) getModel().getObject();
                return node.getDataAsString();
            }
        };
        add(new Label("label", labelModel));

        add(new Label("mimeType", new Model<String>() {
            @Override
            public String getObject() {
                BrixFileNode node = (BrixFileNode) model.getObject();
                return node.getMimeType();
            }
        }));

        add(new Label("size", new Model<String>() {
            @Override
            public String getObject() {
                BrixFileNode node = (BrixFileNode) model.getObject();
                return node.getContentLength() + " bytes";
            }
        }));

        add(new Label("requiredProtocol", new Model<String>() {
            @Override
View Full Code Here

            super(id);

            IModel<String> labelModel = new Model<String>() {
                @Override
                public String getObject() {
                    BrixFileNode node = (BrixFileNode) ViewTab.this.getModel().getObject();
                    return node.getDataAsString();
                }
            };

            add(new Label("label", labelModel));
        }
View Full Code Here

  @Override
  public void respond(IRequestCycle requestCycle) {
    boolean save = (this.save != null) ? this.save : Strings.isTrue(RequestCycle.get().getRequest().getRequestParameters()
        .getParameterValue(SAVE_PARAMETER).toString());

    BrixFileNode node = (BrixFileNode) this.node.getObject();

    if (!SitePlugin.get().canViewNode(node, Action.Context.PRESENTATION)) {
      throw Brix.get().getForbiddenException();
    }

    WebResponse response = (WebResponse) RequestCycle.get().getResponse();

    response.setContentType(node.getMimeType());

    Date lastModified = node.getLastModified();
    response.setLastModifiedTime(Time.valueOf(lastModified));

    try {
      final HttpServletRequest r = (HttpServletRequest) requestCycle.getRequest().getContainerRequest();
      String since = r.getHeader("If-Modified-Since");
      if (!save && since != null) {
        Date d = new Date(r.getDateHeader("If-Modified-Since"));

        // the weird toString comparison is to prevent comparing
        // milliseconds
        if (d.after(lastModified) || d.toString().equals(lastModified.toString())) {
          response.setContentLength(node.getContentLength());
          response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
          return;
        }
      }
      String fileName = node.getName();
      long length = node.getContentLength();
      HttpServletResponse httpServletResponse = (HttpServletResponse) response.getContainerResponse();
            httpServletResponse.setContentType(node.getMimeType());
      InputStream stream = node.getDataAsStream();

      new Streamer(length, stream, fileName, save, r, httpServletResponse).stream();
    } catch (Exception e) {
      log.error("Error writing resource data to content", e);
    }
View Full Code Here

    public abstract Panel newCreateNodePanel(String id, IModel<BrixNode> parentNode,
                                             SimpleCallback goBack);

    public NodeConverter getConverterForNode(BrixNode node) {
        if (node instanceof BrixFileNode) {
            BrixFileNode fileNode = (BrixFileNode) node;
            if (ResourceNodePlugin.TYPE.equals(fileNode.getNodeType())) {
                String mimeType = fileNode.getMimeType();
                if (mimeType != null &&
                        (mimeType.startsWith("text/") || mimeType.equals("application/xml"))) {
                    return new FromResourceConverter(getNodeType());
                }
            }
View Full Code Here

TOP

Related Classes of org.brixcms.jcr.wrapper.BrixFileNode

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.