Package org.teiid.translator

Examples of org.teiid.translator.TranslatorException


   
      String lhsString = getExpressionString(lhs);
      String rhsString = getExpressionString(rhs);
      if(lhsString == null || rhsString == null) {
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.missingNISError"); //$NON-NLS-1$
        throw new TranslatorException(msg);
      }
     
      addCompareCriteriaToList(filterList, op, lhsString, rhsString);
    // Base case
    } else if(criteria instanceof Exists) {
View Full Code Here


      case LE:
        filterList.add("<="); //$NON-NLS-1$
        break;
      default:
              final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.criteriaNotSupportedError"); //$NON-NLS-1$
        throw new TranslatorException(msg);
       
    }
    filterList.add(rhs);
    filterList.add(")"); //$NON-NLS-1$
  }
View Full Code Here

      loadColumnMetadata(insert.getTable());
     
      List<ColumnReference> columns = insert.getColumns();
      List<Expression> values = ((ExpressionValueSource)insert.getValueSource()).getValues();
      if(columns.size() != values.size()) {
        throw new TranslatorException("Error:  columns.size and values.size are not the same.");
      }
     
      for(int i = 0; i < columns.size(); i++) {
        ColumnReference element = columns.get(i);
        Column column = element.getMetadataObject();
View Full Code Here

        this.ldapCtx.setRequestControls(sortCtrl);
        LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Sort ordering was requested, and sort control was created successfully."); //$NON-NLS-1$
      } catch (NamingException ne) {
              final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError") //$NON-NLS-1$
              " : "+ne.getExplanation(); //$NON-NLS-1$
        throw new TranslatorException(msg);
      } catch(IOException e) {
              final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.setControlsError"); //$NON-NLS-1$
        throw new TranslatorException(e,msg);
      }
    }
  }
View Full Code Here

      if (searchDetails.getContextName() != null) {
        LogManager.logError(LogConstants.CTX_CONNECTOR, "Attempted to search context: " //$NON-NLS-1$
            + searchDetails.getContextName());
      }
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.createContextError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
  }
View Full Code Here

      searchEnumeration = this.ldapCtx.search("", filter, ctrls); //$NON-NLS-1$
    } catch (NamingException ne) {
      LogManager.logError(LogConstants.CTX_CONNECTOR, "LDAP search failed. Attempted to search context " //$NON-NLS-1$
          + ctxName + " using filter " + filter); //$NON-NLS-1$
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
      throw new TranslatorException(msg + " : " + ne.getExplanation())//$NON-NLS-1$
    } catch(Exception e) {
      LogManager.logError(LogConstants.CTX_CONNECTOR, "LDAP search failed. Attempted to search context " //$NON-NLS-1$
          + ctxName + " using filter " + filter); //$NON-NLS-1$
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.execSearchError"); //$NON-NLS-1$
      throw new TranslatorException(e, msg);
    }
  }
View Full Code Here

      return null; // GHH 20080326 - if size limit exceeded don't try to read more results
    } catch (NamingException ne) {
      final String msg = "Ldap error while processing next batch of results: " + ne.getExplanation(); //$NON-NLS-1$
      LogManager.logError(LogConstants.CTX_CONNECTOR, msg)// GHH 20080326 - changed to output explanation from LDAP server
      searchEnumeration = null; // GHH 20080326 - NamingEnumertion's are no longer good after an exception so toss it
      throw new TranslatorException(msg);
    }
  }
