Package org.apache.stratos.theme.mgt.stub.registry.resource.stub.beans.xsd

Examples of org.apache.stratos.theme.mgt.stub.registry.resource.stub.beans.xsd.ContentDownloadBean


                log.error(msg);
                response.setStatus(400);
                return;
            }

            ContentDownloadBean bean = client.getContentDownloadBean(path);

            InputStream contentStream = null;
            if (bean.getContent() != null) {
                contentStream = bean.getContent().getInputStream();
            } else {
                String msg = "The resource content was empty.";
                log.error(msg);
                response.setStatus(204);
                return;
            }

            response.setDateHeader("Last-Modified", bean.getLastUpdatedTime().getTime().getTime());
            String ext = "jpg";
            if (path.lastIndexOf(".") < path.length() -1 && path.lastIndexOf(".") > 0) {
                ext = path.substring(path.lastIndexOf(".") + 1);
            }

            if (viewImage != null && viewImage.equals("1")) {
                response.setContentType("img/" + ext);
            }
            else {
                if (bean.getMediatype() != null && bean.getMediatype().length() > 0) {
                    response.setContentType(bean.getMediatype());
                } else {
                    response.setContentType("application/download");
                }

                if (bean.getResourceName() != null) {
                    response.setHeader(
                            "Content-Disposition", "attachment; filename=\"" + bean.getResourceName() + "\"");
                }
            }

            if (contentStream != null) {
View Full Code Here


        }
    }

    public ContentDownloadBean getContentDownloadBean(String path) throws Exception {

        ContentDownloadBean bean = stub.getContentDownloadBean(path);
        return bean;
    }
View Full Code Here

TOP

Related Classes of org.apache.stratos.theme.mgt.stub.registry.resource.stub.beans.xsd.ContentDownloadBean

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.