You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2015/01/28 15:42:40 UTC
[05/14] portals-pluto git commit: work towards enabling v3 deployment
descriptor
work towards enabling v3 deployment descriptor
Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/a8bed7fb
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/a8bed7fb
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/a8bed7fb
Branch: refs/heads/V3Prototype
Commit: a8bed7fbd333a5d97506c802ec621b679ef9bb7a
Parents: 49072ab
Author: Scott Nicklous <ms...@apache.org>
Authored: Tue Jan 27 22:14:22 2015 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Tue Jan 27 22:14:22 2015 +0100
----------------------------------------------------------------------
.../impl/PortletAppDescriptorServiceImpl.java | 726 +++++++-------
.../impl/ContainerRuntimeOptionType.java | 87 --
.../om/portlet/impl/CustomPortletModeType.java | 121 ---
.../om/portlet/impl/CustomWindowStateType.java | 107 ---
.../om/portlet/impl/DescriptionType.java | 120 ---
.../om/portlet/impl/DisplayNameType.java | 122 ---
.../impl/EventDefinitionReferenceType.java | 85 --
.../om/portlet/impl/EventDefinitionType.java | 161 ----
.../om/portlet/impl/FilterMappingType.java | 88 --
.../container/om/portlet/impl/FilterType.java | 214 -----
.../om/portlet/impl/InitParamType.java | 121 ---
.../container/om/portlet/impl/ListenerType.java | 142 ---
.../om/portlet/impl/ObjectFactory.java | 53 --
.../om/portlet/impl/PortletAppType.java | 549 -----------
.../om/portlet/impl/PortletCollectionType.java | 64 --
.../om/portlet/impl/PortletInfoType.java | 92 --
.../om/portlet/impl/PortletPreferencesType.java | 101 --
.../container/om/portlet/impl/PortletType.java | 521 ----------
.../om/portlet/impl/PreferenceType.java | 98 --
.../portlet/impl/PublicRenderParameterType.java | 156 ---
.../om/portlet/impl/SecurityConstraintType.java | 128 ---
.../om/portlet/impl/SecurityRoleRefType.java | 125 ---
.../container/om/portlet/impl/SupportsType.java | 118 ---
.../om/portlet/impl/UserAttributeType.java | 108 ---
.../om/portlet/impl/UserDataConstraintType.java | 107 ---
.../container/om/portlet/impl/package-info.java | 21 -
.../om/portlet10/impl/PortletAppType.java | 942 +++++++++----------
.../impl/ContainerRuntimeOptionType.java | 87 ++
.../portlet20/impl/CustomPortletModeType.java | 121 +++
.../portlet20/impl/CustomWindowStateType.java | 107 +++
.../om/portlet20/impl/DescriptionType.java | 120 +++
.../om/portlet20/impl/DisplayNameType.java | 122 +++
.../impl/EventDefinitionReferenceType.java | 85 ++
.../om/portlet20/impl/EventDefinitionType.java | 161 ++++
.../om/portlet20/impl/FilterMappingType.java | 88 ++
.../container/om/portlet20/impl/FilterType.java | 214 +++++
.../om/portlet20/impl/InitParamType.java | 121 +++
.../om/portlet20/impl/ListenerType.java | 142 +++
.../om/portlet20/impl/ObjectFactory.java | 53 ++
.../om/portlet20/impl/PortletAppType.java | 549 +++++++++++
.../portlet20/impl/PortletCollectionType.java | 64 ++
.../om/portlet20/impl/PortletInfoType.java | 92 ++
.../portlet20/impl/PortletPreferencesType.java | 101 ++
.../om/portlet20/impl/PortletType.java | 521 ++++++++++
.../om/portlet20/impl/PreferenceType.java | 98 ++
.../impl/PublicRenderParameterType.java | 156 +++
.../portlet20/impl/SecurityConstraintType.java | 128 +++
.../om/portlet20/impl/SecurityRoleRefType.java | 125 +++
.../om/portlet20/impl/SupportsType.java | 118 +++
.../om/portlet20/impl/UserAttributeType.java | 108 +++
.../portlet20/impl/UserDataConstraintType.java | 107 +++
.../om/portlet20/impl/package-info.java | 21 +
.../resource/SupportedModesServiceImpl.java | 537 +++++------
.../DefaultPortletPreferencesService.java | 520 +++++-----
.../container/ResourceBundleFactoryTest.java | 264 +++---
55 files changed, 5104 insertions(+), 5103 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
index 09a501b..397df22 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
@@ -1,363 +1,363 @@
-/*
- * 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.container.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.regex.Pattern;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.helpers.DefaultValidationEventHandler;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.XMLEvent;
-import javax.xml.stream.util.StreamReaderDelegate;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.pluto.container.PortletAppDescriptorService;
-import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * JAXB implementation of the xml2java binding
- * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
- */
-
-public class PortletAppDescriptorServiceImpl implements PortletAppDescriptorService{
-
- private static class WebAppDtdEntityResolver implements EntityResolver {
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
- {
- if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
- {
- return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
- }
- return null;
- }
- }
-
- private static class NamespaceOverridingStreamReaderDelegate extends StreamReaderDelegate {
- private String adjustedNamespaceURI = null;
-
- private NamespaceOverridingStreamReaderDelegate(XMLStreamReader reader) {
- super(reader);
- }
-
- @Override
- public int next() throws XMLStreamException
- {
- int eventCode = super.next();
- if (eventCode == XMLEvent.START_ELEMENT && "portlet-app".equals(getLocalName()))
- {
- String version = getAttributeValue(null, "version");
- if ("1.0".equals(version))
- {
- adjustedNamespaceURI = "http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd";
- }
- else if ("2.0".equals(version))
- {
- adjustedNamespaceURI = "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd";
- }
- }
- return eventCode;
- }
-
- @Override
- public String getNamespaceURI()
- {
- String namespaceURI = super.getNamespaceURI();
- return (namespaceURI != null ? namespaceURI : adjustedNamespaceURI);
- }
- }
-
- private static class XPathNamespaceContext implements NamespaceContext
- {
- private String namespaceURI;
- private String prefix;
-
- public XPathNamespaceContext(String prefix)
- {
- this(prefix,XMLConstants.XML_NS_URI);
- }
-
- public XPathNamespaceContext(String prefix, String namespaceURI)
- {
- this.prefix = prefix;
- this.namespaceURI = namespaceURI;
- }
-
- public String getNamespaceURI(String prefix)
- {
- if (prefix == null)
- {
- throw new NullPointerException("Null prefix");
- }
- else if (this.prefix.equals(prefix))
- {
- return namespaceURI;
- }
- else if ("xml".equals(prefix))
- {
- return XMLConstants.XML_NS_URI;
- }
- return XMLConstants.NULL_NS_URI;
- }
-
- public String getPrefix(String namespaceURI)
- {
- throw new UnsupportedOperationException();
- }
-
- public Iterator<?> getPrefixes(String namespaceURI)
- {
- throw new UnsupportedOperationException();
- }
- }
-
- public static Locale convertStringToLocale(String lang)
- {
- if (lang == null)
- {
- return null;
- }
- String country = "";
- String variant = "";
- String[] localeArray = LOCALE_SPLIT.split(lang);
- for (int i = 0; i < localeArray.length; i++)
- {
- if (i == 0)
- {
- lang = localeArray[i];
- }
- else if (i == 1)
- {
- country = localeArray[i];
- }
- else if (i == 2)
- {
- variant = localeArray[i];
- }
- }
- return new Locale(lang, country, variant);
- }
-
- private static final Pattern LOCALE_SPLIT = Pattern.compile("[-|_]");
- private static final String NAMESPACE_PREFIX = "xp";
-
- private final JAXBContext jaxbContext;
-
- public PortletAppDescriptorServiceImpl() {
- ClassLoader containerClassLoader = PortletAppDescriptorServiceImpl.class.getClassLoader();
- try {
- jaxbContext = JAXBContext.newInstance(org.apache.pluto.container.om.portlet10.impl.ObjectFactory.class.getPackage().getName() + ":" +
- org.apache.pluto.container.om.portlet.impl.ObjectFactory.class.getPackage().getName(),
- containerClassLoader);
- }
- catch (JAXBException e) {
- throw new IllegalStateException("Failed to initialize JAXBContext for reading and writing portlet descriptors", e);
- }
- }
-
- /**
- * Read the Web Application Deployment Descriptor.
- *
- * @return WebAppDD instance representing the descriptor.
- * @throws java.io.IOException
- */
- public PortletApplicationDefinition read(String name, String contextPath, InputStream in) throws IOException
- {
- if (in == null) {
- throw new IOException("Cannot read from a null InputStream");
- }
-
- final XMLInputFactory xmlInputFactory = getXmlInputFactory();
-
- //Generate an xml stream reader for the input stream
- final XMLStreamReader streamReader;
- try {
- streamReader = xmlInputFactory.createXMLStreamReader(in);
- }
- catch (XMLStreamException e) {
- final IOException ioe = new IOException(e.getLocalizedMessage());
- ioe.initCause(e);
- throw ioe;
- }
-
- //Wrap the stream reader to make sure the namespace gets setup correctly
- final XMLStreamReader delegatingStreamReader = new NamespaceOverridingStreamReaderDelegate(streamReader);
-
- //Unmarshall the stream
- final JAXBElement<?> app;
- try {
- final Unmarshaller unmarshaller = this.jaxbContext.createUnmarshaller();
- unmarshaller.setEventHandler(new DefaultValidationEventHandler());
- app = (JAXBElement<?>) unmarshaller.unmarshal(delegatingStreamReader);
- }
- catch (JAXBException e) {
- final IOException ioe = new IOException(e.getMessage());
- ioe.initCause(e);
- throw ioe;
- }
-
- PortletApplicationDefinition pad = null;
- if (app.getValue() instanceof org.apache.pluto.container.om.portlet10.impl.PortletAppType)
- {
- pad = ((org.apache.pluto.container.om.portlet10.impl.PortletAppType)app.getValue()).upgrade();
- }
- else
- {
- pad = (PortletApplicationDefinition)app.getValue();
- }
-
- pad.setName(name);
- pad.setContextPath(contextPath);
-
- return pad;
- }
-
- public void mergeWebDescriptor(PortletApplicationDefinition pa, InputStream webDescriptor) throws Exception
- {
- final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- final DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
- builder.setEntityResolver(new WebAppDtdEntityResolver());
-
- final Document document = builder.parse(webDescriptor);
- final Element root = document.getDocumentElement();
- final String namespace = root.getNamespaceURI();
-
- final XPathFactory xpathFactory = XPathFactory.newInstance();
- final XPath xpath = xpathFactory.newXPath();
-
- String prefix;
- if(namespace!= null && namespace.length() > 0)
- {
- prefix = NAMESPACE_PREFIX+":";
- xpath.setNamespaceContext(new XPathNamespaceContext(NAMESPACE_PREFIX, namespace));
- }
- else
- {
- prefix = XMLConstants.DEFAULT_NS_PREFIX;
- xpath.setNamespaceContext(new XPathNamespaceContext(XMLConstants.DEFAULT_NS_PREFIX));
- }
-
- NodeList nodes;
- NodeList children;
- Element element;
-
- // retrieve locale-encoding-mapping
- nodes = (NodeList)xpath.evaluate("/"+prefix+"web-app/"+prefix+"locale-encoding-mapping-list/"+prefix+"locale-encoding-mapping", document, XPathConstants.NODESET);
- if (nodes != null)
- {
- String locale;
- String encoding;
-
- for (int i = 0, nsize = nodes.getLength(); i < nsize; i++)
- {
- element = (Element)nodes.item(i);
- children = element.getElementsByTagName("locale");
- if (children != null && children.getLength() != 0)
- {
- locale = children.item(0).getTextContent().trim();
- if (locale.length() > 0)
- {
-
- children = element.getElementsByTagName("encoding");
- if (children != null && children.getLength() != 0)
- {
- encoding = children.item(0).getTextContent().trim();
- if (encoding.length() > 0)
- {
- pa.getLocaleEncodingMappings().put(convertStringToLocale(locale), encoding);
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * Write the deployment descriptor.
- * @param app
- * @throws java.io.IOException
- */
- public void write(PortletApplicationDefinition app, OutputStream out) throws IOException {
- try {
- final Object src;
- if (PortletApplicationDefinition.JSR_168_VERSION.equals(app.getVersion()))
- {
- src = new org.apache.pluto.container.om.portlet10.impl.PortletAppType(app);
- }
- else
- {
- src = app;
- }
- final Marshaller marshaller = this.jaxbContext.createMarshaller();
- marshaller.setEventHandler(new DefaultValidationEventHandler());
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- marshaller.marshal(src,out);
- }
- catch (JAXBException jaxbEx){
- final IOException ioe = new IOException(jaxbEx.getMessage());
- ioe.initCause(jaxbEx);
- throw ioe;
- }
- catch(Exception me) {
- final IOException ioe = new IOException(me.getLocalizedMessage());
- ioe.initCause(me);
- throw ioe;
- }
- }
-
- protected XMLInputFactory getXmlInputFactory() {
- final ClassLoader portalClassLoader = this.getClass().getClassLoader();
- final Thread currentThread = Thread.currentThread();
- final ClassLoader contextClassLoader = currentThread.getContextClassLoader();
-
- if (portalClassLoader == contextClassLoader) {
- return XMLInputFactory.newInstance();
- }
-
- try {
- currentThread.setContextClassLoader(portalClassLoader);
- return XMLInputFactory.newInstance();
- }
- finally {
- currentThread.setContextClassLoader(contextClassLoader);
- }
- }
-}
+/*
+ * 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.container.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.regex.Pattern;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.helpers.DefaultValidationEventHandler;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.util.StreamReaderDelegate;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.pluto.container.PortletAppDescriptorService;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * JAXB implementation of the xml2java binding
+ * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
+ */
+
+public class PortletAppDescriptorServiceImpl implements PortletAppDescriptorService{
+
+ private static class WebAppDtdEntityResolver implements EntityResolver {
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ if (systemId.equals("http://java.sun.com/dtd/web-app_2_3.dtd"))
+ {
+ return new InputSource(getClass().getResourceAsStream("web-app_2_3.dtd"));
+ }
+ return null;
+ }
+ }
+
+ private static class NamespaceOverridingStreamReaderDelegate extends StreamReaderDelegate {
+ private String adjustedNamespaceURI = null;
+
+ private NamespaceOverridingStreamReaderDelegate(XMLStreamReader reader) {
+ super(reader);
+ }
+
+ @Override
+ public int next() throws XMLStreamException
+ {
+ int eventCode = super.next();
+ if (eventCode == XMLEvent.START_ELEMENT && "portlet-app".equals(getLocalName()))
+ {
+ String version = getAttributeValue(null, "version");
+ if ("1.0".equals(version))
+ {
+ adjustedNamespaceURI = "http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd";
+ }
+ else if ("2.0".equals(version))
+ {
+ adjustedNamespaceURI = "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd";
+ }
+ }
+ return eventCode;
+ }
+
+ @Override
+ public String getNamespaceURI()
+ {
+ String namespaceURI = super.getNamespaceURI();
+ return (namespaceURI != null ? namespaceURI : adjustedNamespaceURI);
+ }
+ }
+
+ private static class XPathNamespaceContext implements NamespaceContext
+ {
+ private String namespaceURI;
+ private String prefix;
+
+ public XPathNamespaceContext(String prefix)
+ {
+ this(prefix,XMLConstants.XML_NS_URI);
+ }
+
+ public XPathNamespaceContext(String prefix, String namespaceURI)
+ {
+ this.prefix = prefix;
+ this.namespaceURI = namespaceURI;
+ }
+
+ public String getNamespaceURI(String prefix)
+ {
+ if (prefix == null)
+ {
+ throw new NullPointerException("Null prefix");
+ }
+ else if (this.prefix.equals(prefix))
+ {
+ return namespaceURI;
+ }
+ else if ("xml".equals(prefix))
+ {
+ return XMLConstants.XML_NS_URI;
+ }
+ return XMLConstants.NULL_NS_URI;
+ }
+
+ public String getPrefix(String namespaceURI)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Iterator<?> getPrefixes(String namespaceURI)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public static Locale convertStringToLocale(String lang)
+ {
+ if (lang == null)
+ {
+ return null;
+ }
+ String country = "";
+ String variant = "";
+ String[] localeArray = LOCALE_SPLIT.split(lang);
+ for (int i = 0; i < localeArray.length; i++)
+ {
+ if (i == 0)
+ {
+ lang = localeArray[i];
+ }
+ else if (i == 1)
+ {
+ country = localeArray[i];
+ }
+ else if (i == 2)
+ {
+ variant = localeArray[i];
+ }
+ }
+ return new Locale(lang, country, variant);
+ }
+
+ private static final Pattern LOCALE_SPLIT = Pattern.compile("[-|_]");
+ private static final String NAMESPACE_PREFIX = "xp";
+
+ private final JAXBContext jaxbContext;
+
+ public PortletAppDescriptorServiceImpl() {
+ ClassLoader containerClassLoader = PortletAppDescriptorServiceImpl.class.getClassLoader();
+ try {
+ jaxbContext = JAXBContext.newInstance(org.apache.pluto.container.om.portlet10.impl.ObjectFactory.class.getPackage().getName() + ":" +
+ org.apache.pluto.container.om.portlet20.impl.ObjectFactory.class.getPackage().getName(),
+ containerClassLoader);
+ }
+ catch (JAXBException e) {
+ throw new IllegalStateException("Failed to initialize JAXBContext for reading and writing portlet descriptors", e);
+ }
+ }
+
+ /**
+ * Read the Web Application Deployment Descriptor.
+ *
+ * @return WebAppDD instance representing the descriptor.
+ * @throws java.io.IOException
+ */
+ public PortletApplicationDefinition read(String name, String contextPath, InputStream in) throws IOException
+ {
+ if (in == null) {
+ throw new IOException("Cannot read from a null InputStream");
+ }
+
+ final XMLInputFactory xmlInputFactory = getXmlInputFactory();
+
+ //Generate an xml stream reader for the input stream
+ final XMLStreamReader streamReader;
+ try {
+ streamReader = xmlInputFactory.createXMLStreamReader(in);
+ }
+ catch (XMLStreamException e) {
+ final IOException ioe = new IOException(e.getLocalizedMessage());
+ ioe.initCause(e);
+ throw ioe;
+ }
+
+ //Wrap the stream reader to make sure the namespace gets setup correctly
+ final XMLStreamReader delegatingStreamReader = new NamespaceOverridingStreamReaderDelegate(streamReader);
+
+ //Unmarshall the stream
+ final JAXBElement<?> app;
+ try {
+ final Unmarshaller unmarshaller = this.jaxbContext.createUnmarshaller();
+ unmarshaller.setEventHandler(new DefaultValidationEventHandler());
+ app = (JAXBElement<?>) unmarshaller.unmarshal(delegatingStreamReader);
+ }
+ catch (JAXBException e) {
+ final IOException ioe = new IOException(e.getMessage());
+ ioe.initCause(e);
+ throw ioe;
+ }
+
+ PortletApplicationDefinition pad = null;
+ if (app.getValue() instanceof org.apache.pluto.container.om.portlet10.impl.PortletAppType)
+ {
+ pad = ((org.apache.pluto.container.om.portlet10.impl.PortletAppType)app.getValue()).upgrade();
+ }
+ else
+ {
+ pad = (PortletApplicationDefinition)app.getValue();
+ }
+
+ pad.setName(name);
+ pad.setContextPath(contextPath);
+
+ return pad;
+ }
+
+ public void mergeWebDescriptor(PortletApplicationDefinition pa, InputStream webDescriptor) throws Exception
+ {
+ final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ final DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
+ builder.setEntityResolver(new WebAppDtdEntityResolver());
+
+ final Document document = builder.parse(webDescriptor);
+ final Element root = document.getDocumentElement();
+ final String namespace = root.getNamespaceURI();
+
+ final XPathFactory xpathFactory = XPathFactory.newInstance();
+ final XPath xpath = xpathFactory.newXPath();
+
+ String prefix;
+ if(namespace!= null && namespace.length() > 0)
+ {
+ prefix = NAMESPACE_PREFIX+":";
+ xpath.setNamespaceContext(new XPathNamespaceContext(NAMESPACE_PREFIX, namespace));
+ }
+ else
+ {
+ prefix = XMLConstants.DEFAULT_NS_PREFIX;
+ xpath.setNamespaceContext(new XPathNamespaceContext(XMLConstants.DEFAULT_NS_PREFIX));
+ }
+
+ NodeList nodes;
+ NodeList children;
+ Element element;
+
+ // retrieve locale-encoding-mapping
+ nodes = (NodeList)xpath.evaluate("/"+prefix+"web-app/"+prefix+"locale-encoding-mapping-list/"+prefix+"locale-encoding-mapping", document, XPathConstants.NODESET);
+ if (nodes != null)
+ {
+ String locale;
+ String encoding;
+
+ for (int i = 0, nsize = nodes.getLength(); i < nsize; i++)
+ {
+ element = (Element)nodes.item(i);
+ children = element.getElementsByTagName("locale");
+ if (children != null && children.getLength() != 0)
+ {
+ locale = children.item(0).getTextContent().trim();
+ if (locale.length() > 0)
+ {
+
+ children = element.getElementsByTagName("encoding");
+ if (children != null && children.getLength() != 0)
+ {
+ encoding = children.item(0).getTextContent().trim();
+ if (encoding.length() > 0)
+ {
+ pa.getLocaleEncodingMappings().put(convertStringToLocale(locale), encoding);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Write the deployment descriptor.
+ * @param app
+ * @throws java.io.IOException
+ */
+ public void write(PortletApplicationDefinition app, OutputStream out) throws IOException {
+ try {
+ final Object src;
+ if (PortletApplicationDefinition.JSR_168_VERSION.equals(app.getVersion()))
+ {
+ src = new org.apache.pluto.container.om.portlet10.impl.PortletAppType(app);
+ }
+ else
+ {
+ src = app;
+ }
+ final Marshaller marshaller = this.jaxbContext.createMarshaller();
+ marshaller.setEventHandler(new DefaultValidationEventHandler());
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ marshaller.marshal(src,out);
+ }
+ catch (JAXBException jaxbEx){
+ final IOException ioe = new IOException(jaxbEx.getMessage());
+ ioe.initCause(jaxbEx);
+ throw ioe;
+ }
+ catch(Exception me) {
+ final IOException ioe = new IOException(me.getLocalizedMessage());
+ ioe.initCause(me);
+ throw ioe;
+ }
+ }
+
+ protected XMLInputFactory getXmlInputFactory() {
+ final ClassLoader portalClassLoader = this.getClass().getClassLoader();
+ final Thread currentThread = Thread.currentThread();
+ final ClassLoader contextClassLoader = currentThread.getContextClassLoader();
+
+ if (portalClassLoader == contextClassLoader) {
+ return XMLInputFactory.newInstance();
+ }
+
+ try {
+ currentThread.setContextClassLoader(portalClassLoader);
+ return XMLInputFactory.newInstance();
+ }
+ finally {
+ currentThread.setContextClassLoader(contextClassLoader);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ContainerRuntimeOptionType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ContainerRuntimeOptionType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ContainerRuntimeOptionType.java
deleted file mode 100644
index 36e5d66..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ContainerRuntimeOptionType.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-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.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.ContainerRuntimeOption;
-
-/**
- * The container-runtime-option element contains settings for the portlet container that the portlet expects to be
- * honored at runtime. These settings may re-define default portlet container behavior, like the javax.portlet.escapeXml
- * setting that disables XML encoding of URLs produced by the portlet tag library as default. Names with the
- * javax.portlet prefix are reserved for the Java Portlet Specification. Used in: portlet-app, portlet <p>Java class
- * for container-runtime-optionType complex type. <p>The following schema fragment specifies the expected content
- * contained within this class.
- *
- * <pre>
- * <complexType name="container-runtime-optionType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="name" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}nameType"/>
- * <element name="value" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}valueType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "container-runtime-optionType", propOrder = { "name", "value" })
-public class ContainerRuntimeOptionType implements ContainerRuntimeOption
-{
- @XmlElement(required = true)
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String name;
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected List<String> value;
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String value)
- {
- name = value;
- }
-
- public List<String> getValues()
- {
- if (value == null)
- {
- value = new ArrayList<String>();
- }
- return value;
- }
-
- public void addValue(String value)
- {
- getValues().add(value);
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomPortletModeType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomPortletModeType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomPortletModeType.java
deleted file mode 100644
index cc2db06..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomPortletModeType.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.CustomPortletMode;
-import org.apache.pluto.container.om.portlet.Description;
-
-/**
- * A custom portlet mode that one or more portlets in this portlet application supports. If the portal does not need to
- * provide some management functionality for this portlet mode, the portal-managed element needs to be set to "false",
- * otherwise to "true". Default is "true". Used in: portlet-app <p>Java class for custom-portlet-modeType complex type.
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="custom-portlet-modeType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="description" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}descriptionType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="portlet-mode" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}portlet-modeType"/>
- * <element name="portal-managed" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}portal-managedType" minOccurs="0"/>
- * </sequence>
- * <attribute name="id" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "custom-portlet-modeType", propOrder = { "description", "portletMode", "portalManaged" })
-public class CustomPortletModeType implements CustomPortletMode
-{
- @XmlElement(name = "description")
- protected List<DescriptionType> description;
- @XmlElement(name = "portlet-mode", required = true)
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String portletMode;
- @XmlElement(name = "portal-managed")
- protected Boolean portalManaged;
-
- public Description getDescription(Locale locale)
- {
- for (Description d : getDescriptions())
- {
- if (d.getLocale().equals(locale))
- {
- return d;
- }
- }
- return null;
- }
-
- public List<? extends Description> getDescriptions()
- {
- if (description == null)
- {
- description = new ArrayList<DescriptionType>();
- }
- return description;
- }
-
- public Description addDescription(String lang)
- {
- DescriptionType d = new DescriptionType();
- d.setLang(lang);
- if (getDescription(d.getLocale()) != null)
- {
- throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
- }
- getDescriptions();
- description.add(d);
- return d;
- }
-
- public String getPortletMode()
- {
- return portletMode != null ? portletMode.toLowerCase() : null;
- }
-
- public void setPortletMode(String value)
- {
- portletMode = value.toLowerCase();
- }
-
- public boolean isPortalManaged()
- {
- return portalManaged != null ? portalManaged.booleanValue() : true;
- }
-
- public void setPortalManaged(boolean value)
- {
- portalManaged = value ? Boolean.TRUE : Boolean.FALSE;
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomWindowStateType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomWindowStateType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomWindowStateType.java
deleted file mode 100644
index 0454c0b..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/CustomWindowStateType.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.CustomWindowState;
-import org.apache.pluto.container.om.portlet.Description;
-
-/**
- * A custom window state that one or more portlets in this portlet application supports. Used in: portlet-app <p>Java
- * class for custom-window-stateType complex type. <p>The following schema fragment specifies the expected content
- * contained within this class.
- *
- * <pre>
- * <complexType name="custom-window-stateType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="description" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}descriptionType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="window-state" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}window-stateType"/>
- * </sequence>
- * <attribute name="id" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "custom-window-stateType", propOrder = { "description", "windowState" })
-public class CustomWindowStateType implements CustomWindowState
-{
- @XmlElement(name = "description")
- protected List<DescriptionType> description;
- @XmlElement(name = "window-state", required = true)
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String windowState;
-
- public Description getDescription(Locale locale)
- {
- for (Description d : getDescriptions())
- {
- if (d.getLocale().equals(locale))
- {
- return d;
- }
- }
- return null;
- }
-
- public List<? extends Description> getDescriptions()
- {
- if (description == null)
- {
- description = new ArrayList<DescriptionType>();
- }
- return description;
- }
-
- public Description addDescription(String lang)
- {
- DescriptionType d = new DescriptionType();
- d.setLang(lang);
- if (getDescription(d.getLocale()) != null)
- {
- throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
- }
- getDescriptions();
- description.add(d);
- return d;
- }
-
- public String getWindowState()
- {
- return windowState != null ? windowState.toLowerCase() : null;
- }
-
- public void setWindowState(String value)
- {
- windowState = value.toLowerCase();
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DescriptionType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DescriptionType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DescriptionType.java
deleted file mode 100644
index 5e8613f..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DescriptionType.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.Description;
-
-/**
- * The description element is used to provide text describing the parent element. The description element should include
- * any information that the portlet application war file producer wants to provide to the consumer of the portlet
- * application war file (i.e., to the Deployer). Typically, the tools used by the portlet application war file consumer
- * will display the description when processing the parent element that contains the description. It has an optional
- * attribute xml:lang to indicate which language is used in the description according to RFC 1766
- * (http://www.ietf.org/rfc/rfc1766.txt). The default value of this attribute is English(“en”). Used in: init-param,
- * portlet, portlet-app, security-role <p>Java class for descriptionType complex type. <p>The following schema
- * fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="descriptionType">
- * <simpleContent>
- * <extension base="<http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd>string">
- * <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/>
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "descriptionType", propOrder = { "value" })
-public class DescriptionType implements Description
-{
- @XmlValue
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String value;
- @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace")
- protected String lang = null;
- @XmlTransient
- protected Locale locale;
-
- public String getDescription()
- {
- return value;
- }
-
- public void setDescription(String value)
- {
- this.value = value;
- }
-
- public String getLang()
- {
- return lang == null ? Locale.ENGLISH.toString() : lang;
- }
-
- public void setLang(String value)
- {
- lang = value;
- deriveLocale();
- }
-
- public Locale getLocale()
- {
- return locale == null ? deriveLocale() : locale;
- }
-
- protected Locale deriveLocale()
- {
- Locale locale = null;
- String lang = this.getLang();
- if (lang != null)
- {
- String country = "";
- String variant = "";
- String[] localeArray = lang.split("[-|_]");
- for (int i = 0; i < localeArray.length; i++)
- {
- if (i == 0)
- {
- lang = localeArray[i];
- }
- else if (i == 1)
- {
- country = localeArray[i];
- }
- else if (i == 2)
- {
- variant = localeArray[i];
- }
- }
- locale = new Locale(lang, country, variant);
- }
- return this.locale = locale;
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DisplayNameType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DisplayNameType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DisplayNameType.java
deleted file mode 100644
index 4b72a3f..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/DisplayNameType.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.XmlValue;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.DisplayName;
-
-/**
- * The display-name type contains a short name that is intended to be displayed by tools. It is used by display-name
- * elements. The display name need not be unique. Example: ...
- *
- * <pre>
- * <?xml version="1.0" encoding="UTF-8"?><display-name xmlns="http://www.w3.org/2001/XMLSchema" xmlns:portlet="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">Employee Self Service</display-name>
- * </pre>
- *
- * It has an optional attribute xml:lang to indicate which language is used in the description according to RFC 1766
- * (http://www.ietf.org/rfc/rfc1766.txt). The default value of this attribute is English(“en”). <p>Java class for
- * display-nameType complex type. <p>The following schema fragment specifies the expected content contained within this
- * class.
- *
- * <pre>
- * <complexType name="display-nameType">
- * <simpleContent>
- * <extension base="<http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd>string">
- * <attribute ref="{http://www.w3.org/XML/1998/namespace}lang"/>
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "display-nameType", propOrder = { "value" })
-public class DisplayNameType implements DisplayName
-{
- @XmlValue
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String value;
- @XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace")
- protected String lang = null;
- @XmlTransient
- protected Locale locale;
-
- public String getDisplayName()
- {
- return value;
- }
-
- public void setDisplayName(String value)
- {
- this.value = value;
- }
-
- public String getLang()
- {
- return lang == null ? Locale.ENGLISH.toString() : lang;
- }
-
- public void setLang(String value)
- {
- lang = value;
- }
-
- public Locale getLocale()
- {
- return locale == null ? deriveLocale() : locale;
- }
-
- protected Locale deriveLocale()
- {
- Locale locale = null;
- String lang = this.getLang();
- if (lang != null)
- {
- String country = "";
- String variant = "";
- String[] localeArray = lang.split("[-|_]");
- for (int i = 0; i < localeArray.length; i++)
- {
- if (i == 0)
- {
- lang = localeArray[i];
- }
- else if (i == 1)
- {
- country = localeArray[i];
- }
- else if (i == 2)
- {
- variant = localeArray[i];
- }
- }
- locale = new Locale(lang, country, variant);
- }
- return this.locale = locale;
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionReferenceType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionReferenceType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionReferenceType.java
deleted file mode 100644
index 454fc11..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionReferenceType.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import javax.xml.namespace.QName;
-
-import org.apache.pluto.container.om.portlet.EventDefinitionReference;
-
-/**
- * The event-definition-referenceType is used to reference events declared with the event-definition element at
- * application level. Used in: portlet <p>Java class for event-definition-referenceType complex type. <p>The following
- * schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="event-definition-referenceType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <choice>
- * <element name="qname" type="{http://www.w3.org/2001/XMLSchema}QName"/>
- * <element name="name" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
- * </choice>
- * <attribute name="id" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "event-definition-referenceType", propOrder = { "qname", "name" })
-public class EventDefinitionReferenceType implements EventDefinitionReference
-{
- protected QName qname;
- @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
- @XmlSchemaType(name = "NCName")
- protected String name;
-
- public QName getQName()
- {
- return qname;
- }
-
- public void setQName(QName value)
- {
- qname = value;
- name = null;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String value)
- {
- name = value;
- qname = null;
- }
-
- public QName getQualifiedName(String defaultNamespace)
- {
- return qname != null ? qname : name != null ? new QName(defaultNamespace, name) : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionType.java
deleted file mode 100644
index d5c743a..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionType.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-import javax.xml.namespace.QName;
-
-import org.apache.pluto.container.om.portlet.Description;
-import org.apache.pluto.container.om.portlet.EventDefinition;
-
-/**
- * The event-definitionType is used to declare events the portlet can either receive or emit. The name must be unique
- * and must be the one the portlet is using in its code for referencing this event. Used in: portlet-app <p>Java class
- * for event-definitionType complex type. <p>The following schema fragment specifies the expected content contained
- * within this class.
- *
- * <pre>
- * <complexType name="event-definitionType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="description" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}descriptionType" maxOccurs="unbounded" minOccurs="0"/>
- * <choice>
- * <element name="qname" type="{http://www.w3.org/2001/XMLSchema}QName"/>
- * <element name="name" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
- * </choice>
- * <element name="alias" type="{http://www.w3.org/2001/XMLSchema}QName" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="value-type" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}fully-qualified-classType" minOccurs="0"/>
- * </sequence>
- * <attribute name="id" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "event-definitionType", propOrder = { "description", "qname", "name", "alias", "valueType" })
-public class EventDefinitionType implements EventDefinition
-{
- @XmlElement(name = "description")
- protected List<DescriptionType> description;
- protected QName qname;
- @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
- @XmlSchemaType(name = "NCName")
- protected String name;
- protected List<QName> alias;
- @XmlElement(name = "value-type")
- protected String valueType;
-
- public Description getDescription(Locale locale)
- {
- for (Description d : getDescriptions())
- {
- if (d.getLocale().equals(locale))
- {
- return d;
- }
- }
- return null;
- }
-
- public List<? extends Description> getDescriptions()
- {
- if (description == null)
- {
- description = new ArrayList<DescriptionType>();
- }
- return description;
- }
-
- public Description addDescription(String lang)
- {
- DescriptionType d = new DescriptionType();
- d.setLang(lang);
- if (getDescription(d.getLocale()) != null)
- {
- throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
- }
- getDescriptions();
- description.add(d);
- return d;
- }
-
- public QName getQName()
- {
- return qname;
- }
-
- public void setQName(QName value)
- {
- qname = value;
- name = null;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String value)
- {
- name = value;
- qname = null;
- }
-
- public List<QName> getAliases()
- {
- if (alias == null)
- {
- alias = new ArrayList<QName>();
- }
- return alias;
- }
-
- public void addAlias(QName alias)
- {
- // TODO: check for duplicates
- getAliases().add(alias);
- }
-
- public String getValueType()
- {
- return valueType;
- }
-
- public void setValueType(String value)
- {
- valueType = value;
- }
-
- public QName getQualifiedName(String defaultNamespace)
- {
- return qname != null ? qname : name != null ? new QName(defaultNamespace, name) : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterMappingType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterMappingType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterMappingType.java
deleted file mode 100644
index b66661d..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterMappingType.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-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.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.FilterMapping;
-
-/**
- * Declaration of the filter mappings in this portlet application is done by using filter-mappingType. The container
- * uses the filter-mapping declarations to decide which filters to apply to a request, and in what order. To determine
- * which filters to apply it matches filter-mapping declarations on the portlet-name and the lifecyle phase defined in
- * the filter element. The order in which filters are invoked is the order in which filter-mapping declarations that
- * match appear in the list of filter-mapping elements. Used in: portlet-app <p>Java class for filter-mappingType
- * complex type. <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="filter-mappingType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="filter-name" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}filter-nameType"/>
- * <element name="portlet-name" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}portlet-nameType" maxOccurs="unbounded"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filter-mappingType", propOrder = { "filterName", "portletName" })
-public class FilterMappingType implements FilterMapping
-{
- @XmlElement(name = "filter-name", required = true)
- protected String filterName;
- @XmlElement(name = "portlet-name", required = true)
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected List<String> portletName;
-
- public String getFilterName()
- {
- return filterName;
- }
-
- public void setFilterName(String value)
- {
- filterName = value;
- }
-
- public List<String> getPortletNames()
- {
- if (portletName == null)
- {
- portletName = new ArrayList<String>();
- }
- return portletName;
- }
-
- public void addPortletName(String name)
- {
- // TODO: check for duplicates
- getPortletNames().add(name);
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterType.java
deleted file mode 100644
index 5e377f9..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/FilterType.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.pluto.container.om.portlet.Description;
-import org.apache.pluto.container.om.portlet.DisplayName;
-import org.apache.pluto.container.om.portlet.Filter;
-import org.apache.pluto.container.om.portlet.InitParam;
-
-/**
- * The filter element specifies a filter that can transform the content of portlet requests and portlet responses.
- * Filters can access the initialization parameters declared in the deployment descriptor at runtime via the
- * FilterConfig interface. A filter can be restricted to one or more lifecycle phases of the portlet. Valid entries for
- * lifecycle are: ACTION_PHASE, EVENT_PHASE, RENDER_PHASE, RESOURCE_PHASE Used in: portlet-app <p>Java class for
- * filterType complex type. <p>The following schema fragment specifies the expected content contained within this
- * class.
- *
- * <pre>
- * <complexType name="filterType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="description" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}descriptionType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="display-name" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}display-nameType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="filter-name" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}filter-nameType"/>
- * <element name="filter-class" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}fully-qualified-classType"/>
- * <element name="lifecycle" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}string" maxOccurs="unbounded"/>
- * <element name="init-param" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}init-paramType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filterType", propOrder = { "description", "displayName", "filterName", "filterClass", "lifecycle",
- "initParam" })
-public class FilterType implements Filter
-{
- @XmlElement(name = "description")
- protected List<DescriptionType> description;
- @XmlElement(name = "display-name")
- protected List<DisplayNameType> displayName;
- @XmlElement(name = "filter-name", required = true)
- protected String filterName;
- @XmlElement(name = "filter-class", required = true)
- protected String filterClass;
- @XmlElement(required = true)
- protected List<String> lifecycle;
- @XmlElement(name = "init-param")
- protected List<InitParamType> initParam;
-
- public Description getDescription(Locale locale)
- {
- for (Description d : getDescriptions())
- {
- if (d.getLocale().equals(locale))
- {
- return d;
- }
- }
- return null;
- }
-
- public List<? extends Description> getDescriptions()
- {
- if (description == null)
- {
- description = new ArrayList<DescriptionType>();
- }
- return description;
- }
-
- public Description addDescription(String lang)
- {
- DescriptionType d = new DescriptionType();
- d.setLang(lang);
- if (getDescription(d.getLocale()) != null)
- {
- throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
- }
- getDescriptions();
- description.add(d);
- return d;
- }
-
- public DisplayName getDisplayName(Locale locale)
- {
- for (DisplayName d : getDisplayNames())
- {
- if (d.getLocale().equals(locale))
- {
- return d;
- }
- }
- return null;
- }
-
- public List<? extends DisplayName> getDisplayNames()
- {
- if (displayName == null)
- {
- displayName = new ArrayList<DisplayNameType>();
- }
- return displayName;
- }
-
- public DisplayName addDisplayName(String lang)
- {
- DisplayNameType d = new DisplayNameType();
- d.setLang(lang);
- if (getDisplayName(d.getLocale()) != null)
- {
- throw new IllegalArgumentException("DisplayName for language: "+d.getLocale()+" already defined");
- }
- getDisplayNames();
- displayName.add(d);
- return d;
- }
-
- public String getFilterName()
- {
- return filterName;
- }
-
- public void setFilterName(String value)
- {
- filterName = value;
- }
-
- public String getFilterClass()
- {
- return filterClass;
- }
-
- public void setFilterClass(String value)
- {
- filterClass = value;
- }
-
- public List<String> getLifecycles()
- {
- if (lifecycle == null)
- {
- lifecycle = new ArrayList<String>();
- }
- return lifecycle;
- }
-
- public void addLifecycle(String name)
- {
- // TODO: check valid name and duplicates
- getLifecycles().add(name);
- }
-
- public InitParam getInitParam(String name)
- {
- for (InitParam param : getInitParams())
- {
- if (param.getParamName().equals(name))
- {
- return param;
- }
- }
- return null;
- }
-
- public List<? extends InitParam> getInitParams()
- {
- if (initParam == null)
- {
- initParam = new ArrayList<InitParamType>();
- }
- return initParam;
- }
-
- public InitParam addInitParam(String paramName)
- {
- if (getInitParam(paramName) != null)
- {
- throw new IllegalArgumentException("Init parameter: "+paramName+" already defined");
- }
- InitParamType param = new InitParamType();
- param.setParamName(paramName);
- getInitParams();
- initParam.add(param);
- return param;
- }
-}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/a8bed7fb/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/InitParamType.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/InitParamType.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/InitParamType.java
deleted file mode 100644
index fe1d48a..0000000
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/InitParamType.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.container.om.portlet.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.apache.pluto.container.om.portlet.Description;
-import org.apache.pluto.container.om.portlet.InitParam;
-
-/**
- * The init-param element contains a name/value pair as an initialization param of the portlet Used in:portlet <p>Java
- * class for init-paramType complex type. <p>The following schema fragment specifies the expected content contained
- * within this class.
- *
- * <pre>
- * <complexType name="init-paramType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="description" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}descriptionType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="name" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}nameType"/>
- * <element name="value" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}valueType"/>
- * </sequence>
- * <attribute name="id" type="{http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- * @version $Id$
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "init-paramType", propOrder = { "description", "name", "value" })
-public class InitParamType implements InitParam
-{
- @XmlElement(name = "description")
- protected List<DescriptionType> description;
- @XmlElement(required = true)
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String name;
- @XmlElement(required = true)
- @XmlJavaTypeAdapter(value=CollapsedStringAdapter.class)
- protected String value;
-
- public Description getDescription(Locale locale)
- {
- for (Description d : getDescriptions())
- {
- if (d.getLocale().equals(locale))
- {
- return d;
- }
- }
- return null;
- }
-
- public List<? extends Description> getDescriptions()
- {
- if (description == null)
- {
- description = new ArrayList<DescriptionType>();
- }
- return description;
- }
-
- public Description addDescription(String lang)
- {
- DescriptionType d = new DescriptionType();
- d.setLang(lang);
- if (getDescription(d.getLocale()) != null)
- {
- throw new IllegalArgumentException("Description for language: "+d.getLocale()+" already defined");
- }
- getDescriptions();
- description.add(d);
- return d;
- }
-
- public String getParamName()
- {
- return name;
- }
-
- public void setParamName(String value)
- {
- name = value;
- }
-
- public String getParamValue()
- {
- return value;
- }
-
- public void setParamValue(String value)
- {
- this.value = value;
- }
-}