Package org.apache.oodt.cas.filemgr.system

Examples of org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient


* Created by bugg on 07/03/14.
*/
public class OODTProcesses {

    public boolean deleteProductByName(OODTConfig config, String filename) throws Exception {
        XmlRpcFileManagerClient client = config.getXMLRpcClient();
        Product p = client.getProductByName(filename);
        List<Reference> refs = client.getProductReferences(p);
        if (refs == null) {
            throw new Exception("FileManager returned null References");
        }
        for (Reference ref : refs) {
            if (!client.removeFile(new File(new URI(ref.getDataStoreReference()))
                    .getAbsolutePath())) {
                throw new Exception("Failed to delete file '"
                        + ref.getDataStoreReference() + "'");
            }
        }
        if (client.removeProduct(p)) {
          //  printer.println("Successfully deleted product '"
           //        + p.getProductName() + "'");
            return true;
        } else {
            throw new Exception("Delete product returned false");
View Full Code Here


*/
public class OODTProcesses {


    public Map<String, Map<String, String>> getAllProducts(OODTConfig config, String productTypeName) throws Exception {
        XmlRpcFileManagerClient client = config.getXMLRpcClient();
        ProductType type = client.getProductTypeByName(productTypeName);
        if (type == null) {
            throw new Exception("FileManager returned null ProductType");
        }
        ProductPage firstPage = client.getFirstPage(type);
        if (firstPage == null) {
            throw new Exception("FileManager returned null product page");
        }

        Map<String, Map<String, String>> o = new HashMap<String, Map<String, String>>();

        for (int pid = 0; pid < firstPage.getTotalPages(); pid++) {
            if (pid > 0) {
                firstPage = client.getNextPage(type, firstPage);
            }
            for (Product p : firstPage.getPageProducts()) {
                Metadata met = client.getMetadata(p);

                Map<String, String> h = new HashMap<String, String>();
                h.put("name", p.getProductName());
                h.put("type", p.getProductType().getName());
                h.put("structure", p.getProductStructure());
View Full Code Here

    private static XmlRpcFileManagerClient client = null;

    public boolean loadXMLRpcClient(String fmUrlStr){
        try {
            client = new XmlRpcFileManagerClient(new URL(fmUrlStr));
        } catch (Exception e) {
            LOG.log(Level.SEVERE,
                    "Unable to create file manager client: Message: "
                            + e.getMessage() + ": errors to follow");
        }
View Full Code Here

            stageFile(asURI(file), new File(fileStagingInfo.getStagingDir()),
                  pgeMetadata, logger);
         }
      }
      if (!fileStagingInfo.getProductIds().isEmpty()) {
         XmlRpcFileManagerClient fmClient = createFileManagerClient(pgeMetadata);
         for (String productId : fileStagingInfo.getProductIds()) {
            logger.log(Level.INFO, "Staging product [" + productId
                  + "] to directory ["
                  + fileStagingInfo.getStagingDir() + "]");
            for (URI uri : getProductReferences(productId, fmClient)) {
View Full Code Here

      String filemgrUrl = pgeMetadata.getMetadata(QUERY_FILE_MANAGER_URL);
      if (filemgrUrl == null) {
         throw new Exception("Must specify [" + QUERY_FILE_MANAGER_URL
               + "] if you want to stage product IDs");
      }
      return new XmlRpcFileManagerClient(new URL(filemgrUrl));
   }
View Full Code Here

          && envReplaceRecur)
        ;
      if (value.toUpperCase().matches(
          "^\\s*SQL\\s*\\(.*\\)\\s*\\{.*\\}\\s*$"))
        value = QueryUtils
            .getQueryResultsAsString(new XmlRpcFileManagerClient(
                new URL(inputMetadata
                    .getMetadata(QUERY_FILE_MANAGER_URL
                        .getName())))
                .complexQuery(SqlParser
                    .parseSqlQueryMethod(value)));
View Full Code Here

      Reference ref1 = new Reference();
      ref1.setDataStoreReference(uri1);
      Reference ref2 = new Reference();
      ref2.setDataStoreReference(uri2);

      XmlRpcFileManagerClient fmClient = createStrictMock(XmlRpcFileManagerClient.class);
      expect(fmClient.getProductReferences(ProductIdMatcher.eqProductId(productId))).andReturn(
            Lists.newArrayList(ref1, ref2));
      replay(fmClient);

      List<URI> uris = FileStager.getProductReferences(productId, fmClient);
      assertEquals(2, uris.size());
View Full Code Here

   public void execute(ActionMessagePrinter printer)
         throws CmdLineActionException {
      try {
         Validate.notNull(productTypeName, "Must specify productTypeName");

         XmlRpcFileManagerClient client = getClient();
         ProductType pt = client.getProductTypeByName(productTypeName);
         if (pt == null) {
            throw new Exception("FileManager returned null ProductType");
         }
         printer.println("Type: ["
               + productTypeName
               + "], Num Products: ["
               + client.getNumProducts(pt) + "]");
      } catch (Exception e) {
         throw new CmdLineActionException(
               "Failed to get number of products for" + " ProductType name '"
                     + productTypeName + "' : " + e.getMessage(), e);
      }
View Full Code Here

     */
    public MetadataBasedProductMover(String pathSpec, String fmUrl)
            throws InstantiationException {
        this.pathSpec = pathSpec;
        try {
            this.fmgrClient = new XmlRpcFileManagerClient(new URL(fmUrl));
        } catch (MalformedURLException e) {
            throw new InstantiationException(e.getMessage());
        } catch (ConnectionException e) {
            throw new InstantiationException(e.getMessage());
        }
View Full Code Here

      try {
         Validate.notNull(productTypeName, "Must specify productTypeName");
         Validate.isTrue(currentPageNum != -1, "Must specify currentPageNum");

         XmlRpcFileManagerClient client = getClient();

         ProductType type = client.getProductTypeByName(productTypeName);
         if (type == null) {
            throw new Exception("FileManager returned null ProductType");
         }
         ProductPage firstPage = client.getFirstPage(type);
         if (firstPage == null) {
            throw new Exception("FileManager returned null first ProductPage");
         }
         ProductPage currentPage = new ProductPage();
         currentPage.setPageNum(currentPageNum);
         currentPage.setPageSize(firstPage.getPageSize());
         currentPage.setTotalPages(firstPage.getTotalPages());
         ProductPage nextPage = client.getNextPage(type, currentPage);
         if (nextPage == null) {
            throw new Exception("FileManager returned null next ProductPage");
         }
         printer.println("Page: [num=" + nextPage.getPageNum()
               + ", totalPages=" + nextPage.getTotalPages() + ", pageSize="
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.filemgr.system.XmlRpcFileManagerClient

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.