⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portletapptype.java

📁 portal越来越流行了
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            dt.lang = d.getLang();
            dt.value = d.getDescription();
            target.description.add(dt);
        }
        for (DisplayName d : src.getDisplayNames())
        {
            if (target.displayName == null)
            {
                target.displayName = new ArrayList<DisplayNameType>();
            }
            DisplayNameType dnt = new DisplayNameType();
            dnt.lang = d.getLang();
            dnt.value = d.getDisplayName();
            target.displayName.add(dnt);
        }
        target.portletClass = src.getPortletClass();
        if (src.getExpirationCache() != 0)
        {
            target.expirationCache = new Integer(src.getExpirationCache());
        }
        for (InitParam p : src.getInitParams())
        {
            if (target.initParam == null)
            {
                target.initParam = new ArrayList<InitParamType>();
            }
            InitParamType pt = new InitParamType();
            pt.name = p.getParamName();
            pt.value = p.getParamValue();
            for (Description d : p.getDescriptions())
            {
                if (pt.description == null)
                {
                    pt.description = new ArrayList<DescriptionType>();
                }
                DescriptionType dt = new DescriptionType();
                dt.lang = d.getLang();
                dt.value = d.getDescription();
                pt.description.add(dt);
            }
            target.initParam.add(pt);
        }
        for (Supports s : src.getSupports())
        {
            if (target.supports == null)
            {
                target.supports = new ArrayList<SupportsType>();
            }
            SupportsType st = new SupportsType();
            st.mimeType = s.getMimeType();
            for (String name : s.getPortletModes())
            {
                if (st.portletMode == null)
                {
                    st.portletMode = new ArrayList<String>();
                }
                st.portletMode.add(name);
            }
            target.supports.add(st);
        }
        for (String lang : src.getSupportedLocales())
        {
            if (target.supportedLocale == null)
            {
                target.supportedLocale = new ArrayList<String>();
            }
            target.supportedLocale.add(lang);
        }
        target.resourceBundle = src.getResourceBundle();
        PortletInfoType pit = new PortletInfoType();
        pit.title = src.getPortletInfo().getTitle();
        pit.shortTitle = src.getPortletInfo().getShortTitle();
        pit.keywords = src.getPortletInfo().getKeywords();
        if (pit.title != null || pit.shortTitle != null || pit.keywords != null)
        {
            target.portletInfo = pit;
        }
        PortletPreferencesType ppt = new PortletPreferencesType();
        ppt.preferencesValidator = src.getPortletPreferences().getPreferencesValidator();
        for (Preference p : src.getPortletPreferences().getPortletPreferences())
        {
            if (ppt.preference == null)
            {
                ppt.preference = new ArrayList<PreferenceType>();                
            }
            PreferenceType pt = new PreferenceType();
            pt.name = p.getName();
            pt.readOnly = p.isReadOnly() ? Boolean.TRUE : null;
            for (String value : p.getValues())
            {
                if (pt.value == null)
                {
                    pt.value = new ArrayList<String>();
                }
                pt.value.add(value);
            }
            ppt.preference.add(pt);
        }
        if (ppt.preferencesValidator != null || ppt.preference != null)
        {
            target.portletPreferences = ppt;
        }
        for (SecurityRoleRef srr : src.getSecurityRoleRefs())
        {
            if (target.securityRoleRef == null)
            {
                target.securityRoleRef = new ArrayList<SecurityRoleRefType>();                
            }
            SecurityRoleRefType srrt = new SecurityRoleRefType();
            srrt.roleName = srr.getRoleName();
            srrt.roleLink = srr.getRoleLink();
            for (Description d : srr.getDescriptions())
            {
                if (srrt.description == null)
                {
                    srrt.description = new ArrayList<DescriptionType>();
                }
                DescriptionType dt = new DescriptionType();
                dt.lang = d.getLang();
                dt.value = d.getDescription();
                srrt.description.add(dt);
            }
            target.securityRoleRef.add(srrt);
        }
    }
    
    private void upgradePortlet(PortletType src, PortletDefinition target)
    {
        if (src.description != null)
        {
            for (DescriptionType d : src.description)
            {
                Description desc = target.addDescription(d.lang);
                desc.setDescription(d.value);
            }
        }
        if (src.displayName != null)
        {
            for (DisplayNameType d : src.displayName)
            {
                DisplayName dname = target.addDisplayName(d.lang);
                dname.setDisplayName(d.value);
            }
        }
        target.setPortletClass(src.portletClass);
        if (src.expirationCache != null)
        {
            target.setExpirationCache(src.expirationCache.intValue());
        }
        if (src.initParam != null)
        {
            for (InitParamType p : src.initParam)
            {
                InitParam param = target.addInitParam(p.name);
                param.setParamValue(p.value);
                if (p.description != null)
                {
                    for (DescriptionType d : p.description)
                    {
                        Description desc = param.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (src.supports != null)
        {
            for (SupportsType st : src.supports)
            {
                Supports s = target.addSupports(st.mimeType);
                if (st.portletMode != null)
                {
                    for (String mode : st.portletMode)
                    {
                        s.addPortletMode(mode);
                    }
                }
            }
        }
        if (src.supportedLocale != null)
        {
            for (String lang : src.supportedLocale)
            {
                target.addSupportedLocale(lang);
            }
        }
        target.setResourceBundle(src.resourceBundle);
        if (src.portletInfo != null)
        {
            PortletInfo pi = target.getPortletInfo();
            pi.setTitle(src.portletInfo.title);
            pi.setShortTitle(src.portletInfo.shortTitle);
            pi.setKeywords(src.portletInfo.keywords);
        }
        if (src.portletPreferences != null)
        {
            Preferences prefs = target.getPortletPreferences();
            prefs.setPreferencesValidator(src.portletPreferences.preferencesValidator);
            if (src.portletPreferences.preference != null)
            {
                for (PreferenceType p : src.portletPreferences.preference)
                {
                    Preference pref = prefs.addPreference(p.name);
                    if (p.value != null)
                    {
                        for (String value : p.value)
                        {
                            pref.addValue(value);
                        }
                    }
                    if (p.readOnly != null)
                    {
                        pref.setReadOnly(p.readOnly.booleanValue());
                    }
                }
            }
        }
        if (src.securityRoleRef != null)
        {
            for (SecurityRoleRefType rrt : src.securityRoleRef)
            {
                SecurityRoleRef srr = target.addSecurityRoleRef(rrt.roleName);
                srr.setRoleLink(rrt.roleLink);
                if (rrt.description != null)
                {
                    for (DescriptionType d : rrt.description)
                    {
                        Description desc = srr.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -