PILLUTLAAVINASH / google-enterprise-connector-manager

Automatically exported from code.google.com/p/google-enterprise-connector-manager
0 stars 0 forks source link

Submitting case variant connector name gives wrong error message #130

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a connector named "abcd"
2. Create another connector name "Abcd"
3. Error message displayed is "No connector configuration returned by the
connector manager."

What is the expected output? What do you see instead?
We return an error status that should display the message:
"The following connector name already exists: ..."

Please use labels and text to provide additional information.

I looked into the case where adding a new connector whose
name is a case-only variant of an existing connector shows a
"No connector configuration returned by the connector manager"
message in the Add Connector page.

A look at SetConnectorConfigHandler shows this snippet of code:

   this.configRes = null;
   try {
     this.configRes = manager.setConnectorConfig(this.connectorName,
         this.connectorType, this.configData, this.language, this.update);
    ...
   } catch (ConnectorExistsException e) {
     this.status = new ConnectorMessageCode(
         ConnectorMessageCode.EXCEPTION_CONNECTOR_EXISTS, connectorName);
     LOGGER.log(Level.WARNING, ServletUtil.LOG_EXCEPTION_CONNECTOR_EXISTS, e);
   } catch (InstantiatorException e) {
    ...

The SetConnectorConfigHandler catches the ConnectorExistsException,
and returns an appropriate status code.  Also, since an exception
was thrown, the ConfigureResponse (this.configRes) remains null.

I made sure that the status was making it into the generated response
and I get:
INFO: writeConfigureResponse sends status:  status.messageId=5302 
status.message=null  status.params=[java.lang.String:
"amobius"]  writeMessageCode=  <StatusId>5302</StatusId>  <CMParams
Order="0" CMParam="amobius"/>

The GSA is apparently ignoring the non-success status being returned.

If I fabricate a ConfigureResponse with an appropriate message
(the ServletUtil.LOG_EXCEPTION_CONNECTOR_EXISTS message displayed
in the log), then that gets displayed.  However, that, I believe
bypasses the localized message string lookup code.

If I do fabricate a ConfigureResponse with a message,
the original status id is lost - replaced with
ConnectorMessageCode.INVALID_CONNECTOR_CONFIG by
SetManagerConfig.processDoPost().

By the observed behaviour, I believe the GSA only checks
for a returned statusId of SUCCESS.  If it is not SUCCESS,
the GSA assumes that ConfigureResponse.message contains
the error message to display.  However, for any of the
5 Exceptions caught by SetConnectorConfigHandler, there
will be a null ConfigureResponse and therefore the GSA shows
"No connector configuration returned by the connector manager"

After some experimentation, I observed that if I return
an empty, but non-null, ConfigureResponse, the correct
error message gets displayed.

Files Changed:
Index:
connector-manager/source/java/com/google/enterprise/connector/servlet/SetConnect
orConfig.java
===================================================================

---
connector-manager/source/java/com/google/enterprise/connector/servlet/SetConnect
orConfig.java
(revision 1588)
+++
connector-manager/source/java/com/google/enterprise/connector/servlet/SetConnect
orConfig.java
(working copy)
@@ -94,9 +94,18 @@
     SetConnectorConfigHandler handler =
         new SetConnectorConfigHandler(xmlBody, manager);
     ConfigureResponse configRes = handler.getConfigRes();
-    ConnectorMessageCode status = (configRes == null) ? handler.getStatus() :
-      new ConnectorMessageCode(ConnectorMessageCode.INVALID_CONNECTOR_CONFIG);
-
+    ConnectorMessageCode status;
+    if (configRes == null) {
+      status = handler.getStatus();
+      if (!status.isSuccess()) {
+        // Avoid a bug in GSA that displays "No connector configuration
+        // returned by the connector manager.", rather than the error status.
+        configRes = new ConfigureResponse(null, null, null);
+      }
+    } else {
+      status = new ConnectorMessageCode(
+          ConnectorMessageCode.INVALID_CONNECTOR_CONFIG);
+    }
     ConnectorManagerGetServlet.writeConfigureResponse(
         out, status, configRes);
     out.close();

Original issue reported on code.google.com by Brett.Mi...@gmail.com on 16 Mar 2009 at 1:55

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Fixed 21 Mar 2009 in Connector Manager revision r1608

Original comment by Brett.Mi...@gmail.com on 31 Mar 2009 at 9:25

GoogleCodeExporter commented 8 years ago

Original comment by jl1615@gmail.com on 28 Apr 2009 at 8:44