Package org.jahia.data.templates

Examples of org.jahia.data.templates.JahiaTemplatesPackage


            labelNodeType = new ConcurrentHashMap<String, String>();
            tooltipsByNodeType.put(locale,labelNodeType);
        }
        String label = labelNodeType.get(nodeType.getName());
        if(label==null) {
            JahiaTemplatesPackage aPackage = nodeType.getTemplatePackage();
            label = new JahiaResourceBundle(nodeType.getResourceBundleId(), locale, aPackage!=null ? aPackage.getName(): null, JahiaTemplatesRBLoader
                    .getInstance(Thread.currentThread().getContextClassLoader(), null)).getString(
                    getResourceBundleKey(nodeType)+".ui.tooltip", "");
            labelNodeType.put(nodeType.getName(), label);
        }
        return label;
View Full Code Here


     * Returns the corresponding template set name of this virtual site.
     *
     * @return the corresponding template set name of this virtual site
     */
    public String getTemplatePackageName() {
        JahiaTemplatesPackage templatePackageByFileName = ServicesRegistry.getInstance().getJahiaTemplateManagerService()
                .getTemplatePackageByFileName(getTemplateFolder());
        if (templatePackageByFileName == null ) {
            return null;
        }
        return templatePackageByFileName.getName();
    }
View Full Code Here

    public static String getIconsFolder(final ExtendedNodeType primaryNodeType) throws RepositoryException {
        String folder = primaryNodeType.getSystemId();
        if (folder.startsWith("system-")) {
            folder = "assets";
        } else {
            final JahiaTemplatesPackage aPackage =
                    ServicesRegistry.getInstance().getJahiaTemplateManagerService().getTemplatePackage(folder);
            if (aPackage != null) {
                folder = aPackage.getRootFolder().equals("default")?"assets":aPackage.getRootFolder();
            } else {
                folder = "assets"; // todo handle portlets
            }
        }
        folder += "/icons/";
View Full Code Here

                }

                if (!remaining.isEmpty()) {
                    List<JahiaTemplatesPackage> remainingPackages = new LinkedList<JahiaTemplatesPackage>();
                    for (File pkgFolder : remaining) {
                        JahiaTemplatesPackage packageHandler = getPackage(pkgFolder);
                        if (packageHandler != null) {
                            remainingPackages.add(packageHandler);
                        }
                    }
                    for (JahiaTemplatesPackage pack : getOrderedPackages(remainingPackages).values()) {
View Full Code Here

            site = siteService.getSite(siteId);
        } catch (JahiaException e) {
            logger.error("Unable to lookup the site for the ID=" + siteId, e);
        }
        if (site != null) {
            JahiaTemplatesPackage pkg = getTemplatePackage(site
                    .getTemplatePackageName());
            if (pkg != null && pkg.getTemplateMap().containsKey(templateName)) {
                displayName = pkg.lookupTemplate(templateName).getDisplayName();
            }
        }
        if (null == displayName) {
            logger
                    .warn("Unable to lookup display name for the template named '"
View Full Code Here

            site = siteService.getSite(siteId);
        } catch (JahiaException e) {
            logger.error("Unable to lookup the site for the ID=" + siteId, e);
        }
        if (site != null) {
            JahiaTemplatesPackage pkg = getTemplatePackage(site
                    .getTemplatePackageName());
            if (pkg != null && pkg.getTemplateMap().containsKey(templateName)) {
                description = pkg.lookupTemplate(templateName).getDescription();
            }
        }
        return description;
    }
View Full Code Here

     * @param siteId the ID of the site
     * @return the requested template package or <code>null</code> if the
     *         package can not be found in the registry
     */
    public JahiaTemplatesPackage getTemplatePackage(int siteId) {
        JahiaTemplatesPackage pkg = null;
        JahiaSite site = null;
        try {
            site = siteService.getSite(siteId);
        } catch (JahiaException e) {
            logger.error("Unablke to find site by ID=" + siteId, e);
View Full Code Here

        return templatePackageRegistry.lookupByFileName(fileName);
    }

    public String getTemplateSourcePath(String templateName, int siteId) {
        String sourcePath = null;
        JahiaTemplatesPackage pkg = getTemplatePackage(siteId);
        if (pkg != null && pkg.getTemplateMap().containsKey(templateName)) {
            sourcePath = pkg.lookupTemplate(templateName).getFilePath();
        }
        if (null == sourcePath) {
            logger
                    .warn("Unable to lookup the source path for the template named '"
                            + templateName + "' in the site with ID=" + siteId);
View Full Code Here

    private static JahiaTemplatesPackage postProcess(
            JahiaTemplatesPackage templatePackage, File file) {
       
        long timer = System.currentTimeMillis();
        if (templatePackage == null) {
            templatePackage = new JahiaTemplatesPackage();
        }

        templatePackage.setFilePath(file.getPath());

        if (StringUtils.isEmpty(templatePackage.getName())) {
View Full Code Here

     *
     * @param file the package file to read
     */
    private static JahiaTemplatesPackage read(File file) {

        JahiaTemplatesPackage templatePackage = new JahiaTemplatesPackage();
        // extract data from the META-INF/MANIFEST.MF file
        try {
            File manifestFile = new File(file, "META-INF/MANIFEST.MF");
            if (manifestFile.exists()) {
                InputStream manifestStream = new BufferedInputStream(new FileInputStream(manifestFile), 1024);
                Manifest manifest = new Manifest(manifestStream);
                IOUtils.closeQuietly(manifestStream);
                String packageName = (String) manifest.getMainAttributes().get(new Attributes.Name("package-name"));
                String rootFolder = (String) manifest.getMainAttributes().get(new Attributes.Name("root-folder"));
                if (packageName == null) {
                    packageName = file.getName();
                }
                if (rootFolder == null) {
                    rootFolder = file.getName();
                }

                String depends = (String) manifest.getMainAttributes().get(new Attributes.Name("depends"));
                if (depends != null) {
                    String[] dependencies = depends.split(",");
                    for (String dependency : dependencies) {
                        templatePackage.setDepends(dependency.trim());
                    }
                }

                String definitions = (String) manifest.getMainAttributes().get(new Attributes.Name("definitions"));
                if (definitions != null) {
                    String[] defs = definitions.split(",");
                    for (String defFile : defs) {
                        templatePackage.getDefinitionsFiles().add(defFile.trim());
                    }
                }

                String imports = (String) manifest.getMainAttributes().get(new Attributes.Name("initial-imports"));
                if (imports != null) {
                    String[] importFiles = imports.split(",");
                    for (String imp : importFiles) {
                        templatePackage.addInitialImport(imp.trim());
                    }
                }

                templatePackage.setName(packageName);
                templatePackage.setRootFolder(rootFolder);

                String moduleType = (String) manifest.getMainAttributes().get(new Attributes.Name("module-type"));
                if (moduleType != null) {
                    templatePackage.setModuleType(moduleType);
                }
            }
        } catch (IOException ioe) {
            logger
                    .warn(
View Full Code Here

TOP

Related Classes of org.jahia.data.templates.JahiaTemplatesPackage

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.