Package com.emc.esu.api

Examples of com.emc.esu.api.EsuException


            if (con.getResponseCode() > 299) {
                handleError(con);
            }
            con.disconnect();
        } catch (MalformedURLException e) {
            throw new EsuException("Invalid URL", e);
        } catch (IOException e) {
            throw new EsuException("Error connecting to server", e);
        } catch (GeneralSecurityException e) {
            throw new EsuException("Error computing request signature", e);
        } catch (URISyntaxException e) {
            throw new EsuException("Invalid URL", e);
        }
     
    }
View Full Code Here


            con.disconnect();
            return new ObjectInfo( responseXml );

        } catch (MalformedURLException e) {
            throw new EsuException("Invalid URL", e);
        } catch (IOException e) {
            throw new EsuException("Error connecting to server", e);
        } catch (GeneralSecurityException e) {
            throw new EsuException("Error computing request signature", e);
        } catch (URISyntaxException e) {
            throw new EsuException("Invalid URL", e);
        }
     
    }
View Full Code Here

            con.connect();

            // Check response
            Date serverDate = new Date(con.getHeaderFieldDate("Date", 0));
          if(serverDate.getTime() == 0) {
            EsuException e = new EsuException(
                "Unable to get date from server request: " +
                    con.getResponseMessage(),
                    con.getResponseCode());
            throw(e);
          }
         
          return System.currentTimeMillis()-serverDate.getTime();
        } catch (MalformedURLException e) {
            throw new EsuException("Invalid URL", e);
        } catch (IOException e) {
            throw new EsuException("Error connecting to server", e);
        } catch (URISyntaxException e) {
            throw new EsuException("Invalid URL", e);
        }
  }
View Full Code Here

            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(con.getResponseMessage(), http_code);
            }

            l4j.debug("Error: " + code + " message: " + message);
            throw new EsuException(message, http_code, Integer.parseInt(code));

        } catch (IOException e) {
            l4j.debug("Could not read error response body", e);
            // Just throw what we know from the response
            try {
                throw new EsuException(con.getResponseMessage(), http_code);
            } catch (IOException e1) {
                l4j.warn("Could not get response code/message!", e);
                throw new EsuException("Could not get response code", e,
                        http_code);
            }
        } catch (JDOMException e) {
            try {
                l4j.debug("Could not parse response body for " + http_code
                        + ": " + con.getResponseMessage(), e);
                throw new EsuException("Could not parse response body for "
                        + http_code + ": " + con.getResponseMessage(), e,
                        http_code);
            } catch (IOException e1) {
                throw new EsuException("Could not parse response body", e1,
                        http_code);
            }

        }
View Full Code Here

            byte[] output;
            int contentLength = con.getContentLength();
            // If we know the content length, read it directly into a buffer.
            if (contentLength != -1) {
                if (buffer != null && buffer.length < con.getContentLength()) {
                    throw new EsuException(
                            "The response buffer was not long enough to hold the response: "
                                    + buffer.length + "<"
                                    + con.getContentLength());
                }
                if (buffer != null) {
View Full Code Here

            }

            con.disconnect();

        } catch ( MalformedURLException e ) {
            throw new EsuException( "Invalid URL", e );
        } catch ( IOException e ) {
            throw new EsuException( "Error connecting to server", e );
        } catch ( GeneralSecurityException e ) {
            throw new EsuException( "Error computing request signature", e );
        } catch ( URISyntaxException e ) {
            throw new EsuException( "Invalid URL", e );
        }

    }
View Full Code Here

                out.write( data.getBuffer(), data.getOffset(), data.getSize() );
                out.close();
            } catch ( IOException e ) {
                silentClose( out );
                con.disconnect();
                throw new EsuException( "Error posting data", e );
            }

            // Check response
            if ( con.getResponseCode() > 299 ) {
                handleError( con );
            }

            // The new object ID is returned in the location response header
            String location = con.getHeaderField( "location" );
            con.disconnect();

            // Parse the value out of the URL
            return getObjectId( location );
        } catch ( MalformedURLException e ) {
            throw new EsuException( "Invalid URL", e );
        } catch ( IOException e ) {
            throw new EsuException( "Error connecting to server", e );
        } catch ( GeneralSecurityException e ) {
            throw new EsuException( "Error computing request signature", e );
        } catch ( URISyntaxException e ) {
            throw new EsuException( "Invalid URL", e );
        }
    }
View Full Code Here

                while ( read < length ) {
                    // make sure we don't write past the content-length
                    int maxRead = (int) Math.min( (long) buffer.length, length - read );
                    int c = data.read( buffer, 0, maxRead );
                    if ( c == -1 ) {
                        throw new EsuException(
                                "EOF encountered reading data stream" );
                    }
                    out.write( buffer, 0, c );
                    read += c;
                }
                out.close();
            } catch ( IOException e ) {
                silentClose( out );
                con.disconnect();
                throw new EsuException( "Error posting data", e );
            }

            // Check response
            if ( con.getResponseCode() > 299 ) {
                handleError( con );
            }

            // The new object ID is returned in the location response header
            String location = con.getHeaderField( "location" );
            con.disconnect();

            // Parse the value out of the URL
            return getObjectId( location );
        } catch ( MalformedURLException e ) {
            throw new EsuException( "Invalid URL", e );
        } catch ( IOException e ) {
            throw new EsuException( "Error connecting to server", e );
        } catch ( GeneralSecurityException e ) {
            throw new EsuException( "Error computing request signature", e );
        } catch ( URISyntaxException e ) {
            throw new EsuException( "Invalid URL", e );
        }
    }
View Full Code Here

                handleError( con );
            }
            con.disconnect();

        } catch ( MalformedURLException e ) {
            throw new EsuException( "Invalid URL", e );
        } catch ( IOException e ) {
            throw new EsuException( "Error connecting to server", e );
        } catch ( GeneralSecurityException e ) {
            throw new EsuException( "Error computing request signature", e );
        } catch ( URISyntaxException e ) {
            throw new EsuException( "Invalid URL", e );
        }
    }
View Full Code Here

            om.setMimeType( con.getContentType() );

            return om;

        } catch ( MalformedURLException e ) {
            throw new EsuException( "Invalid URL", e );
        } catch ( IOException e ) {
            throw new EsuException( "Error connecting to server", e );
        } catch ( GeneralSecurityException e ) {
            throw new EsuException( "Error computing request signature", e );
        } catch ( URISyntaxException e ) {
            throw new EsuException( "Invalid URL", e );
        }
    }
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.