Package org.wso2.carbon.dataservices.core

Examples of org.wso2.carbon.dataservices.core.DataServiceFault


        DataSource externalDS = this.createDataSource();
        this.setDBCPConnectionManager(new DBCPConnectionManager(this, externalDS));
        try {
          this.initSQLDataSource();
        } catch (SQLException e) {
          throw new DataServiceFault(e, DBConstants.FaultCodes.CONNECTION_UNAVAILABLE_ERROR,
              e.getMessage());
        }
    }
  }
View Full Code Here


    }
  }
 
  private void validateJNDIConfig() throws DataServiceFault {
    if (DBUtils.isEmptyString(this.getProperty(DBConstants.JNDI.INITIAL_CONTEXT_FACTORY))) {
      throw new DataServiceFault("Initial context factory cannot be null in config '" +
          this.getConfigId() + "'");
    }
        if (DBUtils.isEmptyString(this.getProperty(DBConstants.JNDI.PROVIDER_URL))) {
          throw new DataServiceFault("Provider URL cannot be null in config '" +
          this.getConfigId() + "'");
    }
        if (DBUtils.isEmptyString(this.getProperty(DBConstants.JNDI.RESOURCE_NAME))) {
          throw new DataServiceFault("Resource name cannot be null in config '" +
          this.getConfigId() + "'");
    }
        this.validateDBCPSQLConfig();
  }
View Full Code Here

      if (resourceName != null && resourceName.trim().length() > 0) {
          InitialContext context = new InitialContext(properties);
          DataSource dataSource = (DataSource) context.lookup(resourceName);
          return dataSource;
      } else {
        throw new DataServiceFault("JNDI resource name not specified.");
      }
    } catch (NamingException e) {
      throw new DataServiceFault(e,
          "Naming error occurred while trying to retrieve JDBC Connection from JNDI tree.");
    }
  }
View Full Code Here

                scraperConfiguration = new ScraperConfiguration(inputSource);
            }
            scraper = new Scraper(scraperConfiguration, "")
            return scraper;
        } catch (FileNotFoundException e) {
            throw new DataServiceFault(e, "Error in reading web harvest configuration");
        }
    }
View Full Code Here

        try {
            Scraper scraper = getScraperConfig();
            scraper.execute();
            return (Variable) scraper.getContext().get(queryVariable);
        } catch (Exception e) {
            throw new DataServiceFault(e, "Error in Scraper Execution");
        }

    }
View Full Code Here

    private void registerSubscribers(EventBroker eventBroker, String topic,
                                     List<String> endpointUrls) throws DataServiceFault {
        if (eventBroker == null) {
            String msg = "Unable To Register Event Subscribers, Event Broker Not Available.";
            log.error(msg);
            throw new DataServiceFault(msg);
        }

        /*
         * Adding new subscriptions.
         */
        Subscription subscription;
        for (String epr : endpointUrls) {
            try {
                subscription = new Subscription();
                subscription.setEventSinkURL(epr);
                subscription.setId(UUID.randomUUID().toString());
                subscription.setTopicName(topic);
                subscription.setEventDispatcherName(EVENT_DISPATCHER_NAME);
                subscription.setOwner(this.getDataService().getName());
                eventBroker.subscribe(subscription);
            } catch (Exception e) {
                throw new DataServiceFault(e, "Error in event subscription for EPR: " + epr +
                        " Topic:" + topic);
            }
        }
    }
View Full Code Here

     */
    private void sendMessageToTopic(OMElement omMessage, String topic) throws DataServiceFault {
        try {
            EventBroker eventBroker = DataServicesDSComponent.getEventBroker();
            if (eventBroker == null) {
              throw new DataServiceFault("Event broker instance is not available");
            }
            Message message = new Message();
            message.setMessage(omMessage);
            eventBroker.publish(message, topic);
        } catch (Exception e) {
          throw new DataServiceFault(e, "Error in publishing event for topic: " +
                    topic + " message:-\n" + omMessage);
        }
    }
View Full Code Here

      validateRDBMSConfig();
        this.setDBCPConnectionManager(new DBCPConnectionManager(this));
        try {
          this.initSQLDataSource();
        } catch (SQLException e) {
          throw new DataServiceFault(e, DBConstants.FaultCodes.CONNECTION_UNAVAILABLE_ERROR,
              e.getMessage());
        }
    }
  }
View Full Code Here

 
  private XADataSourceInfo createXADataSourceInfo(Map<String, String> properties)
      throws DataServiceFault {
    String className = properties.get(DBConstants.RDBMS.XA_DATASOURCE_CLASS);
    if (DBUtils.isEmptyString(className)) {
      throw new DataServiceFault(
          "The class cannot be empty in XADataSource entry with props: \n" + properties);
    }
    String propsString = properties.get(DBConstants.RDBMS.XA_DATASOURCE_PROPS);
    OMElement xaPropsEl = null;
    try {
      xaPropsEl = AXIOMUtil.stringToOM(propsString);
    } catch (Exception e) {
      throw new DataServiceFault(e, "Error in passing XA data source properties: " + propsString);
    }
    Map<String, String> xaProps = DBUtils.extractProperties(xaPropsEl);
    return new XADataSourceInfo(this.getDataService(), className, xaProps);
  }
View Full Code Here

    try {
      XMLStreamWriter xmlWriter = XMLOutputFactory.newInstance()
          .createXMLStreamWriter(new NullOutputStream());
      this.execute(xmlWriter, true);
    } catch (XMLStreamException e) {
      throw new DataServiceFault(e, "Error in pre-fetching data");
    }
  }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.dataservices.core.DataServiceFault

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.