View Javadoc

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 java.util.Vector;
20  import javax.naming.NamingEnumeration;
21  import javax.naming.directory.Attribute;
22  import javax.naming.directory.Attributes;
23  import javax.naming.directory.DirContext;
24  import org.apache.jetspeed.services.ldap.LDAPService;
25  import org.apache.jetspeed.services.ldap.LDAPURL;
26  import org.apache.turbine.services.TurbineServices;
27  
28  /***
29   *
30   * @author <a href="mailto:ender@kilicoglu.nom.tr">Ender KILICOGLU</a>
31   * @author <a href="mailto:sami.leino@netorek.fi">Sami Leino</a>
32   *
33   * @version $Id: JetspeedLDAP.java,v 1.5 2004/02/23 04:00:57 jford Exp $ 
34   * 
35   */
36  public class JetspeedLDAP 
37  {
38      public static LDAPService getService()
39      {
40          return(LDAPService)TurbineServices
41          .getInstance()
42          .getService(LDAPService.SERVICE_NAME);
43      }
44  
45      public static boolean addAttribute(LDAPURL url, Attribute at)
46      {
47          return getService().addAttribute(url, at);
48      }
49  
50  
51      public static boolean addEntry(LDAPURL url, Attributes at)
52      {
53          return getService().addEntry(url, at);
54      }
55  
56      public static int compare(LDAPURL srcUrl, LDAPURL dstUrl)
57      {
58          return getService().compare(srcUrl, dstUrl);
59      }
60  
61      public static boolean deleteAttribute(LDAPURL url, Attribute at)
62      {
63          return getService().deleteAttribute(url, at);
64      }
65  
66      public static boolean deleteEntry(LDAPURL url)
67      {
68          return getService().deleteEntry(url);
69      }
70  
71      public static LDAPURL buildURL(String DN)
72      {
73          return getService().buildURL(DN);
74      }
75  
76      public static boolean deleteTree(LDAPURL url)
77      {
78          return getService().deleteTree(url);
79      }
80  
81      public static boolean exists(LDAPURL url)
82      {
83          return getService().exists(url);
84      }
85  
86      public static LDAPURL findEntryName(LDAPURL url)
87      {
88          return getService().findEntryName(url);
89      }
90  
91      public static String removeAttrName(String attrvalue)
92      {
93          return getService().removeAttrName(attrvalue);
94      }
95  
96      public static Attributes read(LDAPURL url)
97      {
98          return getService().read(url);
99      }
100 
101     public static boolean renameEntry(LDAPURL url, String newDN)
102     {
103         return getService().renameEntry(url, newDN);
104     }
105 
106     public static NamingEnumeration search(DirContext ctx, String dn, String filter, String attribs[], int type)
107     {
108 		try
109 		{
110 	        return getService().search(ctx, dn, filter, attribs, type);
111 		}
112 		catch (Exception e)
113 		{
114 			e.printStackTrace();
115 			return null;
116 		}
117     }
118 
119     public static Vector search(LDAPURL url, String filter, String attribs[], boolean subTreeScope)
120     {
121         return getService().search(url, filter, attribs, subTreeScope);
122     }
123 
124     public static boolean synchEntry(LDAPURL url, Attributes ats)
125     {
126         return getService().synchEntry(url, ats);
127     }
128 
129     public static boolean deleteAttrs(LDAPURL url, Attributes ats)
130     {
131         return getService().deleteAttrs(url, ats);
132     }
133 
134     public static boolean transfer(LDAPURL fromUrl, LDAPURL toUrl, boolean delete, boolean replace, boolean withChildren)
135     {
136         return getService().transfer(fromUrl, toUrl, delete, replace, withChildren);
137     }
138 
139     public static boolean transferEntry(LDAPURL fromUrl, Attributes ats, LDAPURL toUrl, boolean delete, boolean replace)
140     {
141         return getService().transferEntry(fromUrl, ats, toUrl, delete, replace);
142     }
143 
144     public static boolean transferEntry(LDAPURL fromUrl, LDAPURL toUrl, boolean delete, boolean replace)
145     {
146         return getService().transferEntry(fromUrl, toUrl, delete, replace);
147     }
148 
149     public static boolean updateAttribute(LDAPURL url, Attribute at)
150     {
151         return getService().updateAttribute(url, at);
152     }
153 
154     public static boolean updateEntry(LDAPURL url, Attributes at)
155     {
156         return getService().updateEntry(url, at);
157     }
158 
159     public static boolean updateEntry(LDAPURL url, Attributes ats, boolean replace)
160     {
161         return getService().updateEntry(url, ats, replace);
162     }
163 
164     public static String getName(String dn)
165     {
166         return getService().getName(dn);
167     }
168 }