View Full Code Here

   
    String multivalAttr = modelElement.getDefaultValue();
   
    if(modelAttrName == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.nullAttrError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }

    Attribute resultAttr = attrs.get(modelAttrName);
   
    // If the attribute is not present, we return NULL.
    if(resultAttr == null) {
      // MPW - 2-20-07 - Changed from returning empty string to returning null.
      //row.add("");
      //logger.logTrace("Did not find a match for attribute named: " + modelAttrName);
      // GHH 20080326 - return DN from input parameter
      // if DN attribute is not present in search result
      if (modelAttrName.toUpperCase().equals("DN")) {  //$NON-NLS-1$
        row.add(resultDistinguishedName);
      }
      else {
        row.add(null);
      }
      return;
    }
    Object objResult = null;
    try {
      if(TypeFacility.RUNTIME_TYPES.STRING.equals(modelAttrClass) && "multivalued-concat".equalsIgnoreCase(multivalAttr)) { //$NON-NLS-1$
        // mpw 5/09
        // Order the multi-valued attrs alphabetically before creating a single string,
        // using the delimiter to separate each token
        ArrayList<String> multivalList = new ArrayList<String>();
        NamingEnumeration<?> attrNE = resultAttr.getAll();
        int length = 0;
        while(attrNE.hasMore()) {
          String val = (String)attrNE.next();
          multivalList.add(val);
          length += ((val==null?0:val.length()) + 1);
        }
        Collections.sort(multivalList);
 
        StringBuilder multivalSB = new StringBuilder(length);
        Iterator<String> itr = multivalList.iterator();
        while(itr.hasNext()) {
          multivalSB.append(itr.next());
          if (itr.hasNext()) {
            multivalSB.append(delimiter);
          }
        }
        row.add(multivalSB.toString());
        return;
      }
     
      //just a single value
      objResult = resultAttr.get();
    } catch (NamingException ne) {
            final String msg = LDAPPlugin.Util.getString("LDAPSyncQueryExecution.attrValueFetchError",modelAttrName) +" : "+ne.getExplanation(); //$NON-NLS-1$m//$NON-NLS-2$
            LogManager.logWarning(LogConstants.CTX_CONNECTOR, msg);
      throw new TranslatorException(msg);
    }

    // GHH 20080326 - if attribute is not a string or empty, just
    // return null.
    // TODO - allow return of non-strings (always byte[]) as
    // MM object (or blob).  Perhaps also add directory-specific logic
    // to deserialize byte[] attributes into Java objects
    // when appropriate
    if (objResult instanceof String) {
      strResult = (String)objResult;
      // MPW - 3.9.07 - Also return NULL when attribute is unset or empty string.
      // There is no way to differentiate between being unset and being the empty string.
      if(strResult.equals("")) {  //$NON-NLS-1$
        strResult = null;
      }
    }

    // MPW: 3-11-07: Added support for java.lang.Integer conversion.
    if(TypeFacility.RUNTIME_TYPES.TIMESTAMP.equals(modelAttrClass)) {
      Map<String, String> p = modelElement.getProperties();

      String timestampFormat = p.get("Format"); //$NON-NLS-1$
      SimpleDateFormat dateFormat;
      if(timestampFormat == null) {
        timestampFormat = LDAPConnectorConstants.ldapTimestampFormat;
       
      }
      dateFormat = new SimpleDateFormat(timestampFormat);
      try {
        if(strResult != null) {
          Date dateResult = dateFormat.parse(strResult);
          Timestamp tsResult = new Timestamp(dateResult.getTime());
          row.add(tsResult);
        } else {
          row.add(null);
        }
      } catch(ParseException pe) {
        throw new TranslatorException(pe, LDAPPlugin.Util.getString("LDAPSyncQueryExecution.timestampParseFailed", modelAttrName)); //$NON-NLS-1$
      }   
     
      //  TODO: Extend support for more types in the future.
      // Specifically, add support for byte arrays, since that's actually supported
      // in the underlying data source.
View Full Code Here

    // real connection to the LDAP server
    try {
      ldapCtx = (LdapContext)this.ldapConnection.lookup("")//$NON-NLS-1$
    } catch (NamingException ne) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.createContextError",ne.getExplanation()); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }

    if (command instanceof Update) {
      executeUpdate();
    }
    else if (command instanceof Delete) {
      executeDelete();
    }
    else if (command instanceof Insert) {
      executeInsert();
    }
    else {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.incorrectCommandError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
  }
View Full Code Here

      // distinguishedName value.
      if (nameInsertElement.toUpperCase().equals("DN")) {  //$NON-NLS-1$
        insertValue = ((Literal)insertValueList.get(i)).getValue();
        if (insertValue == null) {
                final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNNullError"); //$NON-NLS-1$
          throw new TranslatorException(msg);
        }
        if (!(insertValue instanceof java.lang.String)) {
                final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.columnSourceNameDNTypeError"); //$NON-NLS-1$
          throw new TranslatorException(msg);
        }
        distinguishedName = (String)insertValue;
      }
      // for other attributes specified in the insert command,
      // create a new
      else {
        insertAttr = new BasicAttribute(nameInsertElement);
        insertValue = ((Literal)insertValueList.get(i)).getValue();
        insertAttr.add(insertValue);
        insertAttrs.put(insertAttr);
      }
    }
    // if the DN is not specified, we don't know enough to attempt
    // the LDAP add operation, so throw an exception
    if (distinguishedName == null) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.noInsertSourceNameDNError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    // just try to create a new LDAP entry using the DN and
    // attributes specified in the INSERT operation.  If it isn't
    // legal, we'll get a NamingException back, whose explanation
    // we'll return in a ConnectorException
    try {
      ldapCtx.createSubcontext(distinguishedName, insertAttrs);
    } catch (NamingException ne) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.insertFailed",distinguishedName,ne.getExplanation()); //$NON-NLS-1$
      throw new TranslatorException(msg);
    } catch (Exception e) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.insertFailedUnexpected",distinguishedName); //$NON-NLS-1$
      throw new TranslatorException(e, msg);
    }
  }
View Full Code Here

TOP

Related Classes of org.teiid.translator.TranslatorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.