Package org.apache.roller.weblogger.pojos

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


    }
   
   
    public class WeblogResourceComparator implements Comparator {
        public int compare(Object o1, Object o2) {
            ThemeResource r1 = (ThemeResource)o1;
            ThemeResource r2 = (ThemeResource)o2;
           
            // consider directories so they go to the top of the list
            if(r1.isDirectory() && r2.isDirectory()) {
                // if we have 2 directories then just go by name
                return r1.getPath().compareTo(r2.getPath());
            } else if(r1.isDirectory()) {
                // directories go before files
                return -1;
            } else if(r2.isDirectory()) {
                // directories go before files
                return 1;
            } else {
                // if we have 2 files then just go by name
                return r1.getPath().compareTo(r2.getPath());
            }
        }
View Full Code Here


                // if we have 2 files then just go by name
                return r1.getPath().compareTo(r2.getPath());
            }
        }
        public boolean equals(Object o1, Object o2) {
            ThemeResource r1 = (ThemeResource)o1;
            ThemeResource r2 = (ThemeResource)o2;
           
            // need to be same type to be equals, i.e both files or directories
            if((r1.isDirectory() && !r2.isDirectory()) ||
                    (r1.isFile() && !r2.isFile())) {
                return false;
            }
           
            // after that it's just a matter of comparing paths
            return r1.getPath().equals(r2.getPath());
        }
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

     * Lookup the specified resource by path.
     * Returns null if the resource cannot be found.
     */
    public ThemeResource getResource(String path) {
       
        ThemeResource resource = null;
       
        try {
            FileManager fileMgr = WebloggerFactory.getWeblogger().getFileManager();
            resource = fileMgr.getFile(this.weblog, path);
        } catch (WebloggerException ex) {
View Full Code Here

            // now lets import all the theme resources
            FileManager fileMgr = roller.getFileManager();
           
            List resources = theme.getResources();
            Iterator iterat = resources.iterator();
            ThemeResource resource = null;
            while ( iterat.hasNext() ) {
                resource = (ThemeResource) iterat.next();
               
                log.debug("Importing resource to "+resource.getPath());
               
                try {
                    if(resource.isDirectory()) {
                        fileMgr.createDirectory(website, resource.getPath());
                    } else {
                        // save file without file-type, quota checks, etc.
                        fileMgr.saveFile(website, resource.getPath(), "text/plain",
                                resource.getLength(), resource.getInputStream(), false);
                    }
                } catch (Exception ex) {
                    log.info(ex);
                }
            }
View Full Code Here

            throw new FilePathException("Invalid path ["+path+"], "+
                    "path is not a directory.");
        }
       
        // everything looks good, list contents
        ThemeResource dir = new WeblogResourceFile(weblog, path, dirFile);
       
        return dir.getChildren();
    }
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);
                return;
            }
        }
       
        // if not from theme then see if resource is in weblog's upload dir
        if(resourceStream == null) {
            try {
                FileManager fileMgr = WebloggerFactory.getWeblogger().getFileManager();
                ThemeResource resource = fileMgr.getFile(weblog,
                        resourceRequest.getResourcePath());
                resourceLastMod = resource.getLastModified();
                resourceStream = resource.getInputStream();
            } catch (Exception ex) {
                // still not found? then we don't have it, 404.
                log.debug("Unable to get resource", ex);
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
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);
            return;
        }
       
        // if not from theme then see if resource is in weblog's upload dir
        if(resourceStream == null) {
            try {
                FileManager fileMgr = WebloggerFactory.getWeblogger().getFileManager();
                ThemeResource resource = fileMgr.getFile(weblog,
                        resourceRequest.getResourcePath());
                resourceLastMod = resource.getLastModified();
                resourceStream = resource.getInputStream();
            } catch (Exception ex) {
                // still not found? then we don't have it, 404.
                log.debug("Unable to get resource", ex);
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
View Full Code Here

            FileManager fmgr = roller.getFileManager();
            ThemeResource[] files = fmgr.getFiles(website, path);

            SortedSet sortedSet = new TreeSet(new Comparator() {
                public int compare(Object o1, Object o2) {
                    ThemeResource f1 = (ThemeResource)o1;
                    ThemeResource f2 = (ThemeResource)o2;
                    if (f1.getLastModified() < f2.getLastModified()) return 1;
                    else if (f1.getLastModified() == f2.getLastModified()) return 0;
                    else return -1;
                }
            });
                                   
            if (files != null && start < files.length) { 
View Full Code Here

                    String filePath = filePathFromPathInfo(pathInfo);
                    filePath = filePath.substring(0, filePath.length() - ".media-link".length());
                    String handle = pathInfo[0];
                    Weblog website =
                        roller.getUserManager().getWebsiteByHandle(handle);                   
                    ThemeResource resource =
                        roller.getFileManager().getFile(website, filePath);
                   
                    log.debug("Exiting");
                    if (resource != null) return createAtomResourceEntry(website, resource);
                }
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.