Package com.emc.esu.api

Examples of com.emc.esu.api.EsuException


            }

            return new HttpInputStreamWrapper(con.getInputStream(), con);

        } 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);
            }
            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

                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);
            }
            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

            // Read the response to complete the request (will be empty)
            InputStream in = con.getInputStream();
            in.close();
            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

            // Read the response to complete the request (will be empty)
            InputStream in = con.getInputStream();
            in.close();
            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

            // 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

     */
  public List<DirectoryEntry> listDirectory(ObjectPath path,
      ListOptions options ) {
     
        if (!path.isDirectory()) {
            throw new EsuException(
                    "listDirectory must be called with a directory path");
        }
       
        byte[] data = null;

        // Read out the directory's contents
        try {
            String resource = getResourcePath(context, path);
            URL u = buildUrl(resource, null);
            HttpURLConnection con = (HttpURLConnection) u.openConnection();

            // Build headers
            Map<String, String> headers = new HashMap<String, String>();

            headers.put("x-emc-uid", uid);
           
            if(unicodeEnabled) {
                headers.put("x-emc-utf8", "true");
            }

            // Process options
            if( options != null ) {
              if( options.isIncludeMetadata() ) {
                headers.put( "x-emc-include-meta", "1" );
                if( options.getSystemMetadata() != null ) {
                  headers.put( "x-emc-system-tags",
                      join( options.getSystemMetadata(), "," ) );
                }
                if( options.getUserMetadata() != null ) {
                  headers.put( "x-emc-user-tags",
                      join( options.getUserMetadata(), "," ) );                 
                }
              }
              if( options.getLimit() > 0 ) {
                headers.put( "x-emc-limit", ""+options.getLimit() );
              }
              if( options.getToken() != null ) {
                headers.put( "x-emc-token", options.getToken() );
              }
            }

            // Add date
            headers.put("Date", getDateHeader());

            // Sign request
            signRequest("GET", resource, null, headers);
            configureRequest( con, "GET", headers );

            con.connect();

            // Check response
            if (con.getResponseCode() > 299) {
                handleError(con);
            }
           
            if( options != null ) {
              // Update the token for listing more results.  If there are no
              // more results, the header will not be set and the token will
              // be cleared in the options object.
              options.setToken( con.getHeaderField("x-emc-token") );
            } else {
              if( con.getHeaderField( "x-emc-token" ) != null ) {
                l4j.warn( "Result set truncated. Use ListOptions to " +
                    "retrieve token for next page of results." );
              }
            }

            // The requested content is in the response body.
            data = readResponse(con, null);
                      
        } 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);
        }
       
        return parseDirectoryListing( data, path );

    }
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

            con.disconnect();
           
            return parseServiceInformation(response, con.getHeaderFields());

        } 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();

        } 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.