stephan 2003/05/15 03:09:41
Modified: . status.xml
src/blocks/naming/java/org/apache/cocoon/transformation
LDAPTransformer.java
Log:
Patch 18466 applied.
Revision Changes Path
1.31 +4 -0 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- status.xml 15 May 2003 08:30:01 -0000 1.30
+++ status.xml 15 May 2003 10:09:40 -0000 1.31
@@ -180,6 +180,10 @@
<changes>
<release version="@version@" date="@date@">
+ <action dev="SMS" type="update" fixes-bug="18466" due-to="Yury Mikhienko"
due-to-email="[EMAIL PROTECTED]">
+ Enable the LDAPTransformer to obtain attribute values from LDAP using
various encoding
+ schemes for stored values.
+ </action>
<action dev="SMS" type="update" fixes-bug="19885" due-to="Torsten Knodt"
due-to-email="[EMAIL PROTECTED]">
Cleaned up MIMEUtils.
</action>
1.3 +521 -309
cocoon-2.1/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java
Index: LDAPTransformer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/naming/java/org/apache/cocoon/transformation/LDAPTransformer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LDAPTransformer.java 24 Mar 2003 14:33:54 -0000 1.2
+++ LDAPTransformer.java 15 May 2003 10:09:41 -0000 1.3
@@ -68,8 +68,7 @@
import java.io.IOException;
import java.util.*;
-
-/*****************************************************************************
+/**
* The <code>LDAPTransformer</code> is a class that can be plugged into a
pipeline
* to transform the SAX events which passes thru this transformer into
queries
* an responses to/from a ldap interface.
@@ -84,8 +83,17 @@
* <br>
*
* The following DTD is valid:<br>
- * <!ELEMENT execute-query (attribute+ | show-attribute? | scope? |
initializer? | authentication? | error-element? | sax-error? doc-element? |
row-element? | version? | serverurl? | rootdn? | password? | deref-link? |
count-limit? | searchbase, filter)><br>
- * <!ELEMENT execute-increment (attribute | show-attribute? | scope? |
initializer? | authentication? | error-element? | sax-error? | doc-element? |
row-element? | version? | serverurl? | rootdn? | password? | deref-link? |
count-limit? | searchbase, filter)><br>
+ * <!ELEMENT execute-query (attribute+ | show-attribute? | scope? |
+ * initializer? | authentication? | error-element? | sax-error?
+ * doc-element? | row-element? | version? | serverurl? |
rootdn? |
+ * password? | deref-link? | count-limit? | searchbase,
+ * filter)><br>
+ * <!ELEMENT execute-increment (attribute | show-attribute? | scope? |
+ * initializer? | authentication? |
+ * error-element? | sax-error? |
doc-element? |
+ * row-element? | version? | serverurl? |
+ * rootdn? | password? | deref-link? |
+ * count-limit? | searchbase, filter)><br>
* increments (+1) an integer attribute on a directory-server (ldap)<br>
* <br>
* <!ELEMENT initializer (#PCDATA)>+ (default:
"com.sun.jndi.ldap.LdapCtxFactory")<br>
@@ -95,19 +103,22 @@
* <!ELEMENT port (#PCDATA)>+ (default: 389)<br>
* <!ELEMENT rootdn (#PCDATA)>+<br>
* <!ELEMENT password (#PCDATA)>+<br>
- * <!ELEMENT scope (ONELEVEL_SCOPE | SUBTREE_SCOPE | OBJECT_SCOPE)>+
(default: ONELEVEL_SCOPE)<br>
+ * <!ELEMENT scope (ONELEVEL_SCOPE | SUBTREE_SCOPE | OBJECT_SCOPE)>+
+ * (default: ONELEVEL_SCOPE)<br>
* <!ELEMENT searchbase (#PCDATA)>+<br>
* <!ELEMENT doc-element (#PCDATA)>+ (default: "doc-element")<br>
* <!ELEMENT row-element (#PCDATA)>+ (default: "row-element")<br>
- * <!ELEMENT error-element (#PCDATA)>+ (default: "ldap-error") (in
case of error returned error tag)<br>
- * <!ELEMENT sax_error (TRUE | FALSE)>+; (default: FALSE) (throws
SAX-Exception instead of error tag)<br>
+ * <!ELEMENT error-element (#PCDATA)>+ (default: "ldap-error")
+ * (in case of error returned error tag)<br>
+ * <!ELEMENT sax_error (TRUE | FALSE)>+; (default: FALSE)
+ * (throws SAX-Exception instead of error tag)<br>
* <!ELEMENT attribute (#PCDATA)><br>
* <!ELEMENT show-attribute (TRUE | FALSE)> (default: TRUE)<br>
* <!ELEMENT filter (#PCDATA | execute-query)><br>
* <!ELEMENT deref-link (TRUE | FALSE)> (default: FALSE)<br>
* <!ELEMENT count-limit (#PCDATA)> (integer default: 0 -> no
limit)<br>
* <!ELEMENT time-limit (#PCDATA)> (integer default: 0 ->
infinite)<br>
- * <!ELEMENT debug (TRUE | FALSE)>+; (default: FALSE)<br>
+ * <!ELEMENT debug (TRUE | FALSE)>+; (default: FALSE)<br>
* <br>
* + can also be defined as parameter in the sitemap.
* <br>
@@ -118,8 +129,9 @@
*/
public class LDAPTransformer extends AbstractTransformer {
- /** The LDAP namespace ("http://apache.org/cocoon/LDAP/1.0")**/
+ /** The LDAP namespace ("http://apache.org/cocoon/LDAP/1.0") */
public static final String my_uri = "http://apache.org/cocoon/LDAP/1.0";
+
public static final String my_name = "LDAPTransformer";
/** The LDAP namespace element names **/
@@ -145,6 +157,7 @@
public static final String MAGIC_COUNT_LIMIT_ELEMENT = "count-limit";
public static final String MAGIC_TIME_LIMIT_ELEMENT = "time-limit";
public static final String MAGIC_DEBUG_ELEMENT = "debug";
+ public static final String MAGIC_ENCODING_ELEMENT = "encoding";
/** The states we are allowed to be in **/
public static final int STATE_OUTSIDE = 0;
@@ -172,125 +185,145 @@
public static final int STATE_INSIDE_DEBUG_ELEMENT = 22;
public static final int STATE_INSIDE_SAX_ERROR_ELEMENT = 23;
- /** Default parameters that might apply to all queries **/
+ /** Default parameters that might apply to all queries */
protected Properties default_properties = new Properties();
- /** The name of the value element we're currently receiving **/
+ /** The name of the value element we're currently receiving */
protected String current_name;
- /** The current state of the event receiving FSM **/
+ /** The current state of the event receiving FSM */
protected int current_state = STATE_OUTSIDE;
- /** The value of the value element we're currently receiving **/
+ /** The value of the value element we're currently receiving */
protected StringBuffer current_value = new StringBuffer();
- /** The list of queries that we're currently working on **/
+ /** The list of queries that we're currently working on */
protected Vector queries = new Vector();
- /** The offset of the current query in the queries list **/
+ /** The offset of the current query in the queries list */
protected int current_query_index = -1;
/** SAX producing state information */
protected XMLConsumer xml_consumer;
- protected LexicalHandler lexical_handler;
- /** BEGIN SitemapComponent methods **/
+ protected LexicalHandler lexical_handler;
+ /* BEGIN SitemapComponent methods */
public void setup(SourceResolver resolver, Map objectModel,
- String source, Parameters parameters)
- throws ProcessingException, SAXException, IOException {
+ String source,
+ Parameters parameters)
+ throws ProcessingException, SAXException,
+ IOException {
current_state = STATE_OUTSIDE;
// Check the initializer
- String parameter =
parameters.getParameter(MAGIC_INITIALIZER_ELEMENT, null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_INITIALIZER_ELEMENT,
parameter);
+ String parameter = parameters.getParameter(MAGIC_INITIALIZER_ELEMENT,
+ null);
+
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_INITIALIZER_ELEMENT,
+ parameter);
}
// Check the version
parameter = parameters.getParameter(MAGIC_VERSION_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_VERSION_ELEMENT, parameter);
}
// Check the authentication
- parameter = parameters.getParameter(MAGIC_AUTHENTICATION_ELEMENT,
null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_AUTHENTICATION_ELEMENT,
parameter);
+ parameter = parameters.getParameter(MAGIC_AUTHENTICATION_ELEMENT,
+ null);
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_AUTHENTICATION_ELEMENT,
+ parameter);
}
// Check the scope
parameter = parameters.getParameter(MAGIC_SCOPE_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_SCOPE_ELEMENT, parameter);
}
// Check the serverurl
parameter = parameters.getParameter(MAGIC_SERVERURL_ELEMENT, null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_SERVERURL_ELEMENT,
parameter);
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_SERVERURL_ELEMENT,
+ parameter);
}
// Check the ldap-root_dn
parameter = parameters.getParameter(MAGIC_ROOT_DN_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_ROOT_DN_ELEMENT, parameter);
}
// Check the ldap-pwd
- parameter = parameters.getParameter(MAGIC_PASSWORD_ELEMENT,null);
- if (parameter != null) {
+ parameter = parameters.getParameter(MAGIC_PASSWORD_ELEMENT, null);
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_PASSWORD_ELEMENT,
parameter);
}
// Check the port
parameter = parameters.getParameter(MAGIC_PORT_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_PORT_ELEMENT, parameter);
}
// Check the searchbase
parameter = parameters.getParameter(MAGIC_SEARCHBASE_ELEMENT, null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_SEARCHBASE_ELEMENT,
parameter);
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_SEARCHBASE_ELEMENT,
+ parameter);
}
// Check the doc-element
parameter = parameters.getParameter(MAGIC_DOC_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_DOC_ELEMENT, parameter);
}
// Check the row-element
- parameter = parameters.getParameter(MAGIC_ROW_ELEMENT,null);
- if (parameter != null) {
+ parameter = parameters.getParameter(MAGIC_ROW_ELEMENT, null);
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_ROW_ELEMENT, parameter);
}
// Check the error-element
parameter = parameters.getParameter(MAGIC_ERROR_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_ERROR_ELEMENT, parameter);
}
// Check the sax-error
parameter = parameters.getParameter(MAGIC_SAX_ERROR, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_SAX_ERROR, parameter);
}
// Check the deref-link-element
parameter = parameters.getParameter(MAGIC_DEREF_LINK_ELEMENT, null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_DEREF_LINK_ELEMENT,
parameter.toUpperCase());
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_DEREF_LINK_ELEMENT,
+ parameter.toUpperCase());
}
// Check the count-limit-element
parameter = parameters.getParameter(MAGIC_COUNT_LIMIT_ELEMENT, null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_COUNT_LIMIT_ELEMENT,
parameter);
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_COUNT_LIMIT_ELEMENT,
+ parameter);
}
// Check the time-limit-element
parameter = parameters.getParameter(MAGIC_TIME_LIMIT_ELEMENT, null);
- if (parameter != null) {
- default_properties.setProperty(MAGIC_TIME_LIMIT_ELEMENT,
parameter);
+ if (parameter!=null) {
+ default_properties.setProperty(MAGIC_TIME_LIMIT_ELEMENT,
+ parameter);
}
// Check the debug-element
parameter = parameters.getParameter(MAGIC_DEBUG_ELEMENT, null);
- if (parameter != null) {
+ if (parameter!=null) {
default_properties.setProperty(MAGIC_DEBUG_ELEMENT, parameter);
}
+ // Check the encoding
+ parameter = parameters.getParameter(MAGIC_ENCODING_ELEMENT, null);
+ if (parameter!=null) {
+ getLogger().debug("Get the sitemap parameter "+
+ MAGIC_ENCODING_ELEMENT+"("+parameter+")");
+ default_properties.setProperty(MAGIC_ENCODING_ELEMENT,
parameter);
+ }
+
}
- /** END SitemapComponent methods **/
+ /* END SitemapComponent methods */
- /** BEGIN my very own methods **/
+ /* BEGIN my very own methods */
/**
* This will be the meat of LDAPTransformer, where the query is run.
@@ -298,25 +331,27 @@
protected void executeQuery(int index) throws SAXException {
this.contentHandler.startPrefixMapping("", LDAPTransformer.my_uri);
LDAPQuery query = (LDAPQuery) queries.elementAt(index);
+
try {
query.execute();
} catch (NamingException e) {
- throw new SAXException (e);
+ throw new SAXException(e);
} catch (Exception e) {
- throw new SAXException (e);
+ throw new SAXException(e);
}
this.contentHandler.endPrefixMapping("");
}
protected static void throwIllegalStateException(String message) {
- throw new IllegalStateException(my_name + ": " + message);
+ throw new IllegalStateException(my_name+": "+message);
}
protected void startExecuteQuery(Attributes attributes) {
LDAPQuery query;
+
switch (current_state) {
- case LDAPTransformer.STATE_OUTSIDE:
+ case LDAPTransformer.STATE_OUTSIDE :
current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
current_query_index = queries.size();
query = new LDAPQuery(this);
@@ -324,7 +359,8 @@
getCurrentQuery().toDo =
LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
getCurrentQuery().query_index = current_query_index;
break;
- case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT:
+
+ case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT :
current_state = LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
current_query_index = queries.size();
query = new LDAPQuery(this);
@@ -332,33 +368,36 @@
getCurrentQuery().toDo =
LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY;
getCurrentQuery().query_index = current_query_index;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
execute-query element");
}
}
protected void endExecuteQuery() throws SAXException {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
executeQuery(current_query_index);
queries.remove(current_query_index);
--current_query_index;
- if (current_query_index > -1) {
+ if (current_query_index>-1) {
current_state = getCurrentQuery().toDo;
} else {
queries.removeAllElements();
current_state = LDAPTransformer.STATE_OUTSIDE;
}
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end
execute-query element");
}
}
protected void startExecuteIncrement(Attributes attributes) {
LDAPQuery query;
+
switch (current_state) {
- case LDAPTransformer.STATE_OUTSIDE:
+ case LDAPTransformer.STATE_OUTSIDE :
current_state =
LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
current_query_index = queries.size();
query = new LDAPQuery(this);
@@ -366,7 +405,8 @@
getCurrentQuery().toDo =
LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
getCurrentQuery().query_index = current_query_index;
break;
- case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY:
+
+ case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY :
current_state =
LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
current_query_index = queries.size();
query = new LDAPQuery(this);
@@ -374,560 +414,623 @@
getCurrentQuery().toDo =
LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT;
getCurrentQuery().query_index = current_query_index;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
execute-increment element");
}
}
protected void endExecuteIncrement() throws SAXException {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT:
+ case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT :
executeQuery(current_query_index);
queries.remove(current_query_index);
--current_query_index;
- if (current_query_index > 1) {
+ if (current_query_index>1) {
current_state = getCurrentQuery().toDo;
} else {
- queries.removeAllElements();
+ queries.removeAllElements();
current_state = LDAPTransformer.STATE_OUTSIDE;
}
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end
execute-increment element");
}
}
protected void startInitializerElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
initializer element");
}
}
protected void endInitializerElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT :
getCurrentQuery().initializer = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end initializer
element");
}
}
protected void startScopeElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start scope
element");
}
}
protected void endScopeElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT :
getCurrentQuery().scope = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end scope
element");
}
}
protected void startAuthenticationElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
authentication element");
}
}
protected void endAuthenticationElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT :
getCurrentQuery().authentication = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end
authentication element");
}
}
protected void startServerurlElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start serverurl
element");
}
}
protected void endServerurlElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT :
getCurrentQuery().serverurl = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end serverurl
element");
}
}
protected void startPortElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_PORT_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_PORT_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start port
element");
}
}
protected void endPortElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_PORT_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_PORT_ELEMENT :
getCurrentQuery().port =
Integer.parseInt(current_value.toString());
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end server
element");
}
}
protected void startShowAttributeElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
show-attribute element");
}
}
protected void endShowAttributeElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT :
if (current_value.toString().toUpperCase().equals("FALSE")) {
getCurrentQuery().showAttribute = false;
}
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end
show-attribute element");
}
}
protected void startSearchbaseElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start searchbase
element");
}
}
protected void endSearchbaseElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT :
getCurrentQuery().searchbase = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end searchbase
element");
}
}
protected void startDocElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_DOC_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_DOC_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
doc-element element");
}
}
protected void endDocElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_DOC_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_DOC_ELEMENT :
getCurrentQuery().doc_element = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end doc-element
element");
}
}
protected void startRowElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_ROW_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_ROW_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
row-element element");
}
}
protected void endRowElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_ROW_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_ROW_ELEMENT :
getCurrentQuery().row_element = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end row-element
element");
}
}
protected void startErrorElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
error-element element");
}
}
protected void endErrorElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT :
getCurrentQuery().error_element = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end
error-element element");
}
}
protected void startSaxError(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start sax-error
element");
}
}
protected void endSaxError() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT :
if (current_value.toString().toUpperCase().equals("TRUE")) {
getCurrentQuery().sax_error = true;
}
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end sax-error
element");
}
}
protected void startRootDnElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start root-dn
element");
}
}
protected void endRootDnElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT:
- getCurrentQuery().root_dn = current_value.toString( );
+ case LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT :
+ getCurrentQuery().root_dn = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end root-dn
element");
}
}
+
protected void startPasswordElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state =
LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start password
element");
}
}
protected void endPasswordElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT :
getCurrentQuery().password = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end password
element");
}
}
protected void startAttributeElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_state =
LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT;
current_value.setLength(0);
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_state =
LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT;
current_value.setLength(0);
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start attribute
element");
}
}
protected void endAttributeElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT :
getCurrentQuery().addAttrList(current_value.toString());
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end attribute
element");
}
}
protected void startVersionElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_state = LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT;
current_value.setLength(0);
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_state = LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT;
current_value.setLength(0);
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start version
element");
}
}
protected void endVersionElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT :
getCurrentQuery().version = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end version
element");
}
}
protected void startFilterElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
current_value.setLength(0);
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
getCurrentQuery().current_state =
LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT;
current_value.setLength(0);
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start filter
element");
}
}
protected void endFilterElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT :
getCurrentQuery().filter = current_value.toString();
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end filter
element");
}
}
protected void startDerefLinkElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_state =
LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT;
current_value.setLength(0);
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_state =
LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT;
current_value.setLength(0);
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start deref-link
element");
}
}
protected void endDerefLinkElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT :
if (current_value.toString().toUpperCase().equals("TRUE")) {
getCurrentQuery().deref_link = true;
}
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end deref-link
element");
}
}
protected void startCountLimitElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_state =
LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT;
current_value.setLength(0);
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_state =
LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT;
current_value.setLength(0);
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start
count-limit element");
}
}
protected void endCountLimitElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT :
getCurrentQuery().count_limit =
Integer.parseInt(current_value.toString());
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end count-limit
element");
}
}
protected void startTimeLimitElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_state =
LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT;
current_value.setLength(0);
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_state =
LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT;
current_value.setLength(0);
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start time-limit
element");
}
}
protected void endTimeLimitElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT :
getCurrentQuery().time_limit =
Integer.parseInt(current_value.toString());
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end time-limit
element");
}
}
protected void startDebugElement(Attributes attributes) {
switch (current_state) {
- case STATE_INSIDE_EXECUTE_QUERY:
+ case STATE_INSIDE_EXECUTE_QUERY :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT;
break;
- case STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case STATE_INSIDE_EXECUTE_INCREMENT :
current_value.setLength(0);
current_state = LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a start debug
element");
}
}
protected void endDebugElement() {
switch (current_state) {
- case LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT:
+ case LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT :
if (current_value.toString().toUpperCase().equals("TRUE")) {
getCurrentQuery().debug = true;
}
current_state = getCurrentQuery().toDo;
break;
- default:
+
+ default :
throwIllegalStateException("Not expecting a end debug
element");
}
}
@@ -940,27 +1043,28 @@
return (LDAPQuery) queries.elementAt(i);
}
- /** END my very own methods **/
+ /* END my very own methods */
- /** BEGIN SAX ContentHandler handlers **/
+ /* BEGIN SAX ContentHandler handlers */
public void setDocumentLocator(Locator locator) {
if (getLogger().isDebugEnabled()) {
- getLogger().debug( "PUBLIC ID: " + locator.getPublicId() );
- getLogger().debug( "SYSTEM ID: " + locator.getSystemId() );
+ getLogger().debug("PUBLIC ID: "+locator.getPublicId());
+ getLogger().debug("SYSTEM ID: "+locator.getSystemId());
}
- if (super.contentHandler != null)
+ if (super.contentHandler!=null) {
super.contentHandler.setDocumentLocator(locator);
+ }
}
public void startElement(String uri, String name, String raw,
Attributes attributes) throws SAXException {
- if (!uri.equals(my_uri)) {
+ if ( !uri.equals(my_uri)) {
super.startElement(uri, name, raw, attributes);
return;
}
if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("RECEIVED START ELEMENT " + name + "(" + uri +
")");
+ getLogger().debug("RECEIVED START ELEMENT "+name+"("+uri+")");
}
if (name.equals(LDAPTransformer.MAGIC_EXECUTE_QUERY)) {
@@ -1012,12 +1116,12 @@
public void endElement(String uri, String name,
String raw) throws SAXException {
- if (!uri.equals(my_uri)) {
+ if ( !uri.equals(my_uri)) {
super.endElement(uri, name, raw);
return;
}
if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("RECEIVED END ELEMENT "+ name + "(" + uri +
")");
+ getLogger().debug("RECEIVED END ELEMENT "+name+"("+uri+")");
}
if (name.equals(LDAPTransformer.MAGIC_EXECUTE_QUERY)) {
@@ -1067,31 +1171,34 @@
}
}
- public void characters(char ary[], int start, int length) throws
SAXException {
- if (current_state !=
LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT
&&
- current_state !=
LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_PORT_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_DOC_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_ROW_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT
&&
- current_state !=
LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT
&&
- current_state !=
LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT &&
- current_state !=
LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT &&
- current_state != LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT
&&
- current_state !=
LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT) {
+ public void characters(char ary[], int start,
+ int length) throws SAXException {
+ if
((current_state!=LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT) &&
+
(current_state!=LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT)
&&
+ (current_state!=LDAPTransformer.STATE_INSIDE_PORT_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_DOC_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_ROW_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT)
&&
+ (current_state!=LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT)
&&
+
(current_state!=LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT)
&&
+
(current_state!=LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT) &&
+ (current_state!=LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT)
&&
+ (current_state!=LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT) &&
+ (current_state!=
+ LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT)) {
super.characters(ary, start, length);
}
if (this.getLogger().isDebugEnabled()) {
- getLogger().debug("RECEIVED CHARACTERS: " + new String(ary,
start, length));
+ getLogger().debug("RECEIVED CHARACTERS: "+
+ new String(ary, start, length));
}
current_value.append(ary, start, length);
}
@@ -1106,8 +1213,10 @@
}
private void data(String data) throws SAXException {
- if (data != null)
- super.contentHandler.characters(data.toCharArray(), 0,
data.length());
+ if (data!=null) {
+ super.contentHandler.characters(data.toCharArray(), 0,
+ data.length());
+ }
}
protected static String getStringValue(Object object) {
@@ -1115,31 +1224,31 @@
return new String((byte[]) object);
} else if (object instanceof char[]) {
return new String((char[]) object);
- } else if (object != null) {
+ } else if (object!=null) {
return object.toString();
} else {
return "";
}
}
- public final Logger getTheLogger()
- {
+ public final Logger getTheLogger() {
return getLogger();
}
-
class LDAPQuery {
- /** What index are you in daddy's queries list **/
+
+ /** What index are you in daddy's queries list */
protected int query_index;
- /** The current state of the event receiving FSM **/
+ /** The current state of the event receiving FSM */
protected int current_state;
- /** Who's your daddy? **/
+ /** Who's your daddy? */
protected LDAPTransformer transformer;
- /** LDAP configuration information **/
+ /** LDAP configuration information */
protected String initializer = "com.sun.jndi.ldap.LdapCtxFactory";
+
protected String serverurl = "localhost";
protected int port = 389;
protected String root_dn = "";
@@ -1147,97 +1256,136 @@
protected String version = "2";
protected String scope = "ONELEVEL_SCOPE";
protected String authentication = "simple";
+ protected String encoding = "ISO-8859-1";
- /** LDAP environment information **/
+ /** LDAP environment information */
protected Properties env = new Properties();
+
protected DirContext ctx;
- /** LDAP Query **/
+ /** LDAP Query */
protected int toDo;
+
protected String searchbase = "";
+
protected List attrListe = new LinkedList();
+
protected boolean showAttribute = true;
+
protected String filter = "";
+
protected String doc_element = "doc-element";
protected String row_element = "row-element";
protected String error_element = "ldap-error";
+
protected boolean sax_error = false;
- protected boolean deref_link = false; // Dereference: true ->
dereference the link during search
- protected long count_limit = 0; // Maximum number of
entries to return: 0 -> no limit
- protected int time_limit = 0; // Number of
milliseconds to wait before return: 0 -> infinite
+
+ protected boolean deref_link = false; // Dereference: true ->
dereference the link during search
+ protected long count_limit = 0; // Maximum number of entries
to return: 0 -> no limit
+ protected int time_limit = 0; // Number of milliseconds to
wait before return: 0 -> infinite
+
protected boolean debug = false;
- protected LDAPQuery (LDAPTransformer transformer) {
+ protected LDAPQuery(LDAPTransformer transformer) {
this.transformer = transformer;
- if (null !=
transformer.default_properties.getProperty(MAGIC_INITIALIZER_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_INITIALIZER_ELEMENT)) {
initializer =
transformer.default_properties.getProperty(MAGIC_INITIALIZER_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_SERVERURL_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_SERVERURL_ELEMENT)) {
serverurl =
transformer.default_properties.getProperty(MAGIC_SERVERURL_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_PORT_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_PORT_ELEMENT)) {
port =
Integer.parseInt(transformer.default_properties.getProperty(MAGIC_PORT_ELEMENT));
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_ROOT_DN_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_ROOT_DN_ELEMENT)) {
root_dn =
transformer.default_properties.getProperty(MAGIC_ROOT_DN_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_PASSWORD_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_PASSWORD_ELEMENT)) {
password =
transformer.default_properties.getProperty(MAGIC_PASSWORD_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_VERSION_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_VERSION_ELEMENT)) {
version =
transformer.default_properties.getProperty(MAGIC_VERSION_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_SCOPE_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_SCOPE_ELEMENT)) {
scope =
transformer.default_properties.getProperty(MAGIC_SCOPE_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_AUTHENTICATION_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_AUTHENTICATION_ELEMENT)) {
authentication =
transformer.default_properties.getProperty(MAGIC_AUTHENTICATION_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_SEARCHBASE_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_SEARCHBASE_ELEMENT)) {
searchbase =
transformer.default_properties.getProperty(MAGIC_SEARCHBASE_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_SHOW_ATTRIBUTE_ELEMENT)) {
- showAttribute =
transformer.default_properties.getProperty(MAGIC_SHOW_ATTRIBUTE_ELEMENT).equals("FALSE")
? false : true;
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_SHOW_ATTRIBUTE_ELEMENT)) {
+ showAttribute =
transformer.default_properties.getProperty(MAGIC_SHOW_ATTRIBUTE_ELEMENT).equals("FALSE")
+ ? false : true;
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_DOC_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_DOC_ELEMENT)) {
doc_element =
transformer.default_properties.getProperty(MAGIC_DOC_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_ROW_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_ROW_ELEMENT)) {
row_element =
transformer.default_properties.getProperty(MAGIC_ROW_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_ERROR_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_ERROR_ELEMENT)) {
error_element =
transformer.default_properties.getProperty(MAGIC_ERROR_ELEMENT);
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_SAX_ERROR)) {
- sax_error =
transformer.default_properties.getProperty(MAGIC_SAX_ERROR).equals("TRUE") ?
true : false;
+ if (null!=
+ transformer.default_properties.getProperty(MAGIC_SAX_ERROR))
{
+ sax_error =
transformer.default_properties.getProperty(MAGIC_SAX_ERROR).equals("TRUE")
+ ? true : false;
+ }
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_DEREF_LINK_ELEMENT)) {
+ deref_link =
transformer.default_properties.getProperty(MAGIC_DEREF_LINK_ELEMENT).equals("TRUE")
+ ? true : false;
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_DEREF_LINK_ELEMENT)) {
- deref_link =
transformer.default_properties.getProperty(MAGIC_DEREF_LINK_ELEMENT).equals("TRUE")
? true : false;
- }
- if (null !=
transformer.default_properties.getProperty(MAGIC_COUNT_LIMIT_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_COUNT_LIMIT_ELEMENT)) {
count_limit =
Long.parseLong(transformer.default_properties.getProperty(MAGIC_COUNT_LIMIT_ELEMENT));
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_TIME_LIMIT_ELEMENT)) {
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_TIME_LIMIT_ELEMENT)) {
time_limit =
Integer.parseInt(transformer.default_properties.getProperty(MAGIC_TIME_LIMIT_ELEMENT));
}
- if (null !=
transformer.default_properties.getProperty(MAGIC_DEBUG_ELEMENT)) {
- debug =
transformer.default_properties.getProperty(MAGIC_DEBUG_ELEMENT).equals("TRUE")
? true : false;
+ if (null!=
+
transformer.default_properties.getProperty(MAGIC_DEBUG_ELEMENT)) {
+ debug =
transformer.default_properties.getProperty(MAGIC_DEBUG_ELEMENT).equals("TRUE")
+ ? true : false;
+ }
+ if (null!=
+
transformer.default_properties.getProperty(transformer.MAGIC_ENCODING_ELEMENT))
{
+ encoding =
transformer.default_properties.getProperty(transformer.MAGIC_ENCODING_ELEMENT);
}
+
}
protected void execute() throws Exception, NamingException {
String[] attrList = new String[attrListe.size()];
AttributesImpl attr = new AttributesImpl();
+
if (debug) {
debugPrint();
}
SearchControls constraints = new SearchControls();
+
attrListe.toArray(attrList);
attrListe.clear();
try {
connect();
switch (toDo) {
- case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY:
+ case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY :
try {
if (scope.equals("OBJECT_SCOPE")) {
constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
@@ -1249,41 +1397,63 @@
constraints.setTimeLimit(time_limit);
constraints.setDerefLinkFlag(deref_link);
constraints.setCountLimit(count_limit);
- if (attrList.length > 0) {
+ if (attrList.length>0) {
constraints.setReturningAttributes(attrList);
}
- NamingEnumeration ldapresults =
ctx.search(searchbase, filter, constraints);
+ NamingEnumeration ldapresults =
ctx.search(searchbase,
+
filter,
+
constraints);
- if (!doc_element.equals("")) {
+ if ( !doc_element.equals("")) {
transformer.start(doc_element, attr);
}
- while (ldapresults != null &&
ldapresults.hasMore()) {
- if (!row_element.equals("")) {
+ while ((ldapresults!=null) &&
+ ldapresults.hasMore()) {
+ if ( !row_element.equals("")) {
transformer.start(row_element, attr);
}
- SearchResult si =
(SearchResult)ldapresults.next();
+ SearchResult si = (SearchResult)
ldapresults.next();
javax.naming.directory.Attributes attrs =
si.getAttributes();
- if (attrs != null) {
+
+ if (attrs!=null) {
NamingEnumeration ae = attrs.getAll();
+
while (ae.hasMoreElements()) {
- Attribute at = (Attribute)ae.next();
+ Attribute at = (Attribute) ae.next();
Enumeration vals = at.getAll();
String attrID = at.getID();
+
if (showAttribute) {
transformer.start(attrID, attr);
}
- String attrVal =
(String)vals.nextElement();
- if (query_index > 0) {
- switch
(transformer.getQuery(query_index-1).current_state) {
- case
LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT:
- if
(!transformer.getQuery(query_index-1).filter.equals("")) {
-
transformer.getQuery(query_index-1).filter.concat(", ");
+ String attrVal = (String)
vals.nextElement();
+
+ // Changed by yuryx (encode string
value to UTF characters from base encoding)
+ if ( !encoding.equals("ISO-8859-1"))
{
+ attrVal = new
String(attrVal.getBytes("ISO-8859-1"),
+ encoding);
+ attrVal = new
String(attrVal.getBytes(encoding),
+ "UTF-8");
+ }
+ ;
+ // end
+ if (query_index>0) {
+ switch
(transformer.getQuery(query_index-
+
1).current_state) {
+ case
LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT :
+ if (
!transformer.getQuery(query_index-
+
1).filter.equals("")) {
+
transformer.getQuery(query_index-
+
1).filter.concat(", ");
}
-
transformer.getQuery(query_index-1).filter.concat(attrID).concat("=").concat(attrVal);
+
transformer.getQuery(query_index-
+
1).filter.concat(attrID).concat("=").concat(attrVal);
break;
- default:
-
transformer.start(attrID, attr);
+
+ default :
+ transformer.start(attrID,
+ attr);
}
} else {
transformer.data(String.valueOf(attrVal));
@@ -1293,25 +1463,29 @@
}
}
}
- if (!row_element.equals("")) {
+ if ( !row_element.equals("")) {
transformer.end(row_element);
}
}
- if (!doc_element.equals("")) {
+ if ( !doc_element.equals("")) {
transformer.end(doc_element);
}
- } catch(Exception e) {
+ } catch (Exception e) {
if (sax_error) {
- throw new Exception ("[LDAPTransformer]
Error in LDAP-Query: " + e.toString());
+ throw new Exception("[LDAPTransformer] Error
in LDAP-Query: "+
+ e.toString());
} else {
transformer.start(error_element, attr);
- transformer.data("[LDAPTransformer] Error in
LDAP-Query: " + e);
+ transformer.data("[LDAPTransformer] Error in
LDAP-Query: "+
+ e);
transformer.end(error_element);
-
transformer.getTheLogger().error("[LDAPTransformer] Exception: " +
e.toString());
+
transformer.getTheLogger().error("[LDAPTransformer] Exception: "+
+
e.toString());
}
}
break;
- case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT:
+
+ case LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT :
try {
if (scope.equals("OBJECT_SCOPE")) {
constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
@@ -1323,72 +1497,89 @@
constraints.setTimeLimit(time_limit);
constraints.setDerefLinkFlag(deref_link);
constraints.setCountLimit(count_limit);
- if (attrList.length != 1) {
+ if (attrList.length!=1) {
transformer.start(error_element, attr);
transformer.data("Increment must reference
exactly 1 attribute.");
transformer.end(error_element);
} else {
constraints.setReturningAttributes(attrList);
- NamingEnumeration ldapresults =
ctx.search(searchbase, filter, constraints);
+ NamingEnumeration ldapresults =
ctx.search(searchbase,
+
filter,
+
constraints);
int attrVal = 0;
String attrID = "";
SearchResult si = null;
- while (ldapresults != null &&
ldapresults.hasMore()) {
- si = (SearchResult)ldapresults.next();
+
+ while ((ldapresults!=null) &&
+ ldapresults.hasMore()) {
+ si = (SearchResult) ldapresults.next();
javax.naming.directory.Attributes attrs
= si.getAttributes();
- if (attrs != null) {
+
+ if (attrs!=null) {
NamingEnumeration ae =
attrs.getAll();
+
while (ae.hasMoreElements()) {
- Attribute at =
(Attribute)ae.next();
+ Attribute at = (Attribute)
ae.next();
Enumeration vals = at.getAll();
+
attrID = at.getID();
- attrVal =
Integer.parseInt((String)vals.nextElement());
+ attrVal =
Integer.parseInt((String) vals.nextElement());
}
}
}
++attrVal;
// Specify the changes to make
ModificationItem[] mods = new
ModificationItem[1];
+
// Replace the "mail" attribute with a new
value
mods[0] = new
ModificationItem(DirContext.REPLACE_ATTRIBUTE,
- new BasicAttribute(attrID,
Integer.toString(attrVal)));
+ new
BasicAttribute(attrID,
+
Integer.toString(attrVal)));
// Perform the requested modifications on
the named object
- ctx.modifyAttributes(new
StringBuffer(si.toString().substring(0,si.toString().indexOf(":")))
-
.append(",").append(searchbase).toString(), mods);
+ ctx.modifyAttributes(new
StringBuffer(si.toString().substring(0,
si.toString().indexOf(":"))).append(",").append(searchbase).toString(),
+ mods);
}
- } catch(Exception e) {
+ } catch (Exception e) {
if (sax_error) {
- throw new Exception ("[LDAPTransformer]
Error incrementing an attribute: " + e.toString());
+ throw new Exception("[LDAPTransformer] Error
incrementing an attribute: "+
+ e.toString());
} else {
transformer.start(error_element, attr);
- transformer.data("[LDAPTransformer] Error
incrementing an attribute: " + e.toString());
+ transformer.data("[LDAPTransformer] Error
incrementing an attribute: "+
+ e.toString());
transformer.end(error_element);
-
transformer.getTheLogger().error("[LDAPTransformer] Error incrementing an
attribute: " + e.toString());
+
transformer.getTheLogger().error("[LDAPTransformer] Error incrementing an
attribute: "+
+
e.toString());
}
}
break;
- default:
- } //end switch
+
+ default :
+ } // end switch
} catch (NamingException e) {
if (sax_error) {
- throw new NamingException ("[LDAPTransformer] Failed
ldap-connection to directory service: " + e.toString());
+ throw new NamingException("[LDAPTransformer] Failed
ldap-connection to directory service: "+
+ e.toString());
} else {
transformer.start(error_element, attr);
transformer.data("[LDAPTransformer] Failed
ldap-connection to directory service.");
transformer.end(error_element);
- transformer.getTheLogger().error("[LDAPTransformer]
Failed to connect to " + serverurl + e.toString());
+ transformer.getTheLogger().error("[LDAPTransformer]
Failed to connect to "+
+ serverurl+e.toString());
}
}
try {
disconnect();
} catch (NamingException e) {
if (sax_error) {
- throw new NamingException ("[LDAPTransformer] Failed
ldap-disconnection from directory service: " + e.toString());
+ throw new NamingException("[LDAPTransformer] Failed
ldap-disconnection from directory service: "+
+ e.toString());
} else {
transformer.start(error_element, attr);
transformer.data("[LDAPTransformer] Failed
ldap-disconnection to directory service.");
transformer.end(error_element);
- transformer.getTheLogger().error("[LDAPTransformer]
Failed to disconnect from " + serverurl + e.toString());
+ transformer.getTheLogger().error("[LDAPTransformer]
Failed to disconnect from "+
+ serverurl+e.toString());
}
}
}
@@ -1398,58 +1589,79 @@
}
protected void connect() throws NamingException {
- if (root_dn != null && password != null) {
+ if ((root_dn!=null) && (password!=null)) {
env.put(Context.SECURITY_AUTHENTICATION, authentication);
env.put(Context.SECURITY_PRINCIPAL, root_dn);
env.put(Context.SECURITY_CREDENTIALS, password);
}
- env.put("java.naming.ldap.version", version );
+ env.put("java.naming.ldap.version", version);
env.put(Context.INITIAL_CONTEXT_FACTORY, initializer);
- env.put(Context.PROVIDER_URL, serverurl + ":" + port);
+ env.put(Context.PROVIDER_URL, serverurl+":"+port);
try {
ctx = new InitialDirContext(env);
} catch (NamingException e) {
env.clear();
- throw new NamingException (e.toString());
+ throw new NamingException(e.toString());
}
}
protected void disconnect() throws NamingException {
try {
- if (ctx != null) ctx.close();
+ if (ctx!=null) {
+ ctx.close();
+ }
} catch (NamingException e) {
ctx = null;
env.clear();
- throw new NamingException (e.toString());
+ throw new NamingException(e.toString());
}
ctx = null;
env.clear();
}
protected void debugPrint() {
- transformer.getTheLogger().debug("[LDAPTransformer] query_index:
" + query_index);
- transformer.getTheLogger().debug("[LDAPTransformer]
current_state: " + current_state);
- transformer.getTheLogger().debug("[LDAPTransformer] serverurl: "
+ serverurl);
- transformer.getTheLogger().debug("[LDAPTransformer] port: " +
port);
- transformer.getTheLogger().debug("[LDAPTransformer] root_dn: " +
root_dn);
- transformer.getTheLogger().debug("[LDAPTransformer] password: "
+ password);
- transformer.getTheLogger().debug("[LDAPTransformer] version: " +
version);
- transformer.getTheLogger().debug("[LDAPTransformer] scope: " +
scope);
- transformer.getTheLogger().debug("[LDAPTransformer]
authentication: " + authentication);
- transformer.getTheLogger().debug("[LDAPTransformer] toDo: " +
toDo);
- transformer.getTheLogger().debug("[LDAPTransformer] searchbase:
" + searchbase);
- transformer.getTheLogger().debug("[LDAPTransformer]
showAttribute: " + showAttribute);
- transformer.getTheLogger().debug("[LDAPTransformer] attribute: "
+ attrListe.toString());
- transformer.getTheLogger().debug("[LDAPTransformer] filter: " +
filter);
- transformer.getTheLogger().debug("[LDAPTransformer] doc_element:
" + doc_element);
- transformer.getTheLogger().debug("[LDAPTransformer] row_element:
" + row_element);
- transformer.getTheLogger().debug("[LDAPTransformer]
error_element: " + error_element);
- transformer.getTheLogger().debug("[LDAPTransformer] sax-error: "
+ sax_error);
- transformer.getTheLogger().debug("[LDAPTransformer] deref_link:
" + deref_link);
- transformer.getTheLogger().debug("[LDAPTransformer] count_limit:
" + count_limit);
- transformer.getTheLogger().debug("[LDAPTransformer] time_limit:
" + time_limit);
+ transformer.getTheLogger().debug("[LDAPTransformer] query_index:
"+
+ query_index);
+ transformer.getTheLogger().debug("[LDAPTransformer]
current_state: "+
+ current_state);
+ transformer.getTheLogger().debug("[LDAPTransformer] serverurl: "+
+ serverurl);
+ transformer.getTheLogger().debug("[LDAPTransformer] port:
"+port);
+ transformer.getTheLogger().debug("[LDAPTransformer] root_dn: "+
+ root_dn);
+ transformer.getTheLogger().debug("[LDAPTransformer] password: "+
+ password);
+ transformer.getTheLogger().debug("[LDAPTransformer] version: "+
+ version);
+ transformer.getTheLogger().debug("[LDAPTransformer] scope: "+
+ scope);
+ transformer.getTheLogger().debug("[LDAPTransformer]
authentication: "+
+ authentication);
+ transformer.getTheLogger().debug("[LDAPTransformer] toDo:
"+toDo);
+ transformer.getTheLogger().debug("[LDAPTransformer] searchbase:
"+
+ searchbase);
+ transformer.getTheLogger().debug("[LDAPTransformer]
showAttribute: "+
+ showAttribute);
+ transformer.getTheLogger().debug("[LDAPTransformer] attribute: "+
+ attrListe.toString());
+ transformer.getTheLogger().debug("[LDAPTransformer] filter: "+
+ filter);
+ transformer.getTheLogger().debug("[LDAPTransformer] doc_element:
"+
+ doc_element);
+ transformer.getTheLogger().debug("[LDAPTransformer] row_element:
"+
+ row_element);
+ transformer.getTheLogger().debug("[LDAPTransformer]
error_element: "+
+ error_element);
+ transformer.getTheLogger().debug("[LDAPTransformer] sax-error: "+
+ sax_error);
+ transformer.getTheLogger().debug("[LDAPTransformer] deref_link:
"+
+ deref_link);
+ transformer.getTheLogger().debug("[LDAPTransformer] count_limit:
"+
+ count_limit);
+ transformer.getTheLogger().debug("[LDAPTransformer] time_limit:
"+
+ time_limit);
}
}
}