📄 portletapptype.java
字号:
/*
* 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>
* <complexType name="portlet-appType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="portlet" type="{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}portletType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="custom-portlet-mode" type="{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}custom-portlet-modeType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="custom-window-state" type="{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}custom-window-stateType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="user-attribute" type="{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}user-attributeType" maxOccurs="unbounded" minOccurs="0"/>
* <element name="security-constraint" type="{http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd}security-constraintType" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* <attribute name="version" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" />
* </restriction>
* </complexContent>
* </complexType>
* </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 + -