Package com.google.feedserver.configstore

Examples of com.google.feedserver.configstore.FeedConfigStoreException


    Properties prop = extractFeedConfigProperties(config);

    String adapterName = prop.getProperty(FeedServerConfiguration.FEED_ADAPTER_NAME_KEY);

    if (!hasAdapterConfiguration(namespace, adapterName)) {
      throw new FeedConfigStoreException(Reason.ADAPTER_CONFIG_DOES_NOT_EXIST,
          "There is no adapter configuration with the given name : " + adapterName
              + " Add the adapter configuration and then try adding feed configuration");
    }

    // Check and create the namespace and feed configuration directories if
    // they don't exist
    createNamespaceAndFeedConfigDir(namespace);

    // Get the handle to the file at the given location
    File feedFile = getFeedConfigFilePath(namespace, config.getFeedId());

    // Check that the file does not exist
    if (feedFile.exists()) {
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR, "The feed already exists");
    }

    // Write the feed values to the file
    writeToFile(prop, feedFile, true);
  }
View Full Code Here


    try {
      // Get the feed configuration
      return getFeedConfiguration(namespace, feedId, feedFile);
    } catch (FileNotFoundException e) {
      throw new FeedConfigStoreException(Reason.FEED_DOES_NOT_EXIST, "File '" +
          feedFile.getAbsolutePath() + "' not found.  Please check namespace '" + namespace +
          "' and feedId '" + feedId + "'");
    } catch (IOException e) {
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "Problems loading the feed configuration for namespace '" + namespace + "' and feedId '"
          + feedId + "'");
    }
  }
View Full Code Here

    // Construct and get the feed file handle
    File feedFile = getFeedConfigFilePath(namespace, feedId, userId);

    // Check that the feed file exists
    if (!feedFile.exists()) {
      throw new FeedConfigStoreException(Reason.FEED_DOES_NOT_EXIST,
          "No feed configuration exists with the given feedId : " + feedId
              + "  for the given namespace : " + namespace);
    }

    // Delete the feed configuration
    if (!feedFile.delete()) {
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "Unable to delete the feed configuration for feedId : " + feedId
              + "  for the given namespace : " + namespace);
    }

  }
View Full Code Here

    File feedFile = getFeedConfigFilePath(namespace, config.getFeedId(), userId);

    // Check that the file does not exist
    if (!feedFile.exists()) {
      logger.log(Level.WARNING, "The feed configuration file does not exist");
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "The feed configuration file does not exist");
    }

    // Write the values to the file
    writeToFile(prop, feedFile, false);
View Full Code Here

      throws FeedConfigStoreException {
    // Check for an instance that supports namespace
    if (!(config instanceof NamespacedAdapterConfiguration)) {
      logger.log(Level.SEVERE, "Expected an instance of : "
          + NamespacedAdapterConfiguration.class.getClass() + " but was : " + config.getClass());
      throw new FeedConfigStoreException(Reason.INVALID_ADAPTER_CONFIGURATION,
          "Please provide an instance of : " + NamespacedAdapterConfiguration.class);
    }

    // Create the namespace and adapter config directories if they are not
    // present
    createNamespaceAndAdapterConfigDir(namespace);

    // Type cast to the instance with namespace adapter configuration
    NamespacedAdapterConfiguration namespaceAdapterConfig = (NamespacedAdapterConfiguration) config;

    // Get the adapter config file
    File adapaterFile = getAdapterConfigFile(namespace, namespaceAdapterConfig.getAdapterName());

    // Check if the adapter configuration already exists
    if (adapaterFile.exists()) {
      logger.log(Level.WARNING, "Adapter configuration already exists!!");
      throw new FeedConfigStoreException(Reason.INVALID_ADAPTER_CONFIGURATION,
          "Adapter configuration already exists!!");
    }

    // Get the adapter config properties
    Properties prop = extractAdapterConfigProperties(namespaceAdapterConfig);
View Full Code Here

        namespace, ((NamespacedAdapterConfiguration) config).getAdapterName());

    // Check that the file does not exist
    if (!adapterConfigFile.exists()) {
      logger.log(Level.WARNING, "The adapter configuration file does not exist");
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "The adapter configuration file does not exist");
    }

    // Write the values to the file
    writeToFile(prop, adapterConfigFile, false);
View Full Code Here

   * @see com.google.feedserver.configstore.FeedConfigStore
   * #allowAdapter(java.lang.String, java.lang.String)
   */
  @Override
  public void allowAdapter(String namespace, String adapterId) throws FeedConfigStoreException {
    throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
        "This functionality is not implemented");
  }
View Full Code Here

    // Get the handle to the adapter file
    File adapterFile = getAdapterConfigFile(namespace, adapterId);

    // Check that the adapter file exists
    if (!adapterFile.exists()) {
      throw new FeedConfigStoreException(Reason.ADAPTER_CONFIG_DOES_NOT_EXIST,
          "No adapter configuration exists with the given adaptername : " + adapterId
              + "  for the given namespace : " + namespace);
    }

    // Delete the adapter configuration
    if (!adapterFile.delete()) {
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "Unable to delete the adapter configuration for adaptername : " + adapterId
              + "  for the given namespace : " + namespace);
    }
  }
View Full Code Here

   * @see com.google.feedserver.configstore.FeedConfigStore
   * #disallowAdapter(java.lang.String, java.lang.String)
   */
  @Override
  public void disallowAdapter(String namespace, String adapterId) throws FeedConfigStoreException {
    throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
        "This functionality is not implemented");
  }
View Full Code Here

      throws FeedConfigStoreException {
    try {
      // Check if a new file needs to be created
      if (createNewFile) {
        if (!file.createNewFile()) {
          throw new FeedConfigStoreException(Reason.INTERNAL_ERROR, "Unable to create file : "
              + file.getAbsolutePath() + " to write the configuration details");
        }
      }

      // Create an output stream and write to the file
      FileOutputStream outputStream = new FileOutputStream(file);
      prop.store(outputStream, "");
    } catch (FileNotFoundException e) {
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "Problems encountered while locating the file : " + file.getAbsolutePath()
              + " to write the configuration details", e);
    } catch (IOException e) {
      throw new FeedConfigStoreException(Reason.INTERNAL_ERROR,
          "Problems encountered while writing the configuration details to the file : "
              + file.getAbsolutePath(), e);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.feedserver.configstore.FeedConfigStoreException

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.