Package org.apache.oodt.cas.catalog.exception

Examples of org.apache.oodt.cas.catalog.exception.CatalogServiceException


      for (Catalog catalog : this.catalogs)
        if (catalog.getId().equals(catalogUrn))
          return catalog;
      return null;
    }catch (Exception e) {
      throw new CatalogServiceException("Failed to get catalog catalog '" +  catalogUrn + "' : " + e.getMessage(), e);
    }finally {
      this.catalogsLock.readLock().unlock();
    }
  }
View Full Code Here


      Set<String> catalogIds = new HashSet<String>();
      for (Catalog catalog : this.catalogs)
        catalogIds.add(catalog.getId());
      return catalogIds;
    }catch (Exception e) {
      throw new CatalogServiceException("Failed to get current catalog ids list : " + e.getMessage(), e);
    }finally {
      this.catalogsLock.readLock().unlock();
    }
  }
View Full Code Here

    }
  }
   
  public TransactionReceipt ingest(Metadata metadata) throws CatalogServiceException {
    if (this.restrictIngestPermissions)
      throw new CatalogServiceException("Ingest permissions are restricted for this CatalogService -- request denied");
    try
      boolean performUpdate = false;
      TransactionId<?> catalogServiceTransactionId = this.getCatalogServiceTransactionId(metadata);
      if (performUpdate = this.ingestMapper.hasCatalogServiceTransactionId(catalogServiceTransactionId))
        LOG.log(Level.INFO, "TransactionId '" + catalogServiceTransactionId + "' is an existing TransactionId, switching to update mode");
      List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>();
      for (Catalog catalog : this.getFilteredCatalogList(metadata)) {     
        if (catalog.isIngestable()) {
          this.ingestMapperLock.writeLock().lock();
          try {
            // perform update
            if (performUpdate) {
              if (!Boolean.parseBoolean(metadata.getMetadata(ENABLE_UPDATE_MET_KEY)))
                throw new CatalogServiceException("TransactionId '" + catalogServiceTransactionId + "' already exists -- enable update by setting metadata key '" + ENABLE_UPDATE_MET_KEY + "'=true");
              TransactionId<?> catalogTransactionId = this.ingestMapper.getCatalogTransactionId(catalogServiceTransactionId, catalog.getId());
              if (catalogTransactionId != null) {
                CatalogReceipt catalogReceipt = catalog.update(catalogTransactionId, metadata);
                if (catalogReceipt != null) {
                  if (!catalogReceipt.getTransactionId().equals(catalogTransactionId)) {
                    this.ingestMapper.deleteTransactionIdMapping(catalogTransactionId, catalog.getId());
                    this.ingestMapper.storeTransactionIdMapping(catalogServiceTransactionId, this.transactionIdFactory, catalogReceipt, catalog.getTransactionIdFactory());
                  }
                  catalogReceipts.add(catalogReceipt);
                  LOG.log(Level.INFO, "Successfully updated metadata to catalog '" + catalog + "' for TransactionId '" + catalogServiceTransactionId + "'");
                }else {
                  LOG.log(Level.SEVERE, "Update attempt to catalog '" + catalog + "' failed for TransactionId '" + catalogServiceTransactionId + "' -- update returned false");
                }
              }else {
                LOG.log(Level.INFO, "Catalog '" + catalog + "' was not on ingest list for TransactionId '" + catalogServiceTransactionId + "' -- skipping");
              }
            // perform ingest 
            }else {
              LOG.log(Level.INFO, "Performing ingest for TransactionId '" + catalogServiceTransactionId + "' to catalog '" + catalog + "'");
              CatalogReceipt catalogReceipt = catalog.ingest(metadata);
              if (catalogReceipt != null) {
                LOG.log(Level.INFO, "Successfully ingested metadata -- Indexing TransactionId information for ingest (CatalogService TransactionId = '" + catalogServiceTransactionId + "', Catalog TransactionId = '" + catalogReceipt.getTransactionId() + "', catalog = '" + catalogReceipt.getCatalogId() + "')");
                this.ingestMapper.storeTransactionIdMapping(catalogServiceTransactionId, this.transactionIdFactory, catalogReceipt, catalog.getTransactionIdFactory());
                catalogReceipts.add(catalogReceipt);
              }else {
                LOG.log(Level.WARNING, "Catalog '" + catalog + "' not interested in any Metadata for TransactionId '" + catalogServiceTransactionId + "'");
              }
            }
          }catch (Exception e) {
            LOG.log(Level.WARNING, "Failed to add metadata to catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
            if (this.oneCatalogFailsAllFail)
              throw new CatalogServiceException("Failed to add metadata to catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
          }finally {
            this.ingestMapperLock.writeLock().unlock();
          }
        }else {
          LOG.log(Level.WARNING, "Ingest not permitted to catalog '" + catalog + "' -- skipping over catalog");
        }
      }
      return (catalogReceipts.size() > 0) ? new TransactionReceipt(catalogServiceTransactionId, catalogReceipts) : null;
    }catch (Exception e) {
      throw new CatalogServiceException("Error occured during Metadata ingest attempt : " + e.getMessage(), e);
    }
  }
View Full Code Here

   * @param metadata
   * @throws CatalogServiceException
   */
  public void delete(Metadata metadata) throws CatalogServiceException {
    if (this.restrictIngestPermissions)
      throw new CatalogServiceException("Delete permissions are restricted for this CatalogService -- request denied");
    TransactionId<?> catalogServiceTransactionId = this.getCatalogServiceTransactionId(metadata, false);
    if (catalogServiceTransactionId != null) {
      for (Catalog catalog : this.getFilteredCatalogList(metadata)) {
        if (catalog.isIngestable()) {
          this.ingestMapperLock.writeLock().lock();
          try {
            TransactionId<?> catalogTransactionId = this.ingestMapper.getCatalogTransactionId(catalogServiceTransactionId, catalog.getId());
            if (catalogTransactionId != null) {
              if (this.doReduce(metadata)) {
                LOG.log(Level.INFO, "Deleting metadata from TransactionId '" + catalogServiceTransactionId + "' for catalog '" + catalog + "'");
                if (catalog.reduce(catalogTransactionId, metadata)) {
                  LOG.log(Level.INFO, "Successfully deleted metadata from catalog '" + catalog + "' for TransactionId [id = " + catalogServiceTransactionId + "]");
                }else {
                  LOG.log(Level.INFO, "Failed to deleted metadata from catalog '" + catalog + "' for TransactionId [id = " + catalogServiceTransactionId + "] -- delete returned false");
                }
              }else {
                LOG.log(Level.INFO, "Deleting all records of TransactionId from catalog '" + catalog + "'");
                if (catalog.delete(catalogTransactionId)) {
                  this.ingestMapper.deleteTransactionIdMapping(catalogTransactionId, catalog.getId());
                  LOG.log(Level.INFO, "Successfully deleted metadata from catalog '" + catalog + "' for TransactionId [id = " + catalogServiceTransactionId + "]");
                }else {
                  LOG.log(Level.INFO, "Failed to deleted metadata from catalog '" + catalog + "' for TransactionId [id = " + catalogServiceTransactionId + "] -- delete returned false");
                }
              }
            }else {
              LOG.log(Level.INFO, "Catalog '" + catalog + "' was not on delete list for TransactionId '" + catalogServiceTransactionId + "' -- skipping");
            }
          }catch (Exception e) {
            LOG.log(Level.WARNING, "Error occured while deleting metadata for TransactionId [id = " + catalogServiceTransactionId + "] : " + e.getMessage(), e);
            if (this.oneCatalogFailsAllFail)
              throw new CatalogServiceException("Error occured while deleting metadata for TransactionId [id = " + catalogServiceTransactionId + "] : " + e.getMessage(), e);
          }finally {
            this.ingestMapperLock.writeLock().unlock();
          }
        }else {
          LOG.log(Level.WARNING, "Deletion is not permitted to catalog '" + catalog + "' -- skipping over catalog");
       
      }
    }else {
      throw new CatalogServiceException("Must specify a TransactionId to delete");
    }
  }
View Full Code Here

        String val = catalog.getProperty(key);
        if (val != null)
          vals.add(val);
      }catch (Exception e) {
        if (this.oneCatalogFailsAllFail)
          throw new CatalogServiceException("Failed to get catalog property '" + key + "' from catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
        else
          LOG.log(Level.WARNING, "Failed to get catalog property '" + key + "' from catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
      }
    }
    return vals;
View Full Code Here

            value = catalogProperties.getProperty((String) key);
          properties.setProperty((String) key, value);
        }
      }catch (Exception e) {
        if (this.oneCatalogFailsAllFail)
          throw new CatalogServiceException("Failed to get catalog properties from catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
        else
          LOG.log(Level.WARNING, "Failed to get catalog properties from catalog '" + catalog.getId() + "' : " + e.getMessage(), e);
      }
    }
    return properties;
