From 8399a7ce943508215ba21de59880451300b5c55b Mon Sep 17 00:00:00 2001 From: hzzz Date: Tue, 5 Jun 2018 23:24:14 +0800 Subject: [PATCH] fix --- fine-portlet-api/.DS_Store | Bin 0 -> 6148 bytes fine-portlet-api/src/.DS_Store | Bin 0 -> 6148 bytes fine-portlet-api/src/com/.DS_Store | Bin 0 -> 6148 bytes fine-portlet-api/src/com/fr/third/.DS_Store | Bin 0 -> 6148 bytes .../fr/third/javax/portlet/ActionRequest.java | 162 +++++ .../third/javax/portlet/ActionResponse.java | 225 ++++++ .../third/javax/portlet/GenericPortlet.java | 464 ++++++++++++ .../fr/third/javax/portlet/PortalContext.java | 108 +++ .../com/fr/third/javax/portlet/Portlet.java | 183 +++++ .../fr/third/javax/portlet/PortletConfig.java | 118 +++ .../third/javax/portlet/PortletContext.java | 456 ++++++++++++ .../third/javax/portlet/PortletException.java | 160 +++++ .../fr/third/javax/portlet/PortletMode.java | 154 ++++ .../javax/portlet/PortletModeException.java | 107 +++ .../javax/portlet/PortletPreferences.java | 265 +++++++ .../third/javax/portlet/PortletRequest.java | 669 ++++++++++++++++++ .../portlet/PortletRequestDispatcher.java | 80 +++ .../third/javax/portlet/PortletResponse.java | 113 +++ .../portlet/PortletSecurityException.java | 89 +++ .../third/javax/portlet/PortletSession.java | 377 ++++++++++ .../javax/portlet/PortletSessionUtil.java | 90 +++ .../fr/third/javax/portlet/PortletURL.java | 211 ++++++ .../javax/portlet/PreferencesValidator.java | 53 ++ .../javax/portlet/ReadOnlyException.java | 88 +++ .../fr/third/javax/portlet/RenderRequest.java | 43 ++ .../third/javax/portlet/RenderResponse.java | 342 +++++++++ .../javax/portlet/UnavailableException.java | 134 ++++ .../javax/portlet/ValidatorException.java | 132 ++++ .../fr/third/javax/portlet/WindowState.java | 135 ++++ .../javax/portlet/WindowStateException.java | 105 +++ .../fr/third/javax/portlet/package-info.java | 38 + 31 files changed, 5101 insertions(+) create mode 100644 fine-portlet-api/.DS_Store create mode 100644 fine-portlet-api/src/.DS_Store create mode 100644 fine-portlet-api/src/com/.DS_Store create mode 100644 fine-portlet-api/src/com/fr/third/.DS_Store create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/ActionRequest.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/ActionResponse.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/GenericPortlet.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortalContext.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/Portlet.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletConfig.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletContext.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletMode.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletModeException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletPreferences.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequest.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequestDispatcher.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletResponse.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletSecurityException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletSession.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletSessionUtil.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PortletURL.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/PreferencesValidator.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/ReadOnlyException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/RenderRequest.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/RenderResponse.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/UnavailableException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/ValidatorException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/WindowState.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/WindowStateException.java create mode 100755 fine-portlet-api/src/com/fr/third/javax/portlet/package-info.java diff --git a/fine-portlet-api/.DS_Store b/fine-portlet-api/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0S5Z-O8ZYyFAf<5Nqt%v@IJqaP!gEt|f2bDG<)dp%(n$(~*lGo5T@(Fw$ zXLdJYvEWU_&cN;0j;iayU4o2iShc}Kq(BHht zIMBYo4*2aQcEhG#8c)7{f1EU%@4Qs5tgUYdQ4_VT+O;!^QYUefS!}!0OSDeiWaMf6 zEQ-dTy6c?>!?bVg97SQ`2H|ijlLLPUAy*ec=trp?%|btx^Ek>OL{(J#MtweSwVMsI z({5)CbKdQOzTY{>vZ~nKYaN~p?j9cJPucT}VwVH?Qnob~@Cu47?%tV(<0!lZyNE4f z2#En=fEXYKR*nIE6o}20tDFiZ28e;57{L9(gobEo%oWP513J7uqrZZP0y@4W5KWDi z##|wIK)6Z;RH9xq(34&$Z_XWUXqJuyHGEHY45 zrh(`GG5j)1ANh+ZWDx_zz&~SvS9(s*hNAS@`mH=XYfWeaXebz$qXGi@!X*F<+(+ut esr)AD5NB!372+&7F4F<&A|MH&ju`j_20j2Ft4`ej literal 0 HcmV?d00001 diff --git a/fine-portlet-api/src/com/fr/third/.DS_Store b/fine-portlet-api/src/com/fr/third/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f9508f2a4cec5dd5bcc934705228f05a56aaced0 GIT binary patch literal 6148 zcmeHKI|>3Z5S{S@f{mqRuHX%V=n3`$3W6Y_ASjkwc`lFUn@^!Ec3LQJVDgg5yo9`B zXGcVIe%{PPCL%I|8_LawuGzkM$9fr2ARK30FU{$&KOVN7+;;)v4rM26xxk6^$E}G4U=FOTNiu&z1zj(T64dh4#sKBcN{a8+{{x9Kg z`u|rFS5$xs{FMSaSTu_{o|Lt<^Ej)u1-^n?&K+)sxl=HBIR<(;#=^?+)RQ8w*c|&c Vu?=)O;!X$hXTWr!QGstO@Bm;x6xaX& literal 0 HcmV?d00001 diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/ActionRequest.java b/fine-portlet-api/src/com/fr/third/javax/portlet/ActionRequest.java new file mode 100755 index 000000000..2cdb35e5c --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/ActionRequest.java @@ -0,0 +1,162 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The ActionRequest represents the request sent to the portlet + * to handle an action. + * It extends the PortletRequest interface to provide action request + * information to portlets.
+ * The portlet container creates an ActionRequest object and + * passes it as argument to the portlet's processAction method. + * + * @see PortletRequest + * @see RenderRequest + */ +public interface ActionRequest extends PortletRequest +{ + + + + /** + * Retrieves the body of the HTTP request from client to + * portal as binary data using + * an InputStream. Either this method or + * {@link #getReader} may be called to read the body, but not both. + *

+ * For HTTP POST data of type application/x-www-form-urlencoded + * this method throws an IllegalStateException + * as this data has been already processed by the + * portal/portlet-container and is available as request parameters. + * + * @return an input stream containing the body of the request + * + * @exception java.lang.IllegalStateException + * if getReader was already called, or it is a + * HTTP POST data of type application/x-www-form-urlencoded + * @exception java.io.IOException + * if an input or output exception occurred + */ + public java.io.InputStream getPortletInputStream () throws java.io.IOException; + + + + /** + * Overrides the name of the character encoding used in the body of this + * request. This method must be called prior to reading input + * using {@link #getReader} or {@link #getPortletInputStream}. + *

+ * This method only sets the character set for the Reader that the + * {@link #getReader} method returns. + * + * @param enc a String containing the name of + * the chararacter encoding. + * + * @exception java.io.UnsupportedEncodingException if this is not a valid encoding + * @exception java.lang.IllegalStateException if this method is called after + * reading request parameters or reading input using + * getReader() + */ + + public void setCharacterEncoding(String enc) + throws java.io.UnsupportedEncodingException; + + + /** + * Retrieves the body of the HTTP request from the client to the portal + * as character data using + * a BufferedReader. The reader translates the character + * data according to the character encoding used on the body. + * Either this method or {@link #getPortletInputStream} may be called to read the + * body, not both. + *

+ * For HTTP POST data of type application/x-www-form-urlencoded + * this method throws an IllegalStateException + * as this data has been already processed by the + * portal/portlet-container and is available as request parameters. + * + * @return a BufferedReader + * containing the body of the request + * + * @exception java.io.UnsupportedEncodingException + * if the character set encoding used is + * not supported and the text cannot be decoded + * @exception java.lang.IllegalStateException + * if {@link #getPortletInputStream} method + * has been called on this request, it is a + * HTTP POST data of type application/x-www-form-urlencoded. + * @exception java.io.IOException + * if an input or output exception occurred + * + * @see #getPortletInputStream + */ + + public java.io.BufferedReader getReader() + throws java.io.UnsupportedEncodingException, java.io.IOException; + + + /** + * Returns the name of the character encoding used in the body of this request. + * This method returns null if the request + * does not specify a character encoding. + * + * @return a String containing the name of + * the chararacter encoding, or null + * if the request does not specify a character encoding. + */ + + public java.lang.String getCharacterEncoding(); + + + + /** + * Returns the MIME type of the body of the request, + * or null if the type is not known. + * + * @return a String containing the name + * of the MIME type of the request, or null + * if the type is not known. + */ + + public java.lang.String getContentType(); + + + /** + * Returns the length, in bytes, of the request body + * which is made available by the input stream, or -1 if the + * length is not known. + * + * + * @return an integer containing the length of the + * request body or -1 if the length is not known + * + */ + + public int getContentLength(); + + + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/ActionResponse.java b/fine-portlet-api/src/com/fr/third/javax/portlet/ActionResponse.java new file mode 100755 index 000000000..1e83abd57 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/ActionResponse.java @@ -0,0 +1,225 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The ActionResponse interface represents the portlet + * response to an action request. + * It extends the PortletResponse interface to provide specific + * action response functionality to portlets.
+ * The portlet container creates an ActionResponse object and + * passes it as argument to the portlet's processAction method. + * + * @see ActionRequest + * @see PortletResponse + */ +public interface ActionResponse extends PortletResponse +{ + + + /** + * Sets the window state of a portlet to the given window state. + *

+ * Possible values are the standard window states and any custom + * window states supported by the portal and the portlet. + * Standard window states are: + *

    + *
  • MINIMIZED + *
  • NORMAL + *
  • MAXIMIZED + *
+ * + * @param windowState + * the new portlet window state + * + * @exception WindowStateException + * if the portlet cannot switch to the specified window state. + * To avoid this exception the portlet can check the allowed + * window states with Request.isWindowStateAllowed(). + * @exception java.lang.IllegalStateException + * if the method is invoked after sendRedirect has been called. + * + * @see WindowState + */ + + public void setWindowState (WindowState windowState) + throws WindowStateException; + + + /** + * Sets the portlet mode of a portlet to the given portlet mode. + *

+ * Possible values are the standard portlet modes and any custom + * portlet modes supported by the portal and the portlet. Portlets + * must declare in the deployment descriptor the portlet modes they + * support for each markup type. + * Standard portlet modes are: + *

    + *
  • EDIT + *
  • HELP + *
  • VIEW + *
+ *

+ * Note: The portlet may still be called in a different window + * state in the next render call, depending on the portlet container / portal. + * + * @param portletMode + * the new portlet mode + * + * @exception PortletModeException + * if the portlet cannot switch to this portlet mode, + * because the portlet or portal does not support it for this markup, + * or the current user is not allowed to switch to this portlet mode. + * To avoid this exception the portlet can check the allowed + * portlet modes with Request.isPortletModeAllowed(). + * @exception java.lang.IllegalStateException + * if the method is invoked after sendRedirect has been called. + */ + + public void setPortletMode (PortletMode portletMode) + throws PortletModeException; + + + /** + * Instructs the portlet container to send a redirect response + * to the client using the specified redirect location URL. + *

+ * This method only accepts an absolute URL (e.g. + * http://my.co/myportal/mywebap/myfolder/myresource.gif) + * or a full path URI (e.g. /myportal/mywebap/myfolder/myresource.gif). + * If required, + * the portlet container may encode the given URL before the + * redirection is issued to the client. + *

+ * The sendRedirect method can not be invoked after any of the + * following methods of the ActionResponse interface has been called: + *

    + *
  • setPortletMode + *
  • setWindowState + *
  • setRenderParameter + *
  • setRenderParameters + *
+ * + * @param location the redirect location URL + * + * @exception java.io.IOException + * if an input or output exception occurs. + * @exception java.lang.IllegalArgumentException + * if a relative path URL is given + * @exception java.lang.IllegalStateException + * if the method is invoked after any of above mentioned methods of + * the ActionResponse interface has been called. + */ + + public void sendRedirect(String location) + throws java.io.IOException; + + + /** + * Sets a parameter map for the render request. + *

+ * All previously set render parameters are cleared. + *

+ * These parameters will be accessible in all + * sub-sequent render calls via the + * PortletRequest.getParameter call until + * a new request is targeted to the portlet. + *

+ * The given parameters do not need to be encoded + * prior to calling this method. + * + * @param parameters Map containing parameter names for + * the render phase as + * keys and parameter values as map + * values. The keys in the parameter + * map must be of type String. The values + * in the parameter map must be of type + * String array (String[]). + * + * @exception java.lang.IllegalArgumentException + * if parameters is null, if + * any of the key/values in the Map are null, + * if any of the keys is not a String, or if any of + * the values is not a String array. + * @exception java.lang.IllegalStateException + * if the method is invoked after sendRedirect has been called. + */ + + public void setRenderParameters(java.util.Map parameters); + + + /** + * Sets a String parameter for the render request. + *

+ * These parameters will be accessible in all + * sub-sequent render calls via the + * PortletRequest.getParameter call until + * a request is targeted to the portlet. + *

+ * This method replaces all parameters with the given key. + *

+ * The given parameter do not need to be encoded + * prior to calling this method. + * + * @param key key of the render parameter + * @param value value of the render parameter + * + * @exception java.lang.IllegalArgumentException + * if key or value are null. + * @exception java.lang.IllegalStateException + * if the method is invoked after sendRedirect has been called. + */ + + public void setRenderParameter(String key, String value); + + + /** + * Sets a String array parameter for the render request. + *

+ * These parameters will be accessible in all + * sub-sequent render calls via the + * PortletRequest.getParameter call until + * a request is targeted to the portlet. + *

+ * This method replaces all parameters with the given key. + *

+ * The given parameter do not need to be encoded + * prior to calling this method. + * + * @param key key of the render parameter + * @param values values of the render parameter + * + * @exception java.lang.IllegalArgumentException + * if key or value are null. + * @exception java.lang.IllegalStateException + * if the method is invoked after sendRedirect has been called. + */ + + public void setRenderParameter(String key, String[] values); + + +} + + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/GenericPortlet.java b/fine-portlet-api/src/com/fr/third/javax/portlet/GenericPortlet.java new file mode 100755 index 000000000..1a4c9f15e --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/GenericPortlet.java @@ -0,0 +1,464 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The GenericPortlet class provides a default implementation + * for the Portlet interface. + *

+ * It provides an abstract class to be subclassed to create portlets. A + * subclass of GenericPortlet should override at least + * one method, usually one of the following: + *

    + *
  • processAction, to handle action requests
  • + *
  • doView, to handle render requests when in VIEW mode
  • + *
  • doEdit, to handle render requests when in EDIT mode
  • + *
  • doHelp, to handle render request when in HELP mode
  • + *
  • init and destroy, to manage resources that are held for the life of + * the servlet
  • + *
+ *

+ * Normally there is no need to override the render or the doDispatch + * methods. Render handles render requests setting the title of the + * portlet in the response and invoking doDispatch. doDispatch dispatches + * the request to one of the doView, doEdit or doHelp method depending on + * the portlet mode indicated in the request. + *

+ * Portlets typically run on multithreaded servers, so please note that a + * portlet must handle concurrent requests and be careful to synchronize + * access to shared resources. Shared resources include in-memory data + * such as instance or class variables and external objects such as + * files, database connections, and network connections. + */ +public abstract class GenericPortlet implements Portlet, PortletConfig +{ + + + private transient PortletConfig config; + + /** + * Does nothing. + */ + + public GenericPortlet() + { + } + + + /** + * Called by the portlet container to indicate to a portlet that the + * portlet is being placed into service. + *

+ * The default implementation just stores the PortletConfig + * object. + *

The portlet container calls the init + * method exactly once after instantiating the portlet. + * The init method must complete successfully + * before the portlet can receive any requests. + * + *

The portlet container cannot place the portlet into service + * if the init method does one of the following: + *

    + *
  1. it throws a PortletException + *
  2. it does not return within a time period defined by the Web server + *
+ * + * + * @param config a PortletConfig object + * containing the portlet + * configuration and initialization parameters + * + * @exception PortletException if an exception has occurred that + * interferes with the portlet normal + * operation. + * @exception UnavailableException if the portlet cannot perform the initialization at this time. + */ + + public void init (PortletConfig config) throws PortletException + { + this.config = config; + this.init(); + } + + + /** + * + * A convenience method which can be overridden so that there's no need + * to call super.init(config). + * + *

Instead of overriding {@link #init(PortletConfig)}, simply override + * this method and it will be called by + * GenericPortlet.init(PortletConfig config). + * The PortletConfig object can still be retrieved via {@link + * #getPortletConfig}. + * + * @exception PortletException if an exception has occurred that + * interferes with the portlet normal + * operation. + * @exception UnavailableException if the portlet is unavailable to perform init + */ + + public void init() throws PortletException + { + } + + + /** + * Called by the portlet container to allow the portlet to process + * an action request. This method is called if the client request was + * originated by a URL created (by the portlet) with the + * RenderResponse.createActionURL() method. + *

+ * The default implementation throws an exception. + * + * @param request + * the action request + * @param response + * the action response + * @exception PortletException + * if the portlet cannot fulfilling the request + * @exception UnavailableException + * if the portlet is unavailable to process the action at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + */ + public void processAction (ActionRequest request, ActionResponse response) + throws PortletException, java.io.IOException { + throw new PortletException("processAction method not implemented"); + } + + + /** + * The default implementation of this method sets the title + * using the getTitle method and invokes the + * doDispatch method. + * + * @param request + * the render request + * @param response + * the render response + * + * @exception PortletException + * if the portlet cannot fulfilling the request + * @exception UnavailableException + * if the portlet is unavailable to perform render at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + * + */ + public void render (RenderRequest request, + RenderResponse response) + throws PortletException, java.io.IOException + { + response.setTitle(getTitle(request)); + doDispatch(request, response); + } + + + + /** + * Used by the render method to get the title. + *

+ * The default implementation gets the title from the ResourceBundle + * of the PortletConfig of the portlet. The title is retrieved + * using the 'javax.portlet.title' resource name. + *

+ * Portlets can overwrite this method to provide dynamic + * titles (e.g. based on locale, client, and session information). + * Examples are: + *

    + *
  • language-dependant titles for multi-lingual portals + *
  • shorter titles for WAP phones + *
  • the number of messages in a mailbox portlet + *
+ * + * @return the portlet title for this window + */ + + protected java.lang.String getTitle(RenderRequest request) { + return config.getResourceBundle(request.getLocale()).getString("javax.portlet.title"); + } + + + /** + * The default implementation of this method routes the render request + * to a set of helper methods depending on the current portlet mode the + * portlet is currently in. + * These methods are: + *
    + *
  • doView for handling view requests + *
  • doEdit for handling edit requests + *
  • doHelp for handling help requests + *
+ *

+ * If the window state of this portlet is minimized, this + * method does not invoke any of the portlet mode rendering methods. + *

+ * For handling custom portlet modes the portlet should override this + * method. + * + * @param request + * the render request + * @param response + * the render response + * + * @exception PortletException + * if the portlet cannot fulfilling the request + * @exception UnavailableException + * if the portlet is unavailable to perform render at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + * + * @see #doView(RenderRequest, RenderResponse) + * @see #doEdit(RenderRequest, RenderResponse) + * @see #doHelp(RenderRequest, RenderResponse) + */ + protected void doDispatch (RenderRequest request, + RenderResponse response) throws PortletException,java.io.IOException + { + WindowState state = request.getWindowState(); + + if ( ! state.equals(WindowState.MINIMIZED)) { + PortletMode mode = request.getPortletMode(); + if (mode.equals(PortletMode.VIEW)) { + doView (request, response); + } + else if (mode.equals(PortletMode.EDIT)) { + doEdit (request, response); + } + else if (mode.equals(PortletMode.HELP)) { + doHelp (request, response); + } + else { + throw new PortletException("unknown portlet mode: " + mode); + } + } + + } + + + /** + * Helper method to serve up the mandatory view mode. + *

+ * The default implementation throws an exception. + * + * @param request + * the portlet request + * @param response + * the render response + * + * @exception PortletException + * if the portlet cannot fulfilling the request + * @exception UnavailableException + * if the portlet is unavailable to perform render at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + * + */ + + protected void doView (RenderRequest request, + RenderResponse response) + throws PortletException, java.io.IOException + { + throw new PortletException("doView method not implemented"); + } + + + /** + * Helper method to serve up the edit mode. + *

+ * The default implementation throws an exception. + * + * @param request + * the portlet request + * @param response + * the render response + * + * @exception PortletException + * if the portlet cannot fulfilling the request + * @exception UnavailableException + * if the portlet is unavailable to perform render at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + * + */ + + protected void doEdit (RenderRequest request, + RenderResponse response) + throws PortletException, java.io.IOException + { + throw new PortletException("doEdit method not implemented"); + } + + /** + * Helper method to serve up the help mode. + *

+ * The default implementation throws an exception. + * + * @param request + * the portlet request + * @param response + * the render response + * + * @exception PortletException + * if the portlet cannot fulfilling the request + * @exception UnavailableException + * if the portlet is unavailable to perform render at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + */ + + protected void doHelp (RenderRequest request, + RenderResponse response) + throws PortletException, java.io.IOException + { + throw new PortletException("doHelp method not implemented"); + + } + + + + /** + * Returns the PortletConfig object of this portlet. + * + * @return the PortletConfig object of this portlet + */ + + public PortletConfig getPortletConfig () + { + return config; + } + + + /** + * Called by the portlet container to indicate to a portlet that the portlet + * is being taken out of service. + *

+ * The default implementation does nothing. + * + */ + + public void destroy () + { + // do nothing + } + + //------------------------------------------------------------------------- + // implement PortletConfig + //------------------------------------------------------------------------- + + + /** + * Returns the name of this portlet. + * + * @return the portlet name + * + * @see PortletConfig#getPortletName() + */ + + public String getPortletName () + { + return config.getPortletName(); + } + + + /** + * Returns the PortletContext of the portlet application + * the portlet is in. + * + * @return the portlet application context + */ + + public PortletContext getPortletContext () + { + return config.getPortletContext(); + } + + + + /** + * Gets the resource bundle for the given locale based on the + * resource bundle defined in the deployment descriptor + * with resource-bundle tag or the inlined resources + * defined in the deployment descriptor. + * + * @return the resource bundle for the given locale + */ + + public java.util.ResourceBundle getResourceBundle(java.util.Locale locale) + { + return config.getResourceBundle(locale); + } + + + /** + * Returns a String containing the value of the named initialization parameter, + * or null if the parameter does not exist. + * + * @param name a String specifying the name + * of the initialization parameter + * + * @return a String containing the value + * of the initialization parameter + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public String getInitParameter(java.lang.String name) + { + return config.getInitParameter(name); + } + + + /** + * Returns the names of the portlet initialization parameters as an + * Enumeration of String objects, or an empty Enumeration if the + * portlet has no initialization parameters. + * + * @return an Enumeration of String + * objects containing the names of the portlet + * initialization parameters, or an empty Enumeration if the + * portlet has no initialization parameters. + */ + + public java.util.Enumeration getInitParameterNames() + { + return config.getInitParameterNames(); + } +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortalContext.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortalContext.java new file mode 100755 index 000000000..525e8c234 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortalContext.java @@ -0,0 +1,108 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The PortalContext interface gives the portlet + * the ability to retrieve information about the portal calling this portlet. + *

+ * The portlet can only read the PortalContext data. + */ +public interface PortalContext +{ + + + + /** + * Returns the portal property with the given name, + * or a null if there is + * no property by that name. + * + * @param name property name + * + * @return portal property with key name + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public java.lang.String getProperty(java.lang.String name); + + + /** + * Returns all portal property names, or an empty + * Enumeration if there are no property names. + * + * @return All portal property names as an + * Enumeration of String objects + */ + public java.util.Enumeration getPropertyNames(); + + + /** + * Returns all supported portlet modes by the portal + * as an enumertation of PorltetMode objects. + *

+ * The portlet modes must at least include the + * standard portlet modes EDIT, HELP, VIEW. + * + * @return All supported portal modes by the portal + * as an enumertation of PorltetMode objects. + */ + + public java.util.Enumeration getSupportedPortletModes(); + + + /** + * Returns all supported window states by the portal + * as an enumertation of WindowState objects. + *

+ * The window states must at least include the + * standard window states MINIMIZED, NORMAL, MAXIMIZED. + * + * @return All supported window states by the portal + * as an enumertation of WindowState objects. + */ + + public java.util.Enumeration getSupportedWindowStates(); + + + /** + * Returns information about the portal like vendor, version, etc. + *

+ * The form of the returned string is servername/versionnumber. For + * example, the reference implementation Pluto may return the string + * Pluto/1.0. + *

+ * The portlet container may return other optional information after the + * primary string in parentheses, for example, Pluto/1.0 + * (JDK 1.3.1; Windows NT 4.0 x86). + * + * @return a String containing at least the portal name and version number + */ + + public java.lang.String getPortalInfo(); +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/Portlet.java b/fine-portlet-api/src/com/fr/third/javax/portlet/Portlet.java new file mode 100755 index 000000000..ba216d5d6 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/Portlet.java @@ -0,0 +1,183 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The Portlet interface is used by the portlet container to + * invoke the portlets. Every portlet has to implement this interface, + * either by directly implementing it, or by using an existing class + * implementing the Portlet interface. + *

+ * A portlet is a Java technology-based web component. It is managed by the portlet container and + * processes requests and generates dynamic content as response. Portlets are used by portals as + * pluggable user interface components. + *

+ * The content generated by a portlet is called a fragment. A fragment is a piece of + * markup (e.g. HTML, XHTML, WML) adhering to certain rules and can be aggregated + * with other fragments into a complete document. The content of a portlet is normally + * aggregated with the content of other portlets into the portal page. + *

+ * The portlet container instanciates portlets, manages their lifecycle + * and invoking them to process requests. The lifecycle consists of: + *

    + *
  • initializing the portlet using using the init method + *
  • request processsing + *
  • taking the portlet out of service using the destroy method + *
+ *

+ * Request processing is divided into two types: + *

    + *
  • action requests handled through the processAction method, + * to perform actions targeted to the portlet + *
  • render requests handled through the render method, + * to perform the render operation + *
+ */ +public interface Portlet +{ + + + + /** + * Called by the portlet container to indicate to a portlet that the + * portlet is being placed into service. + * + *

The portlet container calls the init + * method exactly once after instantiating the portlet. + * The init method must complete successfully + * before the portlet can receive any requests. + * + *

The portlet container cannot place the portlet into service + * if the init method + *

    + *
  1. Throws a PortletException + *
  2. Does not return within a time period defined by the portlet container. + *
+ * + * + * @param config a PortletConfig object + * containing the portlet's + * configuration and initialization parameters + * + * @exception PortletException if an exception has occurred that + * interferes with the portlet's normal + * operation. + * @exception UnavailableException if the portlet cannot perform the initialization at this time. + * + * + */ + + public void init(PortletConfig config) throws PortletException; + + + + + /** + * Called by the portlet container to allow the portlet to process + * an action request. This method is called if the client request was + * originated by a URL created (by the portlet) with the + * RenderResponse.createActionURL() method. + *

+ * Typically, in response to an action request, a portlet updates state + * based on the information sent in the action request parameters. + * In an action the portlet may: + *

    + *
  • issue a redirect + *
  • change its window state + *
  • change its portlet mode + *
  • modify its persistent state + *
  • set render parameters + *
+ *

+ * A client request triggered by an action URL translates into one + * action request and many render requests, one per portlet in the portal page. + * The action processing must be finished before the render requests + * can be issued. + * + * @param request + * the action request + * @param response + * the action response + * @exception PortletException + * if the portlet has problems fulfilling the + * request + * @exception UnavailableException + * if the portlet is unavailable to process the action at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception IOException + * if the streaming causes an I/O problem + */ + public void processAction (ActionRequest request, ActionResponse response) + throws PortletException, java.io.IOException; + + + + /** + * Called by the portlet container to allow the portlet to generate + * the content of the response based on its current state. + * + * @param request + * the render request + * @param response + * the render response + * + * @exception PortletException + * if the portlet has problems fulfilling the + * rendering request + * @exception UnavailableException + * if the portlet is unavailable to perform render at this time + * @exception PortletSecurityException + * if the portlet cannot fullfill this request because of security reasons + * @exception java.io.IOException + * if the streaming causes an I/O problem + */ + + public void render (RenderRequest request, RenderResponse response) + throws PortletException, java.io.IOException; + + + /** + * + * Called by the portlet container to indicate to a portlet that the + * portlet is being taken out of service. + *

+ * Before the portlet container calls the destroy method, it should + * allow any threads that are currently processing requests within + * the portlet object to complete execution. To avoid + * waiting forever, the portlet container can optionally wait for + * a predefined time before destroying the portlet object. + * + *

This method enables the portlet to do the following: + *

    + *
  • clean up any resources that it holds (for example, memory, + * file handles, threads) + *
  • make sure that any persistent state is + * synchronized with the portlet current state in memory. + *
+ */ + + public void destroy(); +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletConfig.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletConfig.java new file mode 100755 index 000000000..65df87447 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletConfig.java @@ -0,0 +1,118 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + + +/** + * The PortletConfig interface provides the portlet with + * its configuration. The configuration holds information about the + * portlet that is valid for all users. The configuration is retrieved + * from the portlet definition in the deployment descriptor. + * The portlet can only read the configuration data. + *

+ * The configuration information contains the portlet name, the portlet + * initialization parameters, the portlet resource bundle and the portlet + * application context. + * + * @see Portlet + */ +public interface PortletConfig +{ + + + + /** + * Returns the name of the portlet. + *

+ * The name may be provided via server administration, assigned in the + * portlet application deployment descriptor with the portlet-name + * tag. + * + * @return the portlet name + */ + + public String getPortletName (); + + + /** + * Returns the PortletContext of the portlet application + * the portlet is in. + * + * @return a PortletContext object, used by the + * caller to interact with its portlet container + * + * @see PortletContext + */ + + public PortletContext getPortletContext (); + + + /** + * Gets the resource bundle for the given locale based on the + * resource bundle defined in the deployment descriptor + * with resource-bundle tag or the inlined resources + * defined in the deployment descriptor. + * + * @param locale the locale for which to retrieve the resource bundle + * + * @return the resource bundle for the given locale + * + */ + + public java.util.ResourceBundle getResourceBundle(java.util.Locale locale); + + + /** + * Returns a String containing the value of the named initialization parameter, + * or null if the parameter does not exist. + * + * @param name a String specifying the name + * of the initialization parameter + * + * @return a String containing the value + * of the initialization parameter + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public String getInitParameter(java.lang.String name); + + + /** + * Returns the names of the portlet initialization parameters as an + * Enumeration of String objects, or an empty Enumeration if the + * portlet has no initialization parameters. + * + * @return an Enumeration of String + * objects containing the names of the portlet + * initialization parameters, or an empty Enumeration if the + * portlet has no initialization parameters. + */ + + public java.util.Enumeration getInitParameterNames(); +} + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletContext.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletContext.java new file mode 100755 index 000000000..08277426e --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletContext.java @@ -0,0 +1,456 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + + +/** + * The PortletContext interface defines a portlet view + * of the portlet container. + * The PortletContext also makes resources available + * to the portlet. Using the context, a portlet can access + * the portlet log, and obtain URL references to resources. + * + *

There is one context per "portlet application" per Java Virtual Machine. (A + * "portlet application" is a collection of portlets, servlets, and content installed + * under a specific subset of the server URL namespace, such as /catalog. + * They are possibly installed via a .war file.) + * As a web application, a portlet application also has a servlet context. + * The portlet context leverages most of its functionality from the + * servlet context of the portlet application. + *

+ * Attibutes stored in the context are global for all users and all + * components in the portlet application. + *

+ * In the case of a web + * application marked "distributed" in its deployment descriptor, there will + * be one context instance for each virtual machine. In this situation, the + * context cannot be used as a location to share global information (because + * the information is not truly global). Use an external resource, such as + * a database to achieve sharing on a global scope. + */ +public interface PortletContext +{ + + + /** + * Returns the name and version of the portlet container in which the + * portlet is running. + * + *

+ * The form of the returned string is containername/versionnumber. + * + * + * @return the string containing at least name and version number + */ + + public String getServerInfo (); + + /** + * Returns a {@link PortletRequestDispatcher} object that acts + * as a wrapper for the resource located at the given path. + * A PortletRequestDispatcher object can be used include the + * resource in a response. The resource can be dynamic or static. + * + *

The pathname must begin with a slash ( / ) and is interpreted as relative + * to the current context root. + * + *

This method returns null if the PortletContext + * cannot return a PortletRequestDispatcher + * for any reason. + * + * + * @param path a String specifying the pathname + * to the resource + * @return a PortletRequestDispatcher object + * that acts as a wrapper for the resource + * at the specified path. + * @see PortletRequestDispatcher + */ + + public PortletRequestDispatcher getRequestDispatcher(String path); + + + + /** + * Returns a {@link PortletRequestDispatcher} object that acts + * as a wrapper for the named servlet. + * + *

Servlets (and also JSP pages) may be given names via server + * administration or via a web application deployment descriptor. + * + *

This method returns null if the + * PortletContext cannot return a + * PortletRequestDispatcher for any reason. + * + * + * @param name a String specifying the name + * of a servlet to be wrapped + * + * @return a PortletRequestDispatcher object + * that acts as a wrapper for the named servlet + * + * @see PortletRequestDispatcher + * + */ + + public PortletRequestDispatcher getNamedDispatcher(String name); + + + /** + * Returns the resource located at the given path as an InputStream object. + * The data in the InputStream can be of any type or length. The method returns + * null if no resource exists at the given path. + *

+ * In order to access protected resources the path has to be prefixed with + * /WEB-INF/ (for example /WEB-INF/myportlet/myportlet.jsp). + * Otherwise, the direct path is used + * (for example /myportlet/myportlet.jsp). + * + * @param path the path to the resource + * + * @return the input stream + */ + public java.io.InputStream getResourceAsStream (String path); + + + + /** + * Returns the major version of the Portlet API that this portlet + * container supports. + * + * @return the major version + * + * @see #getMinorVersion() + */ + + public int getMajorVersion (); + + + /** + * Returns the minor version of the Portlet API that this portlet + * container supports. + * + * @return the minor version + * + * @see #getMajorVersion() + */ + + public int getMinorVersion (); + + + /** + * Returns the MIME type of the specified file, or null if + * the MIME type is not known. The MIME type is determined + * by the configuration of the portlet container and may be specified + * in a web application deployment descriptor. Common MIME + * types are text/html and image/gif. + * + * + * @param file a String specifying the name + * of a file + * + * @return a String specifying the MIME type of the file + * + */ + + public String getMimeType(String file); + + + /** + * Returns a String containing the real path + * for a given virtual path. For example, the path /index.html + * returns the absolute file path of the portlet container file system. + * + *

The real path returned will be in a form + * appropriate to the computer and operating system on + * which the portlet container is running, including the + * proper path separators. This method returns null + * if the portlet container cannot translate the virtual path + * to a real path for any reason (such as when the content is + * being made available from a .war archive). + * + * @param path a String specifying a virtual path + * + * @return a String specifying the real path, + * or null if the transformation cannot be performed. + */ + + public String getRealPath(String path); + + + /** + * Returns a directory-like listing of all the paths to resources within + * the web application longest sub-path of which + * matches the supplied path argument. Paths indicating subdirectory paths + * end with a slash (/). The returned paths are all + * relative to the root of the web application and have a leading slash. + * For example, for a web application + * containing

+ * + * /welcome.html
+ * /catalog/index.html
+ * /catalog/products.html
+ * /catalog/offers/books.html
+ * /catalog/offers/music.html
+ * /customer/login.jsp
+ * /WEB-INF/web.xml
+ * /WEB-INF/classes/com.acme.OrderPortlet.class,

+ *
+ * + * getResourcePaths("/") returns + * {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}
+ * getResourcePaths("/catalog/") returns + * {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}.
+ * + * @param path + * the partial path used to match the resources, which must start with a slash + * @return a Set containing the directory listing, or null if there + * are no resources in the web application of which the path + * begins with the supplied path. + */ + + public java.util.Set getResourcePaths(String path); + + + + /** + * Returns a URL to the resource that is mapped to a specified + * path. The path must begin with a slash (/) and is interpreted + * as relative to the current context root. + * + *

This method allows the portlet container to make a resource + * available to portlets from any source. Resources + * can be located on a local or remote + * file system, in a database, or in a .war file. + * + *

The portlet container must implement the URL handlers + * and URLConnection objects that are necessary + * to access the resource. + * + *

This method returns null + * if no resource is mapped to the pathname. + * + *

Some containers may allow writing to the URL returned by + * this method using the methods of the URL class. + * + *

The resource content is returned directly, so be aware that + * requesting a .jsp page returns the JSP source code. + * Use a RequestDispatcher instead to include results of + * an execution. + * + *

This method has a different purpose than + * java.lang.Class.getResource, + * which looks up resources based on a class loader. This + * method does not use class loaders. + * + * @param path a String specifying + * the path to the resource + * + * @return the resource located at the named path, + * or null if there is no resource + * at that path + * + * @exception MalformedURLException if the pathname is not given in + * the correct form + * + */ + + public java.net.URL getResource(String path) throws java.net.MalformedURLException; + + + /** + * Returns the portlet container attribute with the given name, + * or null if there is no attribute by that name. + * An attribute allows a portlet container to give the + * portlet additional information not + * already provided by this interface. + * A list of supported attributes can be retrieved using + * getAttributeNames. + * + *

The attribute is returned as a java.lang.Object + * or some subclass. + * Attribute names should follow the same convention as package + * names. The Java Portlet API specification reserves names + * matching java.*, javax.*, + * and sun.*. + * + * + * @param name a String specifying the name + * of the attribute + * + * @return an Object containing the value + * of the attribute, or null + * if no attribute exists matching the given + * name + * + * @see #getAttributeNames + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public java.lang.Object getAttribute(java.lang.String name); + + + /** + * Returns an Enumeration containing the attribute names + * available within this portlet context, or an emtpy + * Enumeration if no attributes are available. Use the + * {@link #getAttribute} method with an attribute name + * to get the value of an attribute. + * + * @return an Enumeration of attribute names + * + * @see #getAttribute + */ + + public java.util.Enumeration getAttributeNames(); + + + /** + * Returns a String containing the value of the named context-wide + * initialization parameter, or null if the parameter does not exist. + * This method provides configuration information which may be useful for + * an entire "portlet application". + * + * @param name a String containing the name of the + * requested parameter + * + * @return a String containing the value + * of the initialization parameter, or + * null if the parameter does not exist. + * + * @see #getInitParameterNames + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public java.lang.String getInitParameter(java.lang.String name); + + + /** + * Returns the names of the context initialization parameters as an + * Enumeration of String objects, or an empty Enumeration if the context + * has no initialization parameters. + * + * @return an Enumeration of String + * objects containing the names of the context + * initialization parameters + * + * @see #getInitParameter + */ + + public java.util.Enumeration getInitParameterNames(); + + + /** + * Writes the specified message to a portlet log file, usually an event log. + * The name and type of the portlet log file is specific to the portlet container. + *

+ * This method mapps to the ServletContext.log method. + * The portlet container may in addition log this message in a + * portlet container specific log file. + * + * @param msg a String specifying the + * message to be written to the log file + */ + + public void log(java.lang.String msg); + + + /** + * Writes an explanatory message and a stack trace for a given + * Throwable exception to the portlet log file. + * The name and type of the portlet log file is specific to the + * portlet container, usually an event log. + *

+ * This method is mapped to the ServletContext.log method. + * The portlet container may in addition log this message in a + * portlet container specific log file. + * + * @param message a String that + * describes the error or exception + * @param throwable the Throwable error + * or exception + */ + + public void log(java.lang.String message, java.lang.Throwable throwable); + + + /** + * Removes the attribute with the given name from the portlet context. + * After removal, subsequent calls to + * {@link #getAttribute} to retrieve the attribute's value + * will return null. + * + * @param name a String specifying the name + * of the attribute to be removed + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void removeAttribute(java.lang.String name); + + + /** + * Binds an object to a given attribute name in this portlet context. + * If the name specified is already used for an attribute, this method + * removes the old attribute and binds the name to the new attribute. + *

+ * If a null value is passed, the effect is the same as calling + * removeAttribute(). + * + *

Attribute names should follow the same convention as package + * names. The Java Portlet API specification reserves names + * matching java.*, javax.*, and + * sun.*. + * + * @param name a String specifying the name + * of the attribute + * @param object an Object representing the + * attribute to be bound + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void setAttribute(java.lang.String name, java.lang.Object object); + + + /** + * Returns the name of this portlet application correponding to this PortletContext as specified + * in the web.xml deployment descriptor for this web application by the + * display-name element. + * + * + * @return The name of the web application or null if no name has been declared in the deployment descriptor. + */ + + public String getPortletContextName(); + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletException.java new file mode 100755 index 000000000..44d697611 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletException.java @@ -0,0 +1,160 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The PortletException class defines a general exception + * that a portlet can throw when it is unable to perform its operation + * successfully. + */ + +public class PortletException extends java.lang.Exception +{ + + + private Throwable _cause; + + + /** + * Constructs a new portlet exception. + */ + + public PortletException () + { + super(); + } + + /** + * Constructs a new portlet exception with the given text. The + * portlet container may use the text write it to a log. + * + * @param text + * the exception text + */ + + public PortletException (String text) + { + super (text); + } + + /** + * Constructs a new portlet exception when the portlet needs to do + * the following: + *

    + *
  • throw an exception + *
  • include the "root cause" exception + *
  • include a description message + *
+ * + * @param text + * the exception text + * @param cause + * the root cause + */ + + public PortletException (String text, Throwable cause) + { + super(text); + _cause = cause; + // change this when going to jdk1.4: super (text, cause); + } + + /** + * Constructs a new portlet exception when the portlet needs to throw an + * exception. The exception's message is based on the localized message + * of the underlying exception. + * + * @param cause + * the root cause + */ + + public PortletException (Throwable cause) + { + _cause = cause; + // change this when going to jdk1.4: super (cause); + } + + /** + * Prints the stack trace of this exception to the standard error stream. + */ + public void printStackTrace() + { + this.printStackTrace(System.err); + } + + /** + * Prints the stack trace of this exception to the specified print stream. + * + * @param out the PrintStream to be used for output + */ + public void printStackTrace(java.io.PrintStream out) + { + this.printStackTrace(new java.io.PrintWriter(out, true)); + } + + /** + * Prints the stack trace of this exception to the specified print writer. + * + * @param out the PrintWriter to be used for output + */ + public void printStackTrace(java.io.PrintWriter out) + { + super.printStackTrace(out); + + if( getCause () != null ) { + out.println(); + out.print("Nested Exception is "); + getCause ().printStackTrace(out); + } + // change this when going tojdk1.4: + /* + super.printStackTrace(out); + + if( getRootCause () != null ) + { + out.println(); + out.print("Nested Exception is "); + getRootCause ().printStackTrace(out); + } + */ + } + + /** + * Returns the cause of this throwable or null if the + * cause is nonexistent or unknown. (The cause is the throwable that + * caused this throwable to get thrown.) + * + *

This implementation returns the cause that was supplied via one of + * the constructors requiring a Throwable. + * + * @return the cause of this throwable or null if the + * cause is nonexistent or unknown. + */ + public Throwable getCause() { + return (_cause!=null ? _cause : null); + } + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletMode.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletMode.java new file mode 100755 index 000000000..4e078d3a4 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletMode.java @@ -0,0 +1,154 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The PortletMode class represents + * the possible modes that a portlet can assume. + *

+ * A portlet mode indicates the function a portlet is performing. + * Normally, portlets perform different tasks and create different + * content depending on the function they are currently performing. + * When invoking a portlet, the portlet container provides the + * current portlet mode to the portlet. + *

+ * Portlets can programmatically change their portlet + * mode when processing an action request. + *

+ * This class defines the default portlet modes EDIT, HELP, VIEW. + * Additional portlet modes may be defined by calling the constructor + * of this class. If a portal/portlet-container does not support a + * custom portlet mode defined in the portlet application deployment descriptor, + * the custom portlet mode will be ignored by the portal/portlet container. + */ +public class PortletMode +{ + + + /** + * The expected functionality for a portlet in VIEW portlet mode + * is to generate markup reflecting the current state of the portlet. + * For example, the VIEW portlet mode of a portlet may + * include one or more screens that the user can navigate and interact + * with, or it may consist of static content that does not require any + * user interaction. + *

+ * This mode must be supported by the portlet. + *

+ * The string value for this mode is "view". + */ + public final static PortletMode VIEW = new PortletMode ("view"); + + /** + * Within the EDIT portlet mode, a portlet should provide + * content and logic that lets a user customize the behavior of the portlet. + * The EDIT portlet mode may include one or more screens among which + * users can navigate to enter their customization data. + *

+ * Typically, portlets in EDIT portlet mode will + * set or update portlet preferences. + *

+ * This mode is optional. + *

+ * The string value for this mode is "edit". + */ + public final static PortletMode EDIT = new PortletMode ("edit"); + + /** + * When in HELP portlet mode, a portlet should provide help + * information about the portlet. This help information could be + * a simple help screen explaining the entire portlet in + * coherent text or it could be context-sensitive help. + *

+ * This mode is optional. + *

+ * The string value for this mode is "help". + */ + public final static PortletMode HELP = new PortletMode ("help"); + + + + + private String _name; + + + /** + * Creates a new portlet mode with the given name. + *

+ * Upper case letters in the name are converted to + * lower case letters. + * + * @param name The name of the portlet mode + */ + public PortletMode(String name) { + if (name==null) { + throw new IllegalArgumentException("PortletMode name can not be NULL"); + } + _name = name.toLowerCase(); + } + + + /** + * Returns a String representation of this portlet mode. + * Portlet mode names are always lower case names. + * + * @return String representation of this portlet mode + */ + + public String toString() { + return _name; + } + + /** + * Returns the hash code value for this portlet mode. + * The hash code is constructed by producing the + * hash value of the String value of this mode. + * + * @return hash code value for this portlet mode + */ + + public int hashCode() { + return _name.hashCode(); + } + + /** + * Compares the specified object with this portlet mode + * for equality. Returns true if the + * Strings equals method for the String + * representing the two portlet modes returns true. + * + * @param object the portlet mode to compare this portlet mode with + * + * @return true, if the specified object is equal with this portlet mode + */ + + public boolean equals(Object object) { + if ( object instanceof PortletMode ) + return _name.equals(((PortletMode) object)._name); + else + return false; + } +} + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletModeException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletModeException.java new file mode 100755 index 000000000..4a71ec41d --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletModeException.java @@ -0,0 +1,107 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +/** + * The PortletModeException is thrown when a portlet + * tries to use or set a portlet mode that is not supported by the current + * runtime environment or the portlet. + */ + +public class PortletModeException extends PortletException +{ + + + private transient PortletMode _mode = null; + + /** + * Constructs a new portlet mode exception with the given text and the + * portlet mode that caused this exception. The + * portlet container may use the text and portlet mode write it to a log. + * + * @param text + * the exception text + * @param mode + * the mode causing the exception + */ + + public PortletModeException (String text, PortletMode mode) + { + super (text); + _mode = mode; + } + + /** + * Constructs a new portlet mode exception when the portlet needs to do + * the following: + *

    + * throw an exception + *
  • include a message about the "root cause" that interfered + * with its normal operation + *
  • include a description message + *
  • include the portlet mode that caused this exception + *
+ * + * @param text + * the exception text + * @param cause + * the root cause + * @param mode + * the mode causing the exception + */ + + public PortletModeException (String text, Throwable cause, PortletMode mode) + { + super(text, cause); + _mode = mode; + } + + /** + * Constructs a new portlet mode exception when the portlet needs to throw an + * exception. The exception message is based on the localized message + * of the underlying exception and the portlet mode that caused this exception. + * + * @param cause + * the root cause + * @param mode + * the mode causing the exception + */ + + public PortletModeException (Throwable cause, PortletMode mode) + { + super(cause); + _mode = mode; + } + + /** + * Returns the unsupported portlet mode causing this exception. + * + * @return the portlet mode that caused this exception + */ + + public PortletMode getMode() + { + return _mode; + } +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletPreferences.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletPreferences.java new file mode 100755 index 000000000..b308f4017 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletPreferences.java @@ -0,0 +1,265 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The PortletPreferences interface allows the portlet to store + * configuration data. It is not the + * purpose of this interface to replace general purpose databases. + *

+ * There are two different types of preferences: + *

    + *
  • modifiable preferences - these preferences can be changed by the + * portlet in any standard portlet mode (EDIT, HELP, VIEW). + * Per default every preference is modifiable. + *
  • read-only preferences - these preferences cannot be changed by the + * portlet in any standard portlet mode, but may be changed by administrative modes. + * Preferences are read-only, if the are defined in the + * deployment descriptor with read-only set to true, + * or if the portlet container restricts write access. + *
+ *

+ * Changes are persisted when the store method is called. The store method + * can only be invoked within the scope of a processAction call. + * Changes that are not persisted are discarded when the + * processAction or render method ends. + */ +public interface PortletPreferences +{ + + + + + /** + * Returns true, if the value of this key cannot be modified by the user. + *

+ * Modifiable preferences can be changed by the + * portlet in any standard portlet mode (EDIT, HELP, VIEW). + * Per default every preference is modifiable. + *

+ * Read-only preferences cannot be changed by the + * portlet in any standard portlet mode, but inside of custom modes + * it may be allowed changing them. + * Preferences are read-only, if they are defined in the + * deployment descriptor with read-only set to true, + * or if the portlet container restricts write access. + * + * @return false, if the value of this key can be changed, or + * if the key is not known + * + * @exception java.lang.IllegalArgumentException + * if key is null. + */ + public boolean isReadOnly(String key); + + + + /** + * Returns the first String value associated with the specified key of this preference. + * If there is one or more preference values associated with the given key + * it returns the first associated value. + * If there are no preference values associated with the given key, or the + * backing preference database is unavailable, it returns the given + * default value. + * + * @param key key for which the associated value is to be returned + * @param def the value to be returned in the event that there is no + * value available associated with this key. + * + * @return the value associated with key, or def + * if no value is associated with key, or the backing + * store is inaccessible. + * + * @exception java.lang.IllegalArgumentException + * if key is null. (A + * null value for def is permitted.) + * + * @see #getValues(String, String[]) + */ + public String getValue(String key, String def); + + + /** + * Returns the String array value associated with the specified key in this preference. + * + *

Returns the specified default if there is no value + * associated with the key, or if the backing store is inaccessible. + * + *

If the implementation supports stored defaults and such a + * default exists and is accessible, it is used in favor of the + * specified default. + * + * + * @param key key for which associated value is to be returned. + * @param def the value to be returned in the event that this + * preference node has no value associated with key + * or the associated value cannot be interpreted as a String array, + * or the backing store is inaccessible. + * + * @return the String array value associated with + * key, or def if the + * associated value does not exist. + * + * @exception java.lang.IllegalArgumentException if key is null. (A + * null value for def is permitted.) + * + * @see #getValue(String,String) + */ + + public String[] getValues(String key, String[] def); + + + + /** + * Associates the specified String value with the specified key in this + * preference. + *

+ * The key cannot be null, but null values + * for the value parameter are allowed. + * + * @param key key with which the specified value is to be associated. + * @param value value to be associated with the specified key. + * + * @exception ReadOnlyException + * if this preference cannot be modified for this request + * @exception java.lang.IllegalArgumentException if key is null, + * or key.length() + * or value.length are to long. The maximum length + * for key and value are implementation specific. + * + * @see #setValues(String, String[]) + */ + public void setValue(String key, String value) throws ReadOnlyException; + + + + + /** + * Associates the specified String array value with the specified key in this + * preference. + *

+ * The key cannot be null, but null values + * in the values parameter are allowed. + * + * @param key key with which the value is to be associated + * @param values values to be associated with key + * + * @exception java.lang.IllegalArgumentException if key is null, or + * key.length() + * is to long or value.size is to large. The maximum + * length for key and maximum size for value are implementation specific. + * @exception ReadOnlyException + * if this preference cannot be modified for this request + * + * @see #setValue(String,String) + */ + + public void setValues(String key, String[] values) throws ReadOnlyException; + + + /** + * Returns all of the keys that have an associated value, + * or an empty Enumeration if no keys are + * available. + * + * @return an Enumeration of the keys that have an associated value, + * or an empty Enumeration if no keys are + * available. + */ + public java.util.Enumeration getNames(); + + /** + * Returns a Map of the preferences. + *

+ * The values in the returned Map are from type + * String array (String[]). + *

+ * If no preferences exist this method returns an empty Map. + * + * @return an immutable Map containing preference names as + * keys and preference values as map values, or an empty Map + * if no preference exist. The keys in the preference + * map are of type String. The values in the preference map are of type + * String array (String[]). + */ + + public java.util.Map getMap(); + + + /** + * Resets or removes the value associated with the specified key. + *

+ * If this implementation supports stored defaults, and there is such + * a default for the specified preference, the given key will be + * reset to the stored default. + *

+ * If there is no default available the key will be removed. + * + * @param key to reset + * + * @exception java.lang.IllegalArgumentException if key is null. + * @exception ReadOnlyException + * if this preference cannot be modified for this request + */ + + public void reset(String key) throws ReadOnlyException; + + + /** + * Commits all changes made to the preferences via the + * set methods in the persistent store. + *

+ * If this call returns succesfull, all changes are made + * persistent. If this call fails, no changes are made + * in the persistent store. This call is an atomic operation + * regardless of how many preference attributes have been modified. + *

+ * All changes made to preferences not followed by a call + * to the store method are discarded when the + * portlet finishes the processAction method. + *

+ * If a validator is defined for this preferences in the + * deployment descriptor, this validator is called before + * the actual store is performed to check wether the given + * preferences are vaild. If this check fails a + * ValidatorException is thrown. + * + * @exception java.io.IOException + * if changes cannot be written into + * the backend store + * @exception ValidatorException + * if the validation performed by the + * associated validator fails + * @exception java.lang.IllegalStateException + * if this method is called inside a render call + * + * @see PreferencesValidator + */ + + public void store() throws java.io.IOException, ValidatorException; + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequest.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequest.java new file mode 100755 index 000000000..967d52f43 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequest.java @@ -0,0 +1,669 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The PortletRequest defines the base interface to provide client + * request information to a portlet. The portlet container uses two specialized + * versions of this interface when invoking a portlet, ActionRequest + * and RenderRequest. The portlet container creates these objects and + * passes them as arguments to the portlet's processAction and + * render methods. + * + * @see ActionRequest + * @see RenderRequest + */ +public interface PortletRequest +{ + + + /** Used to retrieve user information attributes with the + * getAttribute call. The user information is returned + * as a Map object. The portlet must define the + * user information attribute it is interested in inside the + * user-attribute section of the deployment descriptor. + * If an attribute is not supported + * by the current runtime system it will not show up in the user + * attribute map.
+ * If the user-attribute is supported by the runtime system, but not + * defined for a particular user, then for that user the attribute + * exists in the returned map and the attribute has a null value. + *

+ * If the user-attribute is not defined for the current user it + * will not show up in the Map. + *

+ * The value is javax.portlet.userinfo. + */ + public static final String USER_INFO = "javax.portlet.userinfo"; + + + /** + * String identifier for Basic authentication. Value "BASIC". + */ + public static final String BASIC_AUTH = "BASIC"; + + /** + * String identifier for Form based authentication. Value "FORM". + */ + public static final String FORM_AUTH = "FORM"; + + /** + * String identifier for Certification based authentication. Value "CLIENT_CERT". + */ + public static final String CLIENT_CERT_AUTH = "CLIENT_CERT"; + + /** + * String identifier for Digest based authentication. Value "DIGEST". + */ + public static final String DIGEST_AUTH = "DIGEST"; + + + /** + * Returns true, if the given window state is valid + * to be set for this portlet in the context + * of the current request. + * + * @param state window state to checked + * + * @return true, if it is valid for this portlet + * in this request to change to the + * given window state + * + */ + public boolean isWindowStateAllowed(WindowState state); + + + /** + * Returns true, if the given portlet mode is a valid + * one to set for this portlet in the context + * of the current request. + * + * @param mode portlet mode to check + * + * @return true, if it is valid for this portlet + * in this request to change to the + * given portlet mode + * + */ + + public boolean isPortletModeAllowed(PortletMode mode); + + + /** + * Returns the current portlet mode of the portlet. + * + * @return the portlet mode + */ + + public PortletMode getPortletMode (); + + + /** + * Returns the current window state of the portlet. + * + * @return the window state + */ + + public WindowState getWindowState (); + + + /** + * Returns the preferences object associated with the portlet. + * + * @return the portlet preferences + */ + public PortletPreferences getPreferences (); + + + /** + * Returns the current portlet session or, if there is no current session, + * creates one and returns the new session. + *

+ * Creating a new portlet session will result in creating + * a new HttpSession on which the portlet session is based on. + * + * @return the portlet session + */ + + public PortletSession getPortletSession (); + + + /** + * Returns the current portlet session or, if there is no current session + * and the given flag is true, creates one and returns + * the new session. + *

+ * If the given flag is false and there is no current + * portlet session, this method returns null. + *

+ * Creating a new portlet session will result in creating + * a new HttpSession on which the portlet session is based on. + * + * @param create + * true to create a new session,
+ * false to return null if there + * is no current session + * @return the portlet session + */ + + public PortletSession getPortletSession (boolean create); + + + /** + * Returns the value of the specified request property + * as a String. If the request did not include a property + * of the specified name, this method returns null. + *

+ * A portlet can access portal/portlet-container specific properties + * through this method and, if available, the + * headers of the HTTP client request. + *

+ * This method should only be used if the + * property has only one value. If the property might have + * more than one value, use {@link #getProperties}. + *

+ * If this method is used with a multivalued + * parameter, the value returned is equal to the first value + * in the Enumeration returned by getProperties. + * + * @param name a String specifying the + * property name + * + * @return a String containing the + * value of the requested + * property, or null + * if the request does not + * have a property of that name. + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public String getProperty(String name); + + + /** + * Returns all the values of the specified request property + * as a Enumeration of String objects. + *

+ * If the request did not include any propertys + * of the specified name, this method returns an empty + * Enumeration. + * The property name is case insensitive. You can use + * this method with any request property. + * + * @param name a String specifying the + * property name + * + * @return a Enumeration containing + * the values of the requested property. If + * the request does not have any properties of + * that name return an empty Enumeration. + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public java.util.Enumeration getProperties(String name); + + + /** + * + * Returns a Enumeration of all the property names + * this request contains. If the request has no + * properties, this method returns an empty Enumeration. + * + * + * @return an Enumeration of all the + * property names sent with this + * request; if the request has + * no properties, an empty Enumeration. + */ + + public java.util.Enumeration getPropertyNames(); + + + /** + * Returns the context of the calling portal. + * + * @return the context of the calling portal + */ + + public PortalContext getPortalContext(); + + + /** + * Returns the name of the authentication scheme used for the + * connection between client and portal, + * for example, BASIC_AUTH, CLIENT_CERT_AUTH, + * a custom one or null if there was no authentication. + * + * @return one of the static members BASIC_AUTH, + * FORM_AUTH, CLIENT_CERT_AUTH, + * DIGEST_AUTH (suitable for == comparison) + * indicating the authentication scheme, + * a custom one, or + * null if the request was + * not authenticated. + */ + + public java.lang.String getAuthType(); + + + /** + * Returns the context path which is the path prefix associated with the deployed + * portlet application. If the portlet application is rooted at the + * base of the web server URL namespace (also known as "default" context), + * this path must be an empty string. Otherwise, it must be the path the + * portlet application is rooted to, the path must start with a '/' and + * it must not end with a '/' character. + *

+ * To encode a URL the {@link PortletResponse#encodeURL} method must be used. + * + * @return a String specifying the + * portion of the request URL that indicates the context + * of the request + * + * @see PortletResponse#encodeURL + */ + + public String getContextPath(); + + + /** + * Returns the login of the user making this request, if the user + * has been authenticated, or null if the user has not been authenticated. + * + * @return a String specifying the login + * of the user making this request, or null + * if the user login is not known. + * + */ + + public java.lang.String getRemoteUser(); + + + /** + * Returns a java.security.Principal object containing the name of the + * current authenticated user. + * + * @return a java.security.Principal containing + * the name of the user making this request, or + * null if the user has not been + * authenticated. + */ + + public java.security.Principal getUserPrincipal(); + + + /** + * Returns a boolean indicating whether the authenticated user is + * included in the specified logical "role". Roles and role membership can be + * defined using deployment descriptors. If the user has not been + * authenticated, the method returns false. + * + * @param role a String specifying the name + * of the role + * + * @return a boolean indicating whether + * the user making this request belongs to a given role; + * false if the user has not been + * authenticated. + */ + + public boolean isUserInRole(java.lang.String role); + + + /** + * + * Returns the value of the named attribute as an Object, + * or null if no attribute of the given name exists. + *

+ * Attribute names should follow the same conventions as package + * names. This specification reserves names matching java.*, + * and javax.*. + *

+ * In a distributed portlet web application the Object + * needs to be serializable. + * + * @param name a String specifying the name of + * the attribute + * + * @return an Object containing the value + * of the attribute, or null if + * the attribute does not exist. + * + * @exception java.lang.IllegalArgumentException + * if name is null. + * + */ + + public Object getAttribute(String name); + + + /** + * Returns an Enumeration containing the + * names of the attributes available to this request. + * This method returns an empty Enumeration + * if the request has no attributes available to it. + * + * + * @return an Enumeration of strings + * containing the names + * of the request attributes, or an empty + * Enumeration if the request + * has no attributes available to it. + */ + + public java.util.Enumeration getAttributeNames(); + + + /** + * Returns the value of a request parameter as a String, + * or null if the parameter does not exist. Request parameters + * are extra information sent with the request. The returned parameter + * are "x-www-form-urlencoded" decoded. + *

+ * Only parameters targeted to the current portlet are accessible. + *

+ * This method should only be used if the + * parameter has only one value. If the parameter might have + * more than one value, use {@link #getParameterValues}. + *

+ * If this method is used with a multivalued + * parameter, the value returned is equal to the first value + * in the array returned by getParameterValues. + * + * + * + * @param name a String specifying the + * name of the parameter + * + * @return a String representing the + * single value of the parameter + * + * @see #getParameterValues + * + * @exception java.lang.IllegalArgumentException + * if name is null. + * + */ + + public String getParameter(String name); + + + /** + * + * Returns an Enumeration of String + * objects containing the names of the parameters contained + * in this request. If the request has + * no parameters, the method returns an + * empty Enumeration. + *

+ * Only parameters targeted to the current portlet are returned. + * + * + * @return an Enumeration of String + * objects, each String containing + * the name of a request parameter; or an + * empty Enumeration if the + * request has no parameters. + */ + + public java.util.Enumeration getParameterNames(); + + + /** + * Returns an array of String objects containing + * all of the values the given request parameter has, or + * null if the parameter does not exist. + * The returned parameters are "x-www-form-urlencoded" decoded. + *

+ * If the parameter has a single value, the array has a length + * of 1. + * + * + * @param name a String containing the name of + * the parameter the value of which is requested + * + * @return an array of String objects + * containing the parameter values. + * + * @see #getParameter + * + * @exception java.lang.IllegalArgumentException + * if name is null. + * + */ + + public String[] getParameterValues(String name); + + + /** + * Returns a Map of the parameters of this request. + * Request parameters are extra information sent with the request. + * The returned parameters are "x-www-form-urlencoded" decoded. + *

+ * The values in the returned Map are from type + * String array (String[]). + *

+ * If no parameters exist this method returns an empty Map. + * + * @return an immutable Map containing parameter names as + * keys and parameter values as map values, or an empty Map + * if no parameters exist. The keys in the parameter + * map are of type String. The values in the parameter map are of type + * String array (String[]). + */ + + public java.util.Map getParameterMap(); + + + /** + * Returns a boolean indicating whether this request was made + * using a secure channel between client and the portal, such as HTTPS. + * + * @return true, if the request was made using a secure channel. + */ + + public boolean isSecure(); + + + /** + * Stores an attribute in this request. + * + *

Attribute names should follow the same conventions as + * package names. Names beginning with java.*, + * javax.*, and com.sun.* are + * reserved for use by Sun Microsystems. + *
If the value passed into this method is null, + * the effect is the same as calling {@link #removeAttribute}. + * + * + * @param name a String specifying + * the name of the attribute + * + * @param o the Object to be stored + * + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void setAttribute(String name, Object o); + + + /** + * + * Removes an attribute from this request. This method is not + * generally needed, as attributes only persist as long as the request + * is being handled. + * + *

Attribute names should follow the same conventions as + * package names. Names beginning with java.*, + * javax.*, and com.sun.* are + * reserved for use by Sun Microsystems. + * + * @param name a String specifying + * the name of the attribute to be removed + * + * + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void removeAttribute(String name); + + + /** + * + * Returns the session ID indicated in the client request. + * This session ID may not be a valid one, it may be an old + * one that has expired or has been invalidated. + * If the client request + * did not specify a session ID, this method returns + * null. + * + * @return a String specifying the session + * ID, or null if the request did + * not specify a session ID + * + * @see #isRequestedSessionIdValid + * + */ + + public String getRequestedSessionId(); + + + /** + * + * Checks whether the requested session ID is still valid. + * + * @return true if this + * request has an id for a valid session + * in the current session context; + * false otherwise + * + * @see #getRequestedSessionId + * @see #getPortletSession + */ + + public boolean isRequestedSessionIdValid(); + + + /** + * Returns the portal preferred content type for the response. + *

+ * The content type only includes the MIME type, not the + * character set. + *

+ * Only content types that the portlet has defined in its + * deployment descriptor are valid return values for + * this method call. If the portlet has defined + * '*' or '* / *' as supported content + * types, these may also be valid return values. + * + * @return preferred MIME type of the response + */ + + public String getResponseContentType(); + + + /** + * Gets a list of content types which the portal accepts for the response. + * This list is ordered with the most preferable types listed first. + *

+ * The content type only includes the MIME type, not the + * character set. + *

+ * Only content types that the portlet has defined in its + * deployment descriptor are valid return values for + * this method call. If the portlet has defined + * '*' or '* / *' as supported content + * types, these may also be valid return values. + * + * @return ordered list of MIME types for the response + */ + + public java.util.Enumeration getResponseContentTypes(); + + + /** + * Returns the preferred Locale in which the portal will accept content. + * The Locale may be based on the Accept-Language header of the client. + * + * @return the prefered Locale in which the portal will accept content. + */ + + public java.util.Locale getLocale(); + + + /** + * Returns an Enumeration of Locale objects indicating, in decreasing + * order starting with the preferred locale in which the portal will + * accept content for this request. + * The Locales may be based on the Accept-Language header of the client. + * + * @return an Enumeration of Locales, in decreasing order, in which + * the portal will accept content for this request + */ + + public java.util.Enumeration getLocales(); + + + /** + * Returns the name of the scheme used to make this request. + * For example, http, https, or ftp. + * Different schemes have different rules for constructing URLs, + * as noted in RFC 1738. + * + * @return a String containing the name + * of the scheme used to make this request + */ + + public String getScheme(); + + + /** + * Returns the host name of the server that received the request. + * + * @return a String containing the name + * of the server to which the request was sent + */ + + public String getServerName(); + + + /** + * Returns the port number on which this request was received. + * + * @return an integer specifying the port number + */ + + public int getServerPort(); + + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequestDispatcher.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequestDispatcher.java new file mode 100755 index 000000000..f81379540 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletRequestDispatcher.java @@ -0,0 +1,80 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The PortletRequestDispatcher interface + * defines an object that receives requests from the client + * and sends them to the specified resources (such as a servlet, + * HTML file, or JSP file) on the server. The portlet + * container creates the PortletRequestDispatcher object, + * which is used as a wrapper around a server resource located + * at a particular path or given by a particular name. + * + */ + +public interface PortletRequestDispatcher { + + + /** + * + * Includes the content of a resource (servlet, JSP page, + * HTML file) in the response. In essence, this method enables + * programmatic server-side includes. + *

+ * The included servlet cannot set or change the response status code + * or set headers; any attempt to make a change is ignored. + * + * + * @param request a {@link RenderRequest} object + * that contains the client request + * + * @param response a {@link RenderResponse} object + * that contains the render response + * + * @exception PortletException if the included resource throws a ServletException, + * or other exceptions that are not Runtime- + * or IOExceptions. + * + * @exception java.io.IOException if the included resource throws this exception + * + * + */ + + public void include(RenderRequest request, RenderResponse response) + throws PortletException, java.io.IOException; + + + +} + + + + + + + + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletResponse.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletResponse.java new file mode 100755 index 000000000..217210ad5 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletResponse.java @@ -0,0 +1,113 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The PortletResponse defines the base interface to assist a + * portlet in creating and sending a response to the client. + * The portlet container uses two specialized versions of this interface + * when invoking a portlet, ActionResponse and + * RenderResponse. The portlet container creates these + * objects and passes them as arguments to the portlet's processAction + * and render methods. + * + * @see ActionResponse + * @see RenderResponse + */ +public interface PortletResponse +{ + + + + /** + * Adds a String property to an existing key to be returned to the portal. + *

+ * This method allows response properties to have multiple values. + *

+ * Properties can be used by portlets to provide vendor specific + * information to the portal. + * + * @param key the key of the property to be returned to the portal + * @param value the value of the property to be returned to the portal + * + * @exception java.lang.IllegalArgumentException + * if key is null. + */ + + public void addProperty(String key, String value); + + + /** + * Sets a String property to be returned to the portal. + *

+ * Properties can be used by portlets to provide vendor specific + * information to the portal. + *

+ * This method resets all properties previously added with the same key. + * + * @param key the key of the property to be returned to the portal + * @param value the value of the property to be returned to the portal + * + * @exception java.lang.IllegalArgumentException + * if key is null. + */ + + public void setProperty(String key, String value); + + + /** + * Returns the encoded URL of the resource, like servlets, + * JSPs, images and other static files, at the given path. + *

+ * Some portal/portlet-container implementation may require + * those URLs to contain implementation specific data encoded + * in it. Because of that, portlets should use this method to + * create such URLs. + *

+ * The encodeURL method may include the session ID + * and other portal/portlet-container specific information into the URL. + * If encoding is not needed, it returns the URL unchanged. + * + * @param path + * the URI path to the resource. This must be either + * an absolute URL (e.g. + * http://my.co/myportal/mywebap/myfolder/myresource.gif) + * or a full path URI (e.g. /myportal/mywebap/myfolder/myresource.gif). + * + * @exception java.lang.IllegalArgumentException + * if path doesn't have a leading slash or is not an absolute URL + * + * @return the encoded resource URL as string + */ + + public String encodeURL (String path); + + + + + +} + + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSecurityException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSecurityException.java new file mode 100755 index 000000000..b5abedb63 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSecurityException.java @@ -0,0 +1,89 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +/** + * A portlet should throw a PortletSecurityException + * when a call fails because of security reasons.
+ * Additionally it can be thrown by the portal/portlet-container. + */ + +public class PortletSecurityException extends PortletException +{ + + + private PortletSecurityException () + { + } + + /** + * Constructs a new security exception with the given text. The + * portlet container may use the text write it to a log. + * + * @param text + * the exception text + */ + + public PortletSecurityException (String text) + { + super (text); + } + + /** + * Constructs a new portlet security exception when the portlet needs to do + * the following: + *

    + * throw an exception + *
  • include a message about the "root cause" that interfered + * with its normal operation + *
  • include a description message + *
+ * + * @param text + * the exception text + * @param cause + * the root cause + */ + + public PortletSecurityException (String text, Throwable cause) + { + super(text, cause); + } + + /** + * Constructs a new portlet security exception when the portlet needs to throw an + * exception. The exception message is based on the localized message + * of the underlying exception. + * + * @param cause + * the root cause + */ + + public PortletSecurityException (Throwable cause) + { + super(cause); + } + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSession.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSession.java new file mode 100755 index 000000000..d26efb5de --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSession.java @@ -0,0 +1,377 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The PortletSession interface provides a way to identify a user + * across more than one request and to store transient information about that user. + *

+ * A PortletSession is created per user client per portlet application. + *

+ * A portlet can bind an object attribute into a PortletSession by name. + * The PortletSession interface defines two scopes for storing objects: + *

    + *
  • APPLICATION_SCOPE + *
  • PORTLET_SCOPE + *
+ * All objects stored in the session using the APPLICATION_SCOPE + * must be available to all the portlets, servlets and + * JSPs that belongs to the same portlet application and that handles a + * request identified as being a part of the same session. + * Objects stored in the session using the PORTLET_SCOPE must be + * available to the portlet during requests for the same portlet window + * that the objects where stored from. Attributes stored in the + * PORTLET_SCOPE are not protected from other web components + * of the portlet application. They are just conveniently namespaced. + *

+ * The portlet session is based on the HttpSession. Therefore all + * HttpSession listeners do apply to the portlet session and + * attributes set in the portlet session are visible in the HttpSession + * and vice versa. + */ +public interface PortletSession +{ + + + /** + * This constant defines an application wide scope for the session attribute. + * APPLICATION_SCOPE session attributes enable Portlets + * within one portlet application to share data. + *

+ * Portlets may need to prefix attributes set in this scope with some + * ID, to avoid overwriting each other's attributes in the + * case where two portlets of the same portlet definition + * are created. + *

+ * Value: 0x01 + */ + public static final int APPLICATION_SCOPE = 0x01; + + /** + * This constant defines the scope of the session attribute to be + * private to the portlet and its included resources. + *

+ * Value: 0x02 + */ + public static final int PORTLET_SCOPE = 0x02; + + + + /** + * Returns the object bound with the specified name in this session + * under the PORTLET_SCOPE, or null if no + * object is bound under the name in that scope. + * + * @param name a string specifying the name of the object + * + * @return the object with the specified name for + * the PORTLET_SCOPE. + * + * @exception java.lang.IllegalStateException if this method is called on an + * invalidated session. + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public java.lang.Object getAttribute(java.lang.String name); + + + /** + * Returns the object bound with the specified name in this session, + * or null if no object is bound under the name in the given scope. + * + * @param name a string specifying the name of the object + * @param scope session scope of this attribute + * + * @return the object with the specified name + * + * @exception java.lang.IllegalStateException if this method is called on an + * invalidated session + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public java.lang.Object getAttribute(java.lang.String name,int scope); + + + /** + * Returns an Enumeration of String objects containing the names of + * all the objects bound to this session under the PORTLET_SCOPE, or an + * empty Enumeration if no attributes are available. + * + * @return an Enumeration of + * String objects specifying the + * names of all the objects bound to + * this session, or an empty Enumeration + * if no attributes are available. + * + * @exception java.lang.IllegalStateException if this method is called on an + * invalidated session + */ + + public java.util.Enumeration getAttributeNames(); + + + /** + * Returns an Enumeration of String objects containing the names of + * all the objects bound to this session in the given scope, or an + * empty Enumeration if no attributes are available in the + * given scope. + * + * @param scope session scope of the attribute names + * + * @return an Enumeration of + * String objects specifying the + * names of all the objects bound to + * this session, or an empty Enumeration + * if no attributes are available in the given scope. + * + * @exception java.lang.IllegalStateException if this method is called on an + * invalidated session + */ + + public java.util.Enumeration getAttributeNames(int scope); + + /** + * Returns the time when this session was created, measured in + * milliseconds since midnight January 1, 1970 GMT. + * + * @return a long specifying + * when this session was created, + * expressed in + * milliseconds since 1/1/1970 GMT + * + * @exception java.lang.IllegalStateException if this method is called on an + * invalidated session + */ + + public long getCreationTime(); + + + /** + * Returns a string containing the unique identifier assigned to this session. + * + * @return a string specifying the identifier + * assigned to this session + */ + + public java.lang.String getId(); + + + /** + * Returns the last time the client sent a request associated with this session, + * as the number of milliseconds since midnight January 1, 1970 GMT. + * + *

Actions that your portlet takes, such as getting or setting + * a value associated with the session, do not affect the access + * time. + * + * @return a long + * representing the last time + * the client sent a request associated + * with this session, expressed in + * milliseconds since 1/1/1970 GMT + */ + + public long getLastAccessedTime(); + + + /** + * Returns the maximum time interval, in seconds, for which the portlet container + * keeps this session open between client accesses. After this interval, + * the portlet container invalidates the session. The maximum time + * interval can be set + * with the setMaxInactiveInterval method. + * A negative time indicates the session should never timeout. + * + * @return an integer specifying the number of + * seconds this session remains open + * between client requests + * + * @see #setMaxInactiveInterval + */ + + public int getMaxInactiveInterval(); + + + /** + * Invalidates this session (all scopes) and unbinds any objects bound to it. + *

+ * Invalidating the portlet session will result in invalidating the underlying + * HttpSession + * + * @exception java.lang.IllegalStateException if this method is called on a + * session which has already been invalidated + */ + + public void invalidate(); + + + + /** + * Returns true if the client does not yet know about the session or + * if the client chooses not to join the session. + * + * @return true if the + * server has created a session, + * but the client has not joined yet. + * + * @exception java.lang.IllegalStateException if this method is called on a + * session which has already been invalidated + * + */ + + public boolean isNew(); + + + /** + * Removes the object bound with the specified name under + * the PORTLET_SCOPE from + * this session. If the session does not have an object + * bound with the specified name, this method does nothing. + * + * @param name the name of the object to be + * removed from this session in the + * PORTLET_SCOPE. + * + * @exception java.lang.IllegalStateException + * if this method is called on a + * session which has been invalidated + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void removeAttribute(String name) ; + + + /** + * Removes the object bound with the specified name and the given scope from + * this session. If the session does not have an object + * bound with the specified name, this method does nothing. + * + * @param name the name of the object to be + * removed from this session + * @param scope session scope of this attribute + * + * @exception java.lang.IllegalStateException + * if this method is called on a + * session which has been invalidated + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void removeAttribute(String name, int scope) ; + + + /** + * Binds an object to this session under the PORTLET_SCOPE, using the name specified. + * If an object of the same name in this scope is already bound to the session, + * that object is replaced. + * + *

After this method has been executed, and if the new object + * implements HttpSessionBindingListener, + * the container calls + * HttpSessionBindingListener.valueBound. The container then + * notifies any HttpSessionAttributeListeners in the web + * application. + *

If an object was already bound to this session + * that implements HttpSessionBindingListener, its + * HttpSessionBindingListener.valueUnbound method is called. + * + *

If the value is null, this has the same effect as calling + * removeAttribute(). + * + * + * @param name the name to which the object is bound under + * the PORTLET_SCOPE; + * this cannot be null. + * @param value the object to be bound + * + * @exception java.lang.IllegalStateException if this method is called on a + * session which has been invalidated + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void setAttribute(java.lang.String name, java.lang.Object value); + + + /** + * Binds an object to this session in the given scope, using the name specified. + * If an object of the same name in this scope is already bound to the session, + * that object is replaced. + * + *

After this method has been executed, and if the new object + * implements HttpSessionBindingListener, + * the container calls + * HttpSessionBindingListener.valueBound. The container then + * notifies any HttpSessionAttributeListeners in the web + * application. + *

If an object was already bound to this session + * that implements HttpSessionBindingListener, its + * HttpSessionBindingListener.valueUnbound method is called. + * + *

If the value is null, this has the same effect as calling + * removeAttribute(). + * + * + * @param name the name to which the object is bound; + * this cannot be null. + * @param value the object to be bound + * @param scope session scope of this attribute + * + * @exception java.lang.IllegalStateException if this method is called on a + * session which has been invalidated + * @exception java.lang.IllegalArgumentException + * if name is null. + */ + + public void setAttribute(java.lang.String name, java.lang.Object value, int scope); + + + /** + * Specifies the time, in seconds, between client requests, before the + * portlet container invalidates this session. A negative time + * indicates the session should never timeout. + * + * @param interval An integer specifying the number + * of seconds + */ + + public void setMaxInactiveInterval(int interval); + + + /** + * Returns the portlet application context associated with this session. + * + * @return the portlet application context + */ + + public PortletContext getPortletContext (); + +} + + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSessionUtil.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSessionUtil.java new file mode 100755 index 000000000..b7d0f3b40 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletSessionUtil.java @@ -0,0 +1,90 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +/** + * The PortletSessionUtil class helps identify and decode + * attributes in the PORTLET_SCOPE scope of the PortletSession + * when accessed through the HttpSession an from within calls to methods + * of the HttpSessionBindingListener interface. + */ +public class PortletSessionUtil +{ + + + private static final String PORTLET_SCOPE_NAMESPACE = "javax.portlet.p."; + + /** + * Returns the attribute name of an attribute in the + * PORTLET_SCOPE. If the attribute is in the + * APPLICATION_SCOPE it returns the attribute name unchanged. + * + * @param name a string specifying the name of the + * encoded portlet attribute + * + * @return the decoded attribute name + */ + + public static java.lang.String decodeAttributeName(java.lang.String name) + { + if (name.startsWith(PORTLET_SCOPE_NAMESPACE)) { + int index = name.indexOf('?'); + if (index>-1) { + name = name.substring(index+1); + } + } + return name; + } + + + /** + * Returns the portlet attribute scope from an encoded portlet + * attribute. + *
Possible return values are: + *

    + *
  • PortletSession.APPLICATION_SCOPE
  • + *
  • PortletSession.PORTLET_SCOPE
  • + *
+ * + * @param name a string specifying the name of the + * encoded portlet attribute + * + * @return the decoded attribute scope + * @see PortletSession + */ + + public static int decodeScope(java.lang.String name) + { + int scope = PortletSession.APPLICATION_SCOPE; // APP + if (name.startsWith(PORTLET_SCOPE_NAMESPACE)) { + int index = name.indexOf('?'); + if (index>-1) { + scope = PortletSession.PORTLET_SCOPE; // PORTLET + } + } + return scope; + } +} + + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PortletURL.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletURL.java new file mode 100755 index 000000000..2a2d05d71 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PortletURL.java @@ -0,0 +1,211 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + + +/** + * The PortletURL interface represents a URL + * that reference the portlet itself. + *

+ * A PortletURL is created through the RenderResponse. + * Parameters, a portlet mode, a window state and a security level + * can be added to PortletURL objects. The PortletURL + * must be converted to a String in order to embed it into + * the markup generated by the portlet. + *

+ * There are two types of PortletURLs: + *

    + *
  • Action URLs, they are created with RenderResponse.createActionURL, and + * trigger an action request followed by a render request. + *
  • Render URLs, they are created with RenderResponse.createRenderURL, and + * trigger a render request. + *
+ *

+ * The string reprensentation of a PortletURL does not need to be a valid + * URL at the time the portlet is generating its content. It may contain + * special tokens that will be converted to a valid URL, by the portal, + * before the content is returned to the client. + */ +public interface PortletURL +{ + + + + + /** + * Indicates the window state the portlet should be in, if this + * portlet URL triggers a request. + *

+ * A URL can not have more than one window state attached to it. + * If more than one window state is set only the last one set + * is attached to the URL. + * + * @param windowState + * the portlet window state + * + * @exception WindowStateException + * if the portlet cannot switch to this state, + * because the portal does not support this state, the portlet has not + * declared in its deployment descriptor that it supports this state, or the current + * user is not allowed to switch to this state. + * The PortletRequest.isWindowStateAllowed() method can be used + * to check if the portlet can set a given window state. + * @see PortletRequest#isWindowStateAllowed + */ + public void setWindowState (WindowState windowState) + throws WindowStateException; + + + /** + * Indicates the portlet mode the portlet must be in, if this + * portlet URL triggers a request. + *

+ * A URL can not have more than one portlet mode attached to it. + * If more than one portlet mode is set only the last one set + * is attached to the URL. + * + * @param portletMode + * the portlet mode + * + * @exception PortletModeException + * if the portlet cannot switch to this mode, + * because the portal does not support this mode, the portlet has not + * declared in its deployment descriptor that it supports this mode for the current markup, + * or the current user is not allowed to switch to this mode. + * The PortletRequest.isPortletModeAllowed() method can be used + * to check if the portlet can set a given portlet mode. + * @see PortletRequest#isPortletModeAllowed + */ + public void setPortletMode (PortletMode portletMode) + throws PortletModeException; + + + /** + * Sets the given String parameter to this URL. + *

+ * This method replaces all parameters with the given key. + *

+ * The PortletURL implementation 'x-www-form-urlencoded' encodes + * all parameter names and values. Developers should not encode them. + *

+ * A portlet container may prefix the attribute names internally + * in order to preserve a unique namespace for the portlet. + * + * @param name + * the parameter name + * @param value + * the parameter value + * + * @exception java.lang.IllegalArgumentException + * if name or value are null. + */ + + public void setParameter (String name, String value); + + + /** + * Sets the given String array parameter to this URL. + *

+ * This method replaces all parameters with the given key. + *

+ * The PortletURL implementation 'x-www-form-urlencoded' encodes + * all parameter names and values. Developers should not encode them. + *

+ * A portlet container may prefix the attribute names internally + * in order to preserve a unique namespace for the portlet. + * + * @param name + * the parameter name + * @param values + * the parameter values + * + * @exception java.lang.IllegalArgumentException + * if name or values are null. + */ + + public void setParameter (String name, String[] values); + + + /** + * Sets a parameter map for this URL. + *

+ * All previously set parameters are cleared. + *

+ * The PortletURL implementation 'x-www-form-urlencoded' encodes + * all parameter names and values. Developers should not encode them. + *

+ * A portlet container may prefix the attribute names internally, + * in order to preserve a unique namespace for the portlet. + * + * @param parameters Map containing parameter names for + * the render phase as + * keys and parameter values as map + * values. The keys in the parameter + * map must be of type String. The values + * in the parameter map must be of type + * String array (String[]). + * + * @exception java.lang.IllegalArgumentException + * if parameters is null, if + * any of the key/values in the Map are null, + * if any of the keys is not a String, or if any of + * the values is not a String array. + */ + + public void setParameters(java.util.Map parameters); + + + /** + * Indicated the security setting for this URL. + *

+ * Secure set to true indicates that the portlet requests + * a secure connection between the client and the portlet window for + * this URL. Secure set to false indicates that the portlet + * does not need a secure connection for this URL. If the security is not + * set for a URL, it will stay the same as the current request. + * + * @param secure true, if portlet requests to have a secure connection + * between its portlet window and the client; false, if + * the portlet does not require a secure connection. + * + * @throws PortletSecurityException if the run-time environment does + * not support the indicated setting + */ + + public void setSecure (boolean secure) throws PortletSecurityException; + + + /** + * Returns the portlet URL string representation to be embedded in the + * markup.
+ * Note that the returned String may not be a valid URL, as it may + * be rewritten by the portal/portlet-container before returning the + * markup to the client. + * + * @return the encoded URL as a string + */ + + public String toString (); +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/PreferencesValidator.java b/fine-portlet-api/src/com/fr/third/javax/portlet/PreferencesValidator.java new file mode 100755 index 000000000..95673b6bc --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/PreferencesValidator.java @@ -0,0 +1,53 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The PreferencesValidator allows to validate the set of + * preferences of the associated portlet just before they are + * stored in the persistent store. + *

+ * The portlet container invokes the validate method as + * part of the invocation of the store method of the + * PortletPreferences. + */ +public interface PreferencesValidator +{ + + + /** + * If the preferences values are successfully validated the call to this method + * must finish gracefully. Otherwise it must throw a ValidatorException. + * + * @param preferences preferences to validate + * + * @throws ValidatorException if the given preferences contains invalid + * settings + * + */ + + public void validate(PortletPreferences preferences) + throws ValidatorException; +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/ReadOnlyException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/ReadOnlyException.java new file mode 100755 index 000000000..eb700278e --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/ReadOnlyException.java @@ -0,0 +1,88 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +/** + * The ReadOnlyException is thrown when a portlet tries + * to change the value for a read-only preference attribute. + */ + +public class ReadOnlyException extends PortletException +{ + + + private ReadOnlyException () + { + } + + /** + * Constructs a new read-only exception with the given text. The + * portlet container may use the text write it to a log. + * + * @param text + * the exception text + */ + + public ReadOnlyException (String text) + { + super (text); + } + + /** + * Constructs a new read-only exception when the portlet needs to do + * the following: + *

    + * throw an exception + *
  • include a message about the "root cause" that interfered + * with its normal operation + *
  • include a description message + *
+ * + * @param text + * the exception text + * @param cause + * the root cause + */ + + public ReadOnlyException (String text, Throwable cause) + { + super(text, cause); + } + + /** + * Constructs a new read-only exception when the portlet needs to throw an + * exception. The exception message is based on the localized message + * of the underlying exception. + * + * @param cause + * the root cause + */ + + public ReadOnlyException (Throwable cause) + { + super(cause); + } + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/RenderRequest.java b/fine-portlet-api/src/com/fr/third/javax/portlet/RenderRequest.java new file mode 100755 index 000000000..e6e025ebe --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/RenderRequest.java @@ -0,0 +1,43 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The RenderRequest represents the request sent to the portlet + * to handle a render. + * It extends the PortletRequest interface to provide render request + * information to portlets.
+ * The portlet container creates a RenderRequest object and + * passes it as argument to the portlet's render method. + * + * @see PortletRequest + * @see ActionRequest + */ +public interface RenderRequest extends PortletRequest +{ + + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/RenderResponse.java b/fine-portlet-api/src/com/fr/third/javax/portlet/RenderResponse.java new file mode 100755 index 000000000..60ea6b781 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/RenderResponse.java @@ -0,0 +1,342 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The RenderResponse defines an object to assist a portlet in + * sending a response to the portal. + * It extends the PortletResponse interface to provide specific + * render response functionality to portlets.
+ * The portlet container creates a RenderResponse object and + * passes it as argument to the portlet's render method. + * + * @see RenderRequest + * @see PortletResponse + */ +public interface RenderResponse extends PortletResponse +{ + + + /** + * Property to set the expiration time in seconds for this + * response using the setProperty method. + *

+ * If the expiration value is set to 0, caching is disabled + * for this portlet; if the value is set to -1, + * the cache does not expire. + *

+ * The value is "portlet.expiration-cache". + */ + public static final String EXPIRATION_CACHE = "portlet.expiration-cache"; + + /** + * Returns the MIME type that can be used to contribute + * markup to the render response. + *

+ * If no content type was set previously using the {@link #setContentType} method + * this method retuns null. + * + * @see #setContentType + * + * @return the MIME type of the response, or null + * if no content type is set + */ + + public String getContentType (); + + + /** + * Creates a portlet URL targeting the portlet. If no portlet mode, + * window state or security modifier is set in the PortletURL the + * current values are preserved. If a request is triggered by the + * PortletURL, it results in a render request. + *

+ * The returned URL can be further extended by adding + * portlet-specific parameters and portlet modes and window states. + *

+ * The created URL will per default not contain any parameters + * of the current render request. + * + * @return a portlet render URL + */ + public PortletURL createRenderURL (); + + + /** + * Creates a portlet URL targeting the portlet. If no portlet mode, + * window state or security modifier is set in the PortletURL the + * current values are preserved. If a request is triggered by the + * PortletURL, it results in an action request. + *

+ * The returned URL can be further extended by adding + * portlet-specific parameters and portlet modes and window states. + *

+ * The created URL will per default not contain any parameters + * of the current render request. + * + * @return a portlet action URL + */ + public PortletURL createActionURL (); + + + + /** + * The value returned by this method should be prefixed or appended to + * elements, such as JavaScript variables or function names, to ensure + * they are unique in the context of the portal page. + * + * @return the namespace + */ + + public String getNamespace (); + + + + /** + * This method sets the title of the portlet. + *

+ * The value can be a text String + * + * @param title portlet title as text String or resource URI + */ + + public void setTitle(String title); + + + + + /** + * Sets the MIME type for the render response. The portlet must + * set the content type before calling {@link #getWriter} or + * {@link #getPortletOutputStream}. + *

+ * Calling setContentType after getWriter + * or getOutputStream does not change the content type. + * + * @param type the content MIME type + * + * @throws java.lang.IllegalArgumentException + * if the given type is not in the list returned + * by PortletRequest.getResponseContentTypes + * + * @see RenderRequest#getResponseContentTypes + * @see #getContentType + */ + + public void setContentType(String type); + + + /** + * Returns the name of the charset used for + * the MIME body sent in this response. + * + *

See RFC 2047 + * for more information about character encoding and MIME. + * + * @return a String specifying the + * name of the charset, for + * example, ISO-8859-1 + * + */ + + public String getCharacterEncoding(); + + + /** + * Returns a PrintWriter object that can send character + * text to the portal. + *

+ * Before calling this method the content type of the + * render response must be set using the {@link #setContentType} + * method. + *

+ * Either this method or {@link #getPortletOutputStream} may be + * called to write the body, not both. + * + * @return a PrintWriter object that + * can return character data to the portal + * + * @exception java.io.IOException + * if an input or output exception occurred + * @exception java.lang.IllegalStateException + * if the getPortletOutputStream method + * has been called on this response, + * or if no content type was set using the + * setContentType method. + * + * @see #setContentType + * @see #getPortletOutputStream + */ + + public java.io.PrintWriter getWriter() throws java.io.IOException; + + + /** + * Returns the locale assigned to the response. + * + * @return Locale of this response + */ + + public java.util.Locale getLocale(); + + + /** + * Sets the preferred buffer size for the body of the response. + * The portlet container will use a buffer at least as large as + * the size requested. + *

+ * This method must be called before any response body content is + * written; if content has been written, or the portlet container + * does not support buffering, this method may throw an + * IllegalStateException. + * + * @param size the preferred buffer size + * + * @exception java.lang.IllegalStateException + * if this method is called after + * content has been written, or the + * portlet container does not support buffering + * + * @see #getBufferSize + * @see #flushBuffer + * @see #isCommitted + * @see #reset + */ + + public void setBufferSize(int size); + + + /** + * Returns the actual buffer size used for the response. If no buffering + * is used, this method returns 0. + * + * @return the actual buffer size used + * + * @see #setBufferSize + * @see #flushBuffer + * @see #isCommitted + * @see #reset + */ + + public int getBufferSize(); + + + + /** + * Forces any content in the buffer to be written to the client. A call + * to this method automatically commits the response. + * + * @exception java.io.IOException if an error occured when writing the output + * + * @see #setBufferSize + * @see #getBufferSize + * @see #isCommitted + * @see #reset + */ + + public void flushBuffer() throws java.io.IOException; + + + /** + * Clears the content of the underlying buffer in the response without + * clearing properties set. If the response has been committed, + * this method throws an IllegalStateException. + * + * @exception IllegalStateException if this method is called after + * response is comitted + * + * @see #setBufferSize + * @see #getBufferSize + * @see #isCommitted + * @see #reset + */ + + public void resetBuffer(); + + + /** + * Returns a boolean indicating if the response has been + * committed. + * + * @return a boolean indicating if the response has been + * committed + * + * @see #setBufferSize + * @see #getBufferSize + * @see #flushBuffer + * @see #reset + */ + + public boolean isCommitted(); + + + /** + * Clears any data that exists in the buffer as well as the properties set. + * If the response has been committed, this method throws an + * IllegalStateException. + * + * @exception java.lang.IllegalStateException if the response has already been + * committed + * + * @see #setBufferSize + * @see #getBufferSize + * @see #flushBuffer + * @see #isCommitted + */ + + public void reset(); + + + /** + * Returns a OutputStream suitable for writing binary + * data in the response. The portlet container does not encode the + * binary data. + *

+ * Before calling this method the content type of the + * render response must be set using the {@link #setContentType} + * method. + *

+ * Calling flush() on the OutputStream commits the response. + *

+ * Either this method or {@link #getWriter} may be called to write the body, not both. + * + * @return a OutputStream for writing binary data + * + * @exception java.lang.IllegalStateException if the getWriter method + * has been called on this response, or + * if no content type was set using the + * setContentType method. + * + * @exception java.io.IOException if an input or output exception occurred + * + * @see #setContentType + * @see #getWriter + */ + + public java.io.OutputStream getPortletOutputStream() throws java.io.IOException; + +} + + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/UnavailableException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/UnavailableException.java new file mode 100755 index 000000000..e1577355f --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/UnavailableException.java @@ -0,0 +1,134 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +/** + * The portlet should throw the UnavailableException when + * the portlet is either temporarily or permanently unavailable to handle requests. + * + **/ + +public class UnavailableException extends PortletException +{ + + + private boolean permanent; // needs admin action? + private int seconds; // unavailability estimate + + + /** + * + * Constructs a new exception with a descriptive + * message indicating that the portlet is permanently + * unavailable. + * + * @param text a String specifying the + * descriptive message + * + */ + + public UnavailableException(String text) { + super(text); + + permanent = true; + } + + /** + * Constructs a new exception with a descriptive message + * indicating that the portlet is temporarily unavailable + * and giving an estimate of how long it will be unavailable. + * + *

In some cases, the portlet cannot make an estimate. For + * example, the portlet might know that a server it needs is + * not running, but it might not be able to report how long it will take + * to be restored to functionality. This can be indicated with + * a negative or zero value for the seconds argument. + * + * @param text a String specifying the + * descriptive message. This message can be written + * to a log file or displayed for the user. + * + * @param seconds an integer specifying the number of seconds + * for which the portlet expects to be unavailable; if + * this is zero or negative, it indicates that the portlet + * cannot make an estimate. + * + */ + + public UnavailableException(String text, int seconds) { + super(text); + + if (seconds <= 0) + this.seconds = -1; + else + this.seconds = seconds; + + permanent = false; + } + + /** + * + * Returns a boolean indicating + * whether the portlet is permanently unavailable. + * If so, something is wrong with the portlet, and the + * system administrator must take some corrective action. + * + * @return true if the portlet is + * permanently unavailable; false + * if the portlet is temporarily + * unavailable. + * + */ + + public boolean isPermanent() { + return permanent; + } + + + /** + * Returns the time in seconds for which the portlet can be expected to + * be unavailable. + *

+ * If the portlet is called again while it is still unavailable, it + * indicates the same time estimate. No effort is + * made to correct for the time elapsed since the exception was + * first reported. + *

+ * If this method returns zero or a negative number, the portlet + * is permanently unavailable or cannot provide an estimate of + * how long it will be unavailable. + * + * @return an integer specifying the number of seconds + * the portlet will be temporarily unavailable, + * or zero or a negative number if the portlet is permanently + * unavailable or cannot make an estimate. + * + */ + + public int getUnavailableSeconds() { + return permanent ? -1 : seconds; + } + + +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/ValidatorException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/ValidatorException.java new file mode 100755 index 000000000..f26f14f2c --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/ValidatorException.java @@ -0,0 +1,132 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; + +/** + * The ValidatorException is thrown by the + * validate method of a PreferencesValidator when + * the validation of a preference failed. + */ + +public class ValidatorException extends PortletException +{ + + + private transient ArrayList failedKeyVector = new ArrayList(); + + private ValidatorException () + { + } + + /** + * Constructs a new validator exception with the given text. The + * portlet container may use the text write it to a log. + *

+ * The collection of failed keys may contain all failed keys, only the + * first key that failed validation, or may be null. + * + * @param text + * the exception text + * @param failedKeys + * keys that failed the validation; may be null + */ + + public ValidatorException (String text, Collection failedKeys) + { + super (text); + if ( failedKeys != null ) + failedKeyVector.addAll(failedKeys); + } + + /** + * Constructs a new portlet validator exception. + * Used, when the portlet needs to do one of the following: + *

    + * throw an exception + *
  • include a message about the "root cause" that interfered + * with its normal operation + *
  • include a description message + *
+ *

+ * The Collection of failed keys may contain all failed keys, only the + * first key that failed validation, or may be null. + * + * @param text + * the exception text + * @param cause + * the root cause + * @param failedKeys + * keys that failed the validation; may be null + */ + + public ValidatorException (String text, Throwable cause, Collection failedKeys) + { + super(text, cause); + if ( failedKeys != null ) + failedKeyVector.addAll(failedKeys); + } + + /** + * Constructs a new portlet validator exception when the portlet needs to throw an + * exception. The exception message is based on the localized message + * of the underlying exception. + *

+ * The Collection of failed keys may contain all failed keys, only the + * first key that failed validation, or may be null. + * + * @param cause + * the root cause + * @param failedKeys + * keys that failed the validation; may be null + */ + + public ValidatorException (Throwable cause, Collection failedKeys) + { + super(cause); + if ( failedKeys != null ) + failedKeyVector.addAll(failedKeys); + } + + + /** + * Returns the keys that failed the validation. + *

+ * The Enumeration of failed keys may contain all failed keys, only the + * first key that failed validation, or an empty + * Enumeration if no failed keys are available. + * + * @return the keys that failed validation, or an empty + * Enumeration if no failed keys are available. + */ + + public Enumeration getFailedKeys() + { + return Collections.enumeration(failedKeyVector); + } +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/WindowState.java b/fine-portlet-api/src/com/fr/third/javax/portlet/WindowState.java new file mode 100755 index 000000000..37f7f2b52 --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/WindowState.java @@ -0,0 +1,135 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + + +/** + * The WindowState class represents + * the possible window states that a portlet window can assume. + *

+ * This class defines a standard set of the most basic portlet window states. + * Additional window states may be defined by calling the constructor of + * this class. If a portal/portlet-container does not support a + * custom window state defined in the portlet application deployment descriptor, + * the custom window state will be ignored by the portal/portlet container. + */ + +public class WindowState +{ + + + /** + * The NORMAL window state indicates that a portlet + * may be sharing the page with other portlets. It may also + * indicate that the target device has limited display capabilities. + * Therefore, a portlet should restrict the size of its rendered + * output in this window state. + *

+ * The string value for this state is "normal". + */ + public final static WindowState NORMAL = new WindowState ("normal"); + + /** + * The MAXIMIZED window state is an indication + * that a portlet may be the only portlet being rendered in the + * portal page, or that the portlet has more space compared to other portlets + * in the portal page. A portlet may generate richer content + * when its window state is MAXIMIZED. + *

+ * The string value for this state is "maximized". + */ + public final static WindowState MAXIMIZED = new WindowState ("maximized"); + + /** + * When a portlet is in MINIMIZED window state, + * the portlet should only render minimal output or no output at all. + *

+ * The string value for this state is "minimized". + */ + public final static WindowState MINIMIZED = new WindowState ("minimized"); + + + + private String _name; + + + /** + * Creates a new window state with the given name. + *

+ * Upper case letters in the name are converted to + * lower case letters. + * + * @param name The name of the portlet mode + */ + public WindowState(String name) { + if (name==null) { + throw new IllegalArgumentException("WindowState name can not be NULL"); + } + _name = name.toLowerCase(); + } + + /** + * Returns a String representation of this window state. + * Window state names are always lower case names. + * + * @return String representation of this window state. + */ + + public String toString() { + return _name; + } + + + /** + * Returns the hash code value for this window state. + * The hash code is constructed by producing the + * hash value of the String value of this window state. + * + * @return hash code value for this window state + */ + + public int hashCode() { + return _name.hashCode(); + } + + + /** + * Compares the specified object with this window state + * for equality. Returns true if the + * Strings equals method for the String + * representing the two window states returns true. + * + * @param object the window state to compare this window state with. + * + * @return true, if the specified object is equal with this window state. + */ + + public boolean equals(Object object) { + if ( object instanceof WindowState ) + return _name.equals(((WindowState) object)._name); + else + return false; + } +} + diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/WindowStateException.java b/fine-portlet-api/src/com/fr/third/javax/portlet/WindowStateException.java new file mode 100755 index 000000000..4c07301ee --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/WindowStateException.java @@ -0,0 +1,105 @@ +/** + * 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. + */ + +/** + * This source code implements specifications defined by the Java + * Community Process. In order to remain compliant with the specification + * DO NOT add / change / or delete method signatures! + */ + +package com.fr.third.javax.portlet; + +/** + ** The WindowStateException is thrown when a portlet + ** tries to use a window state that is not supported by the current + ** runtime environment or the portlet. + **/ + +public class WindowStateException extends PortletException +{ + + + private transient WindowState _state = null; + + /** + * Constructs a new portlet state exception with the given text. The + * portlet container may use the text write it to a log. + * + * @param text + * the exception text + * @param state + * the state causing the exception + */ + + public WindowStateException (String text, WindowState state) + { + super (text); + _state = state; + } + + /** + * Constructs a new portlet state exception when the portlet needs to do + * the following: + *

    + * throw an exception + *
  • include a message about the "root cause" that interfered + * with its normal operation + *
  • include a description message + *
+ * + * @param text + * the exception text + * @param cause + * the root cause + * @param state + * the state causing the exception + */ + + public WindowStateException (String text, Throwable cause, WindowState state) + { + super(text, cause); + _state = state; + } + + /** + * Constructs a new portlet state exception when the portlet needs to throw an + * exception. The exception message is based on the localized message + * of the underlying exception. + * + * @param cause + * the root cause + * @param state + * the state causing the exception + */ + + public WindowStateException (Throwable cause, WindowState state) + { + super(cause); + _state = state; + } + + /** + * Returns the portlet state causing this exception. + * + * @return the window state causing this exception + */ + + public WindowState getState() + { + return _state; + } +} diff --git a/fine-portlet-api/src/com/fr/third/javax/portlet/package-info.java b/fine-portlet-api/src/com/fr/third/javax/portlet/package-info.java new file mode 100755 index 000000000..d87eaf23c --- /dev/null +++ b/fine-portlet-api/src/com/fr/third/javax/portlet/package-info.java @@ -0,0 +1,38 @@ +/** + * 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. + */ + +/** + * The com.fr.third.javax.portlet package defines the API for portlets. + *

+ * A portlet is a Java technology based web component, managed by a portlet container, + * that processes requests and generates dynamic content. Portlets provide a presentation + * layer to Information Systems. + *

+ * Portlets generate fragments of markup (e.g. HTML, XHTML, WML). A portal combines markup + * fragments generated by different portlets into a portal page. + *

+ * A portlet container manages the lifecyle of portlets. It also provides the required runtime environment. + *

+ * Portlets are bundled in Portlet Applications as web applications using the WAR file format. + * A portlet application consists of two deployment descriptors: one to specify + * the web application resources (web.xml) and one to specify the portlet resources + * (portlet.xml). The portlet.xml deployment descriptor must conform to the schema identified + * by the namespace http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd. + *

+ */ + +package com.fr.third.javax.portlet; \ No newline at end of file