KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > PsmlManager


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 package org.apache.jetspeed.services;
18
19 import org.apache.jetspeed.services.psmlmanager.PsmlManagerService;
20 import org.apache.jetspeed.om.profile.PSMLDocument;
21 import org.apache.turbine.services.TurbineServices;
22 import org.apache.jetspeed.om.profile.ProfileLocator;
23 import org.apache.jetspeed.om.profile.QueryLocator;
24 import org.apache.jetspeed.om.profile.Profile;
25 import org.apache.jetspeed.om.security.JetspeedUser;
26 import org.apache.jetspeed.om.security.Role;
27 import org.apache.jetspeed.om.security.Group;
28
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31
32 /**
33  * Static accessor for the PsmlManagerService
34  *
35  * @author <a HREF="mailto:raphael@apache.org">RaphaŽl Luta</a>
36  * @version $Id: PsmlManager.java,v 1.10 2004/02/23 04:00:57 jford Exp $
37  */

38 public class PsmlManager
39 {
40
41     /**
42      * Commodity method for getting a reference to the service
43      * singleton
44      */

45     public static PsmlManagerService getService()
46     {
47         return (PsmlManagerService)TurbineServices
48                 .getInstance()
49                 .getService(PsmlManagerService.SERVICE_NAME);
50     }
51
52     /**
53      * Returns a PSML document of the given name.
54      * For this implementation, the name must be the document
55      * URL or absolute filepath
56      *
57      * @deprecated
58      * @param name the name of the document to retrieve
59      */

60     public static PSMLDocument getDocument( String JavaDoc name )
61     {
62         return getService().getDocument(name);
63     }
64
65     /**
66      * Returns a PSML document for the given locator
67      *
68      * @param locator The locator descriptor of the document to be retrieved.
69      */

70     public static PSMLDocument getDocument( ProfileLocator locator )
71     {
72         return getService().getDocument(locator);
73     }
74
75     /** Given a ordered list of locators, find the first document matching
76      * a profile locator, starting from the beginning of the list and working
77      * to the end.
78      *
79      * @param locator The ordered list of profile locators.
80      */

81     public static PSMLDocument getDocument( List JavaDoc locators )
82     {
83         return getService().getDocument(locators);
84     }
85
86     /** Store the PSML document on disk, using its locator
87      *
88      * @param profile the profile locator description.
89      * @return true if the operation succeeded
90      */

91     public static boolean store(Profile profile)
92     {
93         return getService().store(profile);
94     }
95
96     /** Save the PSML document on disk, using its name as filepath
97      * @deprecated
98      * @param doc the document to save
99      */

100     public static boolean saveDocument(PSMLDocument doc)
101     {
102         return getService().saveDocument(doc);
103     }
104     
105     /** Save the PSML document on disk to the specififed fileOrUrl
106      * @deprecated
107      * @param fileOrUrl a String representing either an absolute URL
108      * or an absolute filepath
109      * @param doc the document to save
110      */

111     public static boolean saveDocument(String JavaDoc fileOrUrl, PSMLDocument doc)
112     {
113         return getService().saveDocument(fileOrUrl, doc);
114     }
115
116     /** Create a new document.
117      *
118      * @param profile The description and default value for the new document.
119      * @return The newly created document.
120      */

121     public static PSMLDocument createDocument( Profile profile )
122     {
123         return getService().createDocument( profile );
124     }
125
126     /** Removes a document.
127      *
128      * @param locator The description of the profile resource to be removed.
129      */

130     public static void removeDocument( ProfileLocator locator )
131     {
132         getService().removeDocument( locator );
133     }
134
135     /** Removes all documents for a given user.
136      *
137      * @param user The user object.
138      */

139     public static void removeUserDocuments( JetspeedUser user )
140     {
141         getService().removeUserDocuments( user );
142     }
143
144     /** Removes all documents for a given group.
145      *
146      * @param group The group object.
147      */

148     public static void removeGroupDocuments( Group group )
149     {
150         getService().removeGroupDocuments( group );
151     }
152
153
154     /** Removes all documents for a given role.
155      *
156      * @param role The role object.
157      */

158     public static void removeRoleDocuments( Role role )
159     {
160         getService().removeRoleDocuments( role );
161     }
162
163
164     /** Query for a collection of profiles given a profile locator criteria.
165      *
166      * @param locator The profile locator criteria.
167      */

168     public static Iterator JavaDoc query( QueryLocator locator )
169     {
170         return getService().query( locator );
171     }
172
173     /** Export profiles from this service into another service
174      *
175      * @param consumer The PSML consumer service, receives PSML from this service.
176      * @param locator The profile locator criteria.
177      *
178      * @return The count of profiles exported.
179      */

180     public int export(PsmlManagerService consumer, QueryLocator locator)
181     {
182         return getService().export(consumer, locator);
183     }
184
185     /**
186      * Refreshes a PSML document for the given locator
187      *
188      * @param locator The locator descriptor of the document to be retrieved.
189      */

190     public static PSMLDocument refresh( ProfileLocator locator )
191     {
192         return getService().refresh(locator);
193     }
194
195 }
196
197
Popular Tags