Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.ThemeResource


            }
            if (pathInfo.length > 1) {
                try {                                       
                    // Parse pathinfo to determine file path
                    String filePath = filePathFromPathInfo(pathInfo);
                    ThemeResource resource = fmgr.getFile(website, filePath);                   
                    return new AtomMediaResource(resource);
                } catch (Exception e) {
                    throw new AtomException(
                        "Unexpected error during file upload", e);
                }
View Full Code Here


                    if (path.length() > 0) path = path + File.separator;
                    FileInputStream fis = new FileInputStream(tempFile)
                    fmgr.saveFile(website, path + fileName, contentType, tempFile.length(), fis);
                    fis.close();
                   
                    ThemeResource resource = fmgr.getFile(website, path + fileName);
                   
                    log.debug("Exiting");
                    return createAtomResourceEntry(website, resource);

                } catch (FileIOException fie) {
View Full Code Here

                                       
                    // Parse pathinfo to determine file path
                    String path = filePathFromPathInfo(pathInfo);
                   
                    // Attempt to load file, to ensure it exists
                    ThemeResource resource = fmgr.getFile(website, path);                   
                   
                    FileInputStream fis = new FileInputStream(tempFile)
                    fmgr.saveFile(website, path, contentType, tempFile.length(), fis);
                    fis.close();
                   
View Full Code Here

        InputStream resourceStream = null;
       
        // first, see if we have a preview theme to operate from
        if(!StringUtils.isEmpty(resourceRequest.getThemeName())) {
            Theme theme = resourceRequest.getTheme();
            ThemeResource resource = theme.getResource(resourceRequest.getResourcePath());
            if(resource != null) {
                resourceLastMod = resource.getLastModified();
                resourceStream = resource.getInputStream();
            }
        }
       
        // second, see if resource comes from weblog's configured shared theme
        if(resourceStream == null) {
            try {
                WeblogTheme weblogTheme = weblog.getTheme();
                if(weblogTheme != null) {
                    ThemeResource resource = weblogTheme.getResource(resourceRequest.getResourcePath());
                    if(resource != null) {
                        resourceLastMod = resource.getLastModified();
                        resourceStream = resource.getInputStream();
                    }
                }
            } catch (Exception ex) {
                // hmmm, some kind of error getting theme.  that's an error.
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

       
        // first see if resource comes from weblog's shared theme
        try {
            WeblogTheme weblogTheme = weblog.getTheme();
            if(weblogTheme != null) {
                ThemeResource resource = weblogTheme.getResource(resourceRequest.getResourcePath());
                if(resource != null) {
                    resourceLastMod = resource.getLastModified();
                    resourceStream = resource.getInputStream();
                }
            }
        } catch (Exception ex) {
            // hmmm, some kind of error getting theme.  that's an error.
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
View Full Code Here

       
        // try looking up selected theme
        try {
            ThemeManager tmgr = WebloggerFactory.getWeblogger().getThemeManager();
            SharedTheme previewTheme = tmgr.getTheme(theme);
            ThemeResource previewImage = previewTheme.getPreviewImage();
            if(previewImage != null) {
                previewImagePath = previewImage.getPath();
                resourceLastMod = previewImage.getLastModified();
                resourceStream = previewImage.getInputStream();
            }
        } catch (Exception ex) {
            log.debug("error looking up preview image", ex);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
View Full Code Here

    public ThemeResource getResource(String path) {
       
        if(path == null)
            return null;
       
        ThemeResource resource = null;
       
        // first check in our shared theme
        resource = this.theme.getResource(path);
       
        // if we didn't find it in our theme then look in weblog uploads
View Full Code Here

   
    /**
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */
    public int compareTo(Object o) {
        ThemeResource other = (ThemeResource) o;
        return getPath().compareTo(other.getPath());
    }
View Full Code Here

        wmgr.saveWeblog(website);

        // now lets import all the theme resources
        List resources = theme.getResources();
        Iterator iterat = resources.iterator();
        ThemeResource resource = null;
        while (iterat.hasNext()) {
            resource = (ThemeResource) iterat.next();

            log.debug("Importing resource " + resource.getPath());

            if (resource.isDirectory()) {
                MediaFileDirectory mdir =
                    fileMgr.getMediaFileDirectoryByPath(website, resource.getPath());
                if (mdir == null) {
                    log.debug("    Creating directory: " + resource.getPath());
                    mdir = fileMgr.createMediaFileDirectory(
                      fileMgr.getMediaFileRootDirectory(website), resource.getPath());
                    roller.flush();
                } else {
                    log.debug("    No action: directory already exists");
                }

            } else {
                String resourcePath = resource.getPath();

                MediaFileDirectory mdir = null;
                String justName = null;
                String justPath = null;

                if (resourcePath.indexOf("/") == -1) {
                    mdir = fileMgr.getMediaFileRootDirectory(website);
                    justPath = "";
                    justName = resourcePath;
                   
                } else {
                    justPath = resourcePath.substring(0, resourcePath.lastIndexOf("/"));
                    if (!justPath.startsWith("/")) justPath = "/" + justPath;
                    justName = resourcePath.substring(resourcePath.lastIndexOf("/") + 1);
                    mdir = fileMgr.getMediaFileDirectoryByPath(website, justPath);
                    if (mdir == null) {
                        log.debug("    Creating directory: " + justPath);
                        mdir = fileMgr.createMediaFileDirectoryByPath(website, justPath);
                        roller.flush();
                    }
                }

                MediaFile oldmf = fileMgr.getMediaFileByOriginalPath(website, justPath + "/" + justName);
                if (oldmf != null) {
                    fileMgr.removeMediaFile(website, oldmf);
                }

                // save file without file-type, quota checks, etc.
                InputStream is = resource.getInputStream();
                MediaFile mf = new MediaFile();
                mf.setDirectory(mdir);
                mf.setWeblog(website);
                mf.setName(justName);
                mf.setOriginalPath(justPath + "/" + justName);
                mf.setContentType(map.getContentType(justName));
                mf.setInputStream(is);
                mf.setLength(resource.getLength());

                log.debug("    Saving file: " + justName);
                log.debug("    Saviving in directory = " + mf.getDirectory());
                RollerMessages errors = new RollerMessages();
                fileMgr.createMediaFile(website, mf, errors);
                try {
                    resource.getInputStream().close();
                } catch (IOException ex) {
                    errors.addError("error.closingStream");
                    log.debug("ERROR closing inputstream");
                }
                if (errors.getErrorCount() > 0) {
View Full Code Here

     * Lookup the specified resource by path.
     * Returns null if the resource cannot be found.
     */
    public ThemeResource getResource(String path) {
       
        ThemeResource resource = null;
       
        try {
            MediaFileManager mmgr =
                WebloggerFactory.getWeblogger().getMediaFileManager();
            MediaFile mf = mmgr.getMediaFileByOriginalPath(
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.ThemeResource

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.