Package com.emc.esu.api

Examples of com.emc.esu.api.EsuException


        String code = d.getRootElement().getChildText("Code");
        String message = d.getRootElement().getChildText("Message");

        if (code == null && message == null) {
            // not an error from ESU
            throw new EsuException(msg, httpCode);
        }

        l4j.debug("Error: " + code + " message: " + message);
        throw new EsuException(message, httpCode, Integer.parseInt(code));
  }
View Full Code Here


        handleError(con);
      }

      return new ListHostsResponse(con);
    } catch (IOException e) {
      throw new EsuException("Error connecting to server: " + e.getMessage(), e);
    } catch (URISyntaxException e) {
      throw new EsuException("Error building URI: " + e.getMessage(), e);
    } catch (JDOMException e) {
      throw new EsuException("Error parsing XML response", e);
    }
  }
View Full Code Here

      }
     
      return new ListRmgResponse(con);
     
    } catch (IOException e) {
      throw new EsuException("Error connecting to server: " + e.getMessage(), e);
    } catch (URISyntaxException e) {
      throw new EsuException("Error building URI: " + e.getMessage(), e);
    } catch (JDOMException e) {
      throw new EsuException("Error parsing XML response", e);
    }

  }
View Full Code Here

    public void readObject( Identifier id, File f) {
        OutputStream out;
        try {
            out = new FileOutputStream(f);
        } catch (FileNotFoundException e) {
            throw new EsuException("Error opening output file", e);
        }
        readObject(id, out, true);
    }
View Full Code Here

        }

        // We need to know how big the object is to download it.  Fail the
        // transfer if we can't determine the object size.
        if (this.totalBytes == -1) {
            throw new EsuException("Failed to get object size");
        }
       
        if( checksumming ) {
          try {
        checksum = new Checksum( Algorithm.SHA0 );
      } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException( "Could not initialize SHA0 hash algorithm" );
      }
        }

        // Loop, downloading chunks until the transfer is complete.
        while (true) {
            try {
                Extent extent = null;

                // Determine how much data to download.  If we're at the last
                // request in the transfer, only request as many bytes as needed
                // to get to the end of the file.
                if (currentBytes + buffer.getBuffer().length > totalBytes) {
                    // Would go past end of file.  Request less bytes.                                     
                    extent = new Extent(this.currentBytes, totalBytes
                            - currentBytes);
                } else {
                    extent = new Extent(this.currentBytes,
                            buffer.getBuffer().length);
                }
                buffer.setSize((int) extent.getSize());

                // Read data from the server.
                byte[] obuffer = this.esu.readObject(id, extent, buffer.getBuffer(), checksum);

                // See if they returned the buffer we're using.  In some
                // cases, this doesn't happen (when content length is not
                // defined in the response).
                if( obuffer != buffer.getBuffer() ) {
                    if( obuffer.length != extent.getSize() ) {
                        throw new EsuException( "Read size mismatch.  " +
                            "Requested " + extent.getSize() +
                            " bytes but received " +
                            obuffer.length + " bytes" );
                    }
                    stream.write( obuffer, 0, obuffer.length );
                } else {
                    // Write to the stream
                    stream.write(buffer.getBuffer(), buffer.getOffset(), buffer
                            .getSize());
                }

                // Update progress
                this.progress(buffer.getSize());

                // See if we're done.
                if (this.currentBytes == this.totalBytes) {
                  if( checksumming && checksum.getExpectedValue() != null ) {
                    // Validate
                     
                      if( !checksum.getExpectedValue().equals( checksum.toString() ) ) {
                        throw new EsuException("Checksum validation error.  Expected " + checksum.getExpectedValue() + " but computed " + checksum.toString() );
                      } else {
                        l4j.info( "Checksum OK: " + checksum.getExpectedValue() );
                      }

                  }
                    this.complete();
                    return;
                }
            } catch (EsuException e) {
                this.fail(e);
                throw e;
            } catch (IOException e) {
                fail(e);
                throw new EsuException("Error downloading file", e);
            }
        }
    }
View Full Code Here

    hosts = new ArrayList<ListHostsResponse.Host>();
   
    List<?> hostsXml = root.getChildren("node");
    for(Object o : hostsXml) {
      if(!(o instanceof Element)) {
        throw new EsuException("Expected XML Element got " + o.getClass());
      }
     
      Element e = (Element)o;
     
      Host h = new Host();
View Full Code Here

      return;
    }
   
    for(Object o : rmgsXml) {
      if(!(o instanceof Element)) {
        throw new EsuException("Expected XML Element got " + o.getClass());
      }
     
      Element e = (Element)o;
     
      Rmg r = new Rmg();
View Full Code Here

        // Open the file and call the streaming version
        try {
            totalBytes = f.length();
            fis = new FileInputStream(f);
        } catch (FileNotFoundException e) {
            throw new EsuException("Could not open input file", e);
        }
        return createObject(fis, acl, meta, true);
    }
View Full Code Here

        } catch (EsuException e) {
            this.fail(e);
            throw e;
        } catch (IOException e) {
            this.fail(e);
            throw new EsuException("Error uploading object", e);
        }

        return id;
    }
View Full Code Here

        // Open the file and call the streaming version
        try {
            totalBytes = f.length();
            fis = new FileInputStream(f);
        } catch (FileNotFoundException e) {
            throw new EsuException("Could not open input file", e);
        }
        return createObjectOnPath( path, fis, acl, meta, true);
     
    }
View Full Code Here

TOP

Related Classes of com.emc.esu.api.EsuException

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.