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

📄 portletapptype.java

📁 portal越来越流行了
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.pluto.descriptors.portlet10;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.pluto.om.portlet.CustomPortletMode;
import org.apache.pluto.om.portlet.CustomWindowState;
import org.apache.pluto.om.portlet.Description;
import org.apache.pluto.om.portlet.DisplayName;
import org.apache.pluto.om.portlet.InitParam;
import org.apache.pluto.om.portlet.PortletDefinition;
import org.apache.pluto.om.portlet.PortletApplicationDefinition;
import org.apache.pluto.om.portlet.PortletInfo;
import org.apache.pluto.om.portlet.Preference;
import org.apache.pluto.om.portlet.Preferences;
import org.apache.pluto.om.portlet.SecurityConstraint;
import org.apache.pluto.om.portlet.SecurityRoleRef;
import org.apache.pluto.om.portlet.Supports;
import org.apache.pluto.om.portlet.UserAttribute;

/**
 * <p>Java class for portlet-appType complex type.</p> <p>The following schema fragment specifies the expected
 * content contained within this class.</p>
 * 
 * <pre>
 * &lt;complexType name=&quot;portlet-appType&quot;&gt;
 *   &lt;complexContent&gt;
 *     &lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}anyType&quot;&gt;
 *       &lt;sequence&gt;
 *         &lt;element name=&quot;portlet&quot; type=&quot;{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}portletType&quot; maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot;/&gt;
 *         &lt;element name=&quot;custom-portlet-mode&quot; type=&quot;{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}custom-portlet-modeType&quot; maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot;/&gt;
 *         &lt;element name=&quot;custom-window-state&quot; type=&quot;{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}custom-window-stateType&quot; maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot;/&gt;
 *         &lt;element name=&quot;user-attribute&quot; type=&quot;{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}user-attributeType&quot; maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot;/&gt;
 *         &lt;element name=&quot;security-constraint&quot; type=&quot;{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}security-constraintType&quot; maxOccurs=&quot;unbounded&quot; minOccurs=&quot;0&quot;/&gt;
 *       &lt;/sequence&gt;
 *       &lt;attribute name=&quot;version&quot; use=&quot;required&quot; type=&quot;{http://www.w3.org/2001/XMLSchema}string&quot; /&gt;
 *       &lt;attribute name=&quot;id&quot; type=&quot;{http://www.w3.org/2001/XMLSchema}string&quot; /&gt;
 *     &lt;/restriction&gt;
 *   &lt;/complexContent&gt;
 * &lt;/complexType&gt;
 * </pre>
 * 
 * @version $Id: PortletAppType.java 706830 2008-10-22 01:05:30Z ate $
 */
@XmlRootElement(name = "portlet-app")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "portlet-appType", propOrder = { "portlet", "customPortletMode", "customWindowState", "userAttribute",
                                                "securityConstraint" })
public class PortletAppType
{
    @XmlElement(name = "portlet")
    List<PortletType> portlet;
    @XmlElement(name = "custom-portlet-mode")
    List<CustomPortletModeType> customPortletMode;
    @XmlElement(name = "custom-window-state")
    List<CustomWindowStateType> customWindowState;
    @XmlElement(name = "user-attribute")
    List<UserAttributeType> userAttribute;
    @XmlElement(name = "security-constraint")
    List<SecurityConstraintType> securityConstraint;
    @XmlAttribute(required = true)
    String version = PortletApplicationDefinition.JSR_168_VERSION;
    
    public PortletAppType()
    {
    }
    
    public PortletAppType(PortletApplicationDefinition app)
    {
        // downgrade
        for (PortletDefinition pd : app.getPortlets())
        {
            if (portlet == null)
            {
                portlet = new ArrayList<PortletType>();
            }
            PortletType pt = new PortletType();
            downgradePortlet(pd, pt);
            portlet.add(pt);            
        }
        for (CustomPortletMode cpm : app.getCustomPortletModes())
        {
            if (customPortletMode == null)
            {
                customPortletMode = new ArrayList<CustomPortletModeType>();
            }
            CustomPortletModeType cpmt = new CustomPortletModeType();
            cpmt.portletMode = cpm.getPortletMode();
            for (Description d : cpm.getDescriptions())
            {
                if (cpmt.description == null)
                {
                    cpmt.description = new ArrayList<DescriptionType>();
                }
                DescriptionType dt = new DescriptionType();
                dt.lang = d.getLang();
                dt.value = d.getDescription();
                cpmt.description.add(dt);
            }
        }
        for (CustomWindowState cws : app.getCustomWindowStates())
        {
            if (customWindowState == null)
            {
                customWindowState = new ArrayList<CustomWindowStateType>();
            }
            CustomWindowStateType cwst = new CustomWindowStateType();
            cwst.windowState = cws.getWindowState();
            for (Description d : cws.getDescriptions())
            {
                if (cwst.description == null)
                {
                    cwst.description = new ArrayList<DescriptionType>();
                }
                DescriptionType dt = new DescriptionType();
                dt.lang = d.getLang();
                dt.value = d.getDescription();
                cwst.description.add(dt);
            }
        }
    }
    
    public PortletApplicationDefinition upgrade()
    {
        PortletApplicationDefinition app = new org.apache.pluto.descriptors.portlet.PortletAppType();
        app.setVersion(version);
        if (portlet != null)
        {
            for (PortletType src : portlet)
            {
                PortletDefinition target = app.addPortlet(src.portletName);
                upgradePortlet(src, target);
            }
        }
        if (customPortletMode != null)
        {
            for (CustomPortletModeType src : customPortletMode)
            {
                CustomPortletMode target = app.addCustomPortletMode(src.portletMode);
                if (src.description != null)
                {
                    for (DescriptionType d : src.description)
                    {
                        Description desc = target.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (customWindowState != null)
        {
            for (CustomWindowStateType src : customWindowState)
            {
                CustomWindowState target = app.addCustomWindowState(src.windowState);
                if (src.description != null)
                {
                    for (DescriptionType d : src.description)
                    {
                        Description desc = target.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (userAttribute != null)
        {
            for (UserAttributeType src : userAttribute)
            {
                UserAttribute target = app.addUserAttribute(src.name);
                if (src.description != null)
                {
                    for (DescriptionType d : src.description)
                    {
                        Description desc = target.addDescription(d.lang);
                        desc.setDescription(d.value);
                    }
                }
            }
        }
        if (securityConstraint != null)
        {
            for (SecurityConstraintType src : securityConstraint)
            {
                SecurityConstraint target = app.addSecurityConstraint(src.userDataConstraint.transportGuarantee);
                if (src.displayName != null)
                {
                    for (DisplayNameType d : src.displayName)
                    {
                        DisplayName dname = target.addDisplayName(d.lang);
                        dname.setDisplayName(d.value);
                    }
                }
                if (src.portletCollection != null && src.portletCollection.portletName != null)
                {
                    for (String pname : src.portletCollection.portletName)
                    {
                        target.addPortletName(pname);
                    }
                }
            }
        }
        return app;
    }
    
    private void downgradePortlet(PortletDefinition src, PortletType target)
    {
        for (Description d : src.getDescriptions())
        {
            if (target.description == null)
            {
                target.description = new ArrayList<DescriptionType>();
            }
            DescriptionType dt = new DescriptionType();

⌨️ 快捷键说明

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