Examples of MediaFileDirectory


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

        log.debug("Importing theme [" + theme.getName() + "] to weblog [" + website.getName() + "]");

        WeblogManager wmgr = roller.getWeblogManager();
        MediaFileManager fileMgr = roller.getMediaFileManager();
       
        MediaFileDirectory root = fileMgr.getMediaFileRootDirectory(website);
        log.warn("Weblog " + website.getHandle() + " does not have a root MediaFile directory");

        Set importedActionTemplates = new HashSet();
        ThemeTemplate themeTemplate = null;
        ThemeTemplate stylesheetTemplate = theme.getStylesheet();
        Iterator iter = theme.getTemplates().iterator();
        while (iter.hasNext()) {
            themeTemplate = (ThemeTemplate) iter.next();

            WeblogTemplate template = null;

            // if template is an action, lookup by action
            if (themeTemplate.getAction() != null
                    && !themeTemplate.getAction().equals(WeblogTemplate.ACTION_CUSTOM)) {
                importedActionTemplates.add(themeTemplate.getAction());
                template = wmgr.getPageByAction(website, themeTemplate.getAction());

                // otherwise, lookup by name
            } else {
                template = wmgr.getPageByName(website, themeTemplate.getName());
            }

            // Weblog does not have this template, so create it.
            boolean newTmpl = false;
            if (template == null) {
                template = new WeblogTemplate();
                template.setWebsite(website);
                newTmpl = true;
            }

            // TODO: fix conflict situation
            // it's possible that someone has defined a theme template which
            // matches 2 existing templates, 1 by action, the other by name

            // update template attributes
            // NOTE: we don't want to copy the template data for an existing stylesheet
            if (newTmpl || !themeTemplate.equals(stylesheetTemplate)) {
                template.setAction(themeTemplate.getAction());
                template.setName(themeTemplate.getName());
                template.setDescription(themeTemplate.getDescription());
                template.setLink(themeTemplate.getLink());
                template.setContents(themeTemplate.getContents());
                template.setHidden(themeTemplate.isHidden());
                template.setNavbar(themeTemplate.isNavbar());
                template.setTemplateLanguage(themeTemplate.getTemplateLanguage());
                // NOTE: decorators are deprecated starting in 4.0
                template.setDecoratorName(null);
                template.setLastModified(new Date());

                // save it
                wmgr.savePage(template);
            }
        }

        // now, see if the weblog has left over action templates that
        // need to be deleted because they aren't in their new theme
        for (int i = 0; i < WeblogTemplate.ACTIONS.length; i++) {
            String action = WeblogTemplate.ACTIONS[i];

            // if we didn't import this action then see if it should be deleted
            if (!importedActionTemplates.contains(action)) {
                WeblogTemplate toDelete = wmgr.getPageByAction(website, action);
                if (toDelete != null) {
                    log.debug("Removing stale action template " + toDelete.getId());
                    wmgr.removePage(toDelete);
                }
            }
        }


        // always update this weblog's theme and customStylesheet, then save
        website.setEditorTheme(WeblogTheme.CUSTOM);
        if (theme.getStylesheet() != null) {
            website.setCustomStylesheetPath(theme.getStylesheet().getLink());
        }
        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);
View Full Code Here

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

        if (parentDirectory.hasDirectory(newDirName)) {
            throw new WebloggerException("Directory exists");
        }

        MediaFileDirectory newDirectory = parentDirectory.createNewDirectory(newDirName);

        // update weblog last modified date.  date updated by saveWeblog()
        roller.getWeblogManager().saveWeblog(newDirectory.getWeblog());

        return newDirectory;
    }
View Full Code Here

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

            throw new WebloggerException("Invalid path!");
        }

        int lastPathIndex = path.lastIndexOf("/");

        MediaFileDirectory newDirectory = null;
        if (lastPathIndex == -1) {

            // Directory needs to be created under root
            MediaFileDirectory root = getMediaFileRootDirectory(weblog);

            if (root.hasDirectory(path)) {
                throw new WebloggerException("Directory exists");
            } else {
                log.debug("    Created dir under ROOT");
                newDirectory = root.createNewDirectory(path);
            }

        } else {

            boolean created = false;

            MediaFileDirectory base = getMediaFileRootDirectory(weblog);
            String token = null;
            String pathpart = "";
            StringTokenizer toker = new StringTokenizer(path, "/");
            while (toker.hasMoreTokens()) {
                token = toker.nextToken();
                if (!pathpart.endsWith("/")) {
                    pathpart += "/" + token;
                } else {
                    pathpart += token;
                }
                MediaFileDirectory possibleBase = getMediaFileDirectoryByPath(weblog, pathpart);
                if (possibleBase == null) {
                    base = base.createNewDirectory(token);
                    log.debug("   Created new directory: " + base.getPath());
                    created = true;
                    roller.flush();
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    public MediaFileDirectory createRootMediaFileDirectory(Weblog weblog)
            throws WebloggerException {
        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root directory", weblog);
        createMediaFileDirectory(rootDirectory);
        return rootDirectory;
    }
View Full Code Here

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

    public MediaFile getMediaFileByPath(Weblog weblog, String path)
            throws WebloggerException {

        // get directory
        String fileName = path;
        MediaFileDirectory mdir = null;
        int slash = path.lastIndexOf("/");
        if (slash > 0) {
            mdir = getMediaFileDirectoryByPath(weblog, path.substring(0, slash));
        } else {
            mdir = getMediaFileRootDirectory(weblog);
        }
        if (slash != -1) {
            fileName = fileName.substring(slash + 1);
        }
        return mdir.getMediaFile(fileName);
    }
View Full Code Here

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

                                    }
                                }

                                try {
                                    // create weblog's mediafile directory if needed
                                    MediaFileDirectory root =
                                            this.getMediaFileRootDirectory(weblog);
                                    if (root == null) {
                                        root = this.createRootMediaFileDirectory(weblog);
                                        roller.flush();
                                    }
View Full Code Here

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

                    upgradeUploadsDir(weblog, user, files[i],
                            newDir.getChildDirectory(files[i].getName()));

                } else {
                    // need to create a new mediafile directory
                    MediaFileDirectory subDir = null;
                    try {
                        subDir = newDir.createNewDirectory(files[i].getName());
                        roller.getMediaFileManager().createMediaFileDirectory(subDir);
                        newDir.getChildDirectories().add(subDir);
                        roller.flush();
View Full Code Here

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

                    int lastSlash = path.lastIndexOf("/");
                    if (lastSlash > -1) {
                        justPath = path.substring(lastSlash);
                    }

                    MediaFileDirectory mdir =
                        fileMgr.getMediaFileDirectoryByPath(website, justPath);

                    if (mdir.hasMediaFile(fileName)) {
                        throw new AtomException("Duplicate file name");
                    }

                    if (path.length() > 0) path = path + File.separator;
                    FileInputStream fis = new FileInputStream(tempFile);
View Full Code Here

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

            link.setRel("alternate");
            link.setType("text/html");
            feed.setAlternateLinks(Collections.singletonList(link));

            MediaFileManager fmgr = roller.getMediaFileManager();
            MediaFileDirectory dir = null;
            if (StringUtils.isNotEmpty(path)) {
                log.debug("Fetching resource collection from weblog " + handle + " at path: " + path);
                dir = fmgr.getMediaFileDirectoryByPath(website, path);
            } else {
                log.debug("Fetching root resource collection from weblog " + handle);
                dir = fmgr.getMediaFileRootDirectory(website);
            }
            Set<MediaFile> files = dir.getMediaFiles();

            SortedSet sortedSet = new TreeSet(new Comparator() {
                public int compare(Object o1, Object o2) {
                    MediaFile f1 = (MediaFile)o1;
                    MediaFile f2 = (MediaFile)o2;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.