1   /*
2    * Copyright 2000-2001,2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /* 
18  
19   */
20  
21  package org.apache.wsrp4j.producer.provider;
22  
23  import oasis.names.tc.wsrp.v1.types.ModelDescription;
24  import oasis.names.tc.wsrp.v1.types.PropertyList;
25  
26  /**
27   Manages the portlet states. Provides convenience mehtods usefull for state handling
28   * @author Stefan Behl
29   *
30   */
31  public interface PortletStateManager {
32  
33      /** defines an error state */
34      public static final int INITIALIZATION_FAILED = 3007;//TODO do we need this?
35  
36      /**
37       Returns the portlet's state for a given portlet handle
38       @param portletHandle String representing a portlet handle
39       @return PortletState
40       */
41      public PortletState get(String portletHandle);
42  
43      /**
44       Returns the portlet's state as String for a given portlet handle
45       @param  portletHandle String representing a portlet handle
46       @return String representing the portlet's state
47       */
48      public String getAsString(String portletHandle);
49  
50      /**
51       Converts a PortletState object to java.lang.String
52       @param state PortletState
53       @return java.lang.String representing a portlet state
54       */
55      public String getAsString(PortletState state);
56  
57      /**
58       Converts a subset of the portlet stateto java.lang.String.
59       The subset of the state is represented by an array of names.
60       @param portletHandle String representing a portlet handle
61       @param names array of String 
62       @return String representing a subset of a portlte state
63       */
64      public String getAsString(String portletHandle, String[] names);
65  
66      /**
67       Returns the portlet's state as PropertyList
68       @param portletHandle String representing a portlte handle
69       @return PropertyList
70       */
71      public PropertyList getAsPropertyList(String portletHandle);
72  
73      /**
74       Converts a portlet's state to a PropertyList
75       @param  state the portlet's state
76       @return PropertyList
77       */
78      public PropertyList getAsPropertyList(PortletState state);
79  
80      /**
81       Converts a subset of the portlet state to a PropertyList. The subset
82       of the state is represented by an array of names.
83       @param portletHandle String representing a portlet handle
84       @param names array of String 
85       @return PropertyList
86       */
87      public PropertyList getAsPropertyList(String portletHandle, String[] names);
88  
89      /**
90       Set the portlet's state
91       @param portletHandle String representing a portlet handle
92       @param state PortletState
93       */
94      public void set(String portletHandle, PortletState state);
95  
96      /**
97       Set the portlet state
98       @param portletHandle String representing a portlet handle
99       @param state String representing the portlet's state
100      */
101     public void setAsString(String portletHandle, String state);
102 
103     /**
104      Set the portlet state
105      @param  portletHandle String representing a portlet handle
106      @param state PropretyList representing the portlte's state
107      */
108     public void setAsPropertyList(String portletHandle, PropertyList state);
109 
110     /**
111      Destroys a portlet state
112      @param  portletHandle String representing a portlet handle
113      */
114     public void destroy(String portletHandle);
115 
116     /**
117      Returns the WSRP model description for a portlet's state.
118      @param  portletHandle String representing a portlet handle
119      @param desiredLocales determine the desired locales
120      @param sendAllLocales indicates if all locales are desired
121      @return ModelDescription
122      */
123     public ModelDescription getModelDescription(String portletHandle,
124             String[] desiredLocales, boolean sendAllLocales);
125 
126 }