View Full Code Here

      if (catalog != null)
        return catalog.getProperties();
      else
        return null;
    }catch (Exception e) {
      throw new CatalogServiceException("Failed to get catalog properties from catalog '" + catalogUrn + "' : " + e.getMessage(), e);
    }
  }
View Full Code Here

            }
          }
          return new Page(new ProcessedPageInfo(pageInfo.getPageSize(), pageInfo.getPageNum(), totalResults), queryExpression, catalogIds, this.indexReceipts(this.getPossiblyUnindexedTransactionReceipts(pageOfReceipts)));
        }
      }catch (Exception e) {
        throw new CatalogServiceException(e.getMessage(), e);
      }
    }else {
      QueryPager queryPager = new QueryPager(this._query(queryExpression, catalogIds));
      queryPager.setPageInfo(pageInfo);
      return this.getPage(queryExpression, catalogIds, queryPager);
View Full Code Here

   * @return
   * @throws CatalogServiceException
   */
  public List<TransactionReceipt> _query(QueryExpression queryExpression, Set<String> catalogIds) throws CatalogServiceException {
    if (this.restrictQueryPermissions)
      throw new CatalogServiceException("Query permissions are restricted for this CatalogService -- request denied");
    try {
      LOG.log(Level.INFO, "Recieved query '" + queryExpression + "'");
      if (this.simplifyQueries) {
        queryExpression = QueryUtils.simplifyQuery(queryExpression);
        LOG.log(Level.INFO, "Simplified query to '" + queryExpression + "' -- routing query to catalogs");
      }
      QueryResult queryResult = this.queryRecur(queryExpression, catalogIds);
      List<CatalogReceipt> catalogReceipts = new Vector<CatalogReceipt>();
      if (queryResult.getCatalogReceipts() == null && queryResult.getInterestedCatalogs() != null) {
        for (Catalog catalog : this.getCurrentCatalogList()) {
          try {
            if (queryResult.getInterestedCatalogs().contains(catalog.getId())) {
              LOG.log(Level.INFO, "Restricting query to understood terms for Catalog '" + catalog + "'");
              QueryExpression reducedExpression = this.reduceToUnderstoodExpressions(catalog, queryExpression);
              LOG.log(Level.INFO, "Querying Catalog '" + catalog + "' with query '" + reducedExpression + "'");
              catalogReceipts.addAll(catalog.query(reducedExpression));
            }
          }catch (Exception e) {
            if (this.oneCatalogFailsAllFail)
              throw new CatalogServiceException("Failed to query catalog '" + catalog.getId() + "' for query '" + queryExpression + "' : " + e.getMessage(), e);
            else
              LOG.log(Level.WARNING, "Failed to query catalog '" + catalog.getId() + "' for query '" + queryExpression + "' : " + e.getMessage(), e);
         
        }
      }
      List<TransactionReceipt> transactionReceipts = this.getPossiblyUnindexedTransactionReceipts(catalogReceipts);
      LOG.log(Level.INFO, "Sorting Query Results . . . ");
      Collections.sort(transactionReceipts, new Comparator<TransactionReceipt>() {
        public int compare(TransactionReceipt o1,
            TransactionReceipt o2) {
          return o2.getTransactionDate().compareTo(o1.getTransactionDate());
        }
      });

      LOG.log(Level.INFO, "Query returned " + transactionReceipts.size() + " results");
      return transactionReceipts;
    }catch (Exception e) {
      e.printStackTrace();
      throw new CatalogServiceException("Failed to get TransactionId to Metadata map for query '" + queryExpression + "' : " + e.getMessage(), e);
    }
  }
View Full Code Here

       }
       for (TransactionId<?> transactionId : existing.keySet())
         returnList.add(new TransactionReceipt(transactionId, existing.get(transactionId)));
       return returnList;
    }catch (Exception e) {
      throw new CatalogServiceException(e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.catalog.exception.CatalogServiceException

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.