Package com.emc.esu.api

Examples of com.emc.esu.api.EsuException


        } 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
        InputStream in;
        try {
            in = new FileInputStream(f);
        } catch (FileNotFoundException e) {
            throw new EsuException("Could not open input file", e);
        }
        totalBytes = f.length();
        updateObject(id, in, acl, metadata, true);
    }
View Full Code Here

    rmgs = new ArrayList<ListRmgResponse.Rmg>();
   
    List<?> rmgsXml = root.getChildren("rmg");
    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

          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

                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

                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

                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

                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

                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

     * @param id the identifier of the object whose metadata to delete.
     * @param tags the list of metadata tags to delete.
     */
    public void deleteUserMetadata(Identifier id, MetadataTags tags) {
        if (tags == null) {
            throw new EsuException("Must specify tags to delete");
        }
        try {
            String resource = getResourcePath(context, id);
            String query = "metadata/user";
            URL u = buildUrl(resource, query);
            HttpURLConnection con = (HttpURLConnection) u.openConnection();

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

            headers.put("x-emc-uid", uid);

            // process tags
            if (tags != null) {
                processTags(tags, headers);
            }

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

            // Sign request
            signRequest("DELETE", resource, query, headers);
            configureRequest( con, "DELETE", headers );

            con.connect();

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

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.