throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated);
/** * Handles a redirect exception by generating the new URL to use for the * redirect. */ protected URL handleRedirectException(RedirectRequiredException redirect) throws ServiceException { try { return new URL(redirect.getRedirectLocation()); } catch (MalformedURLException e) { ServiceException se = new ServiceException( CoreErrorDomain.ERR.invalidRedirectedToUrl); se.setInternalReason("Invalid redirected-to URL - " + redirect.getRedirectLocation()); throw se; } }
/** * Handles a redirect exception by generating the new URL to use for the * redirect. */ protected URL handleRedirectException(RedirectRequiredException redirect) throws ServiceException { try { return new URL(redirect.getRedirectLocation()); } catch (MalformedURLException e) { ServiceException se = new ServiceException( CoreErrorDomain.ERR.invalidRedirectedToUrl); se.setInternalReason("Invalid redirected-to URL - " + redirect.getRedirectLocation()); throw se; } }
/** * Handles a redirect exception by generating the new URL to use for the * redirect. */ protected URL handleRedirectException(RedirectRequiredException redirect) throws ServiceException { try { return new URL(redirect.getRedirectLocation()); } catch (MalformedURLException e) { ServiceException se = new ServiceException( CoreErrorDomain.ERR.invalidRedirectedToUrl); se.setInternalReason("Invalid redirected-to URL - " + redirect.getRedirectLocation()); throw se; } }
/** * Updates this entry by sending the current representation to the associated * GData service. * * @return the updated entry returned by the Service. * * @throws ServiceException If there is no associated GData service or the * service is unable to perform the update. * * @throws UnsupportedOperationException If update is not supported for the * target entry. * * @throws IOException If there is an error communicating with the GData * service. */ public Entry update() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException(CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be updated"); } URL editUrl = editLink.getHrefUri().toURL(); return state.service.update(editUrl, this); }
/** * Updates this entry by sending the current representation to the associated * GData service. * * @return the updated entry returned by the Service. * * @throws ServiceException If there is no associated GData service or the * service is unable to perform the update. * * @throws UnsupportedOperationException If update is not supported for the * target entry. * * @throws IOException If there is an error communicating with the GData * service. */ public Entry update() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException(CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be updated"); } URL editUrl = editLink.getHrefUri().toURL(); return state.service.update(editUrl, this); }
/** * Inserts a new Entry into the feed, if the feed is currently associated with * a Service. * * @return the inserted Entry returned by the Service. * * @throws ServiceException If there is no associated GData service or the * service is unable to perform the insertion. * * @throws UnsupportedOperationException If insert is not supported for the * target feed. * * @throws IOException If there is an error communicating with the GData * service. */ public <T extends Entry> T insert(T newEntry) throws ServiceException, IOException { if (feedState.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link postLink = getEntryPostLink(); if (postLink == null) { throw new UnsupportedOperationException("Media cannot be inserted"); } URL postUrl = postLink.getHrefUri().toURL(); return feedState.service.insert(postUrl, newEntry); }
/** * Updates this entry by sending the current representation to the * associated GData service. * * @return the updated entry returned by the Service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the update. * * @throws UnsupportedOperationException * If update is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public E update() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be updated"); } URL editUrl = new URL(editLink.getHref()); return (E) state.service.update(editUrl, this); }
/** * Inserts a new Entry into the feed, if the feed is currently associated with * a Service. * * @return the inserted Entry returned by the Service. * * @throws ServiceException If there is no associated GData service or the * service is unable to perform the insertion. * * @throws UnsupportedOperationException If insert is not supported for the * target feed. * * @throws IOException If there is an error communicating with the GData * service. */ public <T extends Entry> T insert(T newEntry) throws ServiceException, IOException { if (feedState.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link postLink = getEntryPostLink(); if (postLink == null) { throw new UnsupportedOperationException("Media cannot be inserted"); } URL postUrl = postLink.getHrefUri().toURL(); return feedState.service.insert(postUrl, newEntry); }
/** * Updates this entry by sending the current representation to the * associated GData service. * * @return the updated entry returned by the Service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the update. * * @throws UnsupportedOperationException * If update is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public E update() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be updated"); } URL editUrl = new URL(editLink.getHref()); return (E) state.service.update(editUrl, this); }
/** * Retrieves the current version of this Entry by requesting it from * the associated GData service. * * @return the current version of the entry. */ public E getSelf() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link selfLink = getSelfLink(); if (selfLink == null) { throw new UnsupportedOperationException("Entry cannot be retrieved"); } URL entryUrl = new URL(selfLink.getHref()); try { // If an etag is available, use it to conditionalize the retrieval, // otherwise, use time of last edit or update. if (state.etag != null) { return (E) state.service.getEntry(entryUrl, this.getClass(), state.etag); } else { return (E) state.service.getEntry(entryUrl, this.getClass(), (state.edited != null ? state.edited : state.updated)); } } catch (NotModifiedException e) { return (E) this; } }
/** * Updates this entry by sending the current representation to the * associated GData service. * * @return the updated entry returned by the Service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the update. * * @throws UnsupportedOperationException * If update is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public E update() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be updated"); } URL editUrl = new URL(editLink.getHref()); return (E) state.service.update(editUrl, this); }
/** * Inserts a new Entry into the feed, if the feed is currently * associated with a Service. * * @return the inserted Entry returned by the Service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the insertion. * * @throws UnsupportedOperationException * If insert is not supported for the target feed. * * @throws IOException * If there is an error communicating with the GData service. */ public <T extends E> T insert(T newEntry) throws ServiceException, IOException { if (feedState.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link postLink = getEntryPostLink(); if (postLink == null) { throw new UnsupportedOperationException("Media cannot be inserted"); } URL postUrl = new URL(postLink.getHref()); return feedState.service.insert(postUrl, newEntry); }
/** * Deletes this entry by sending a request to the associated GData * service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the deletion. * * @throws UnsupportedOperationException * If deletion is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public void delete() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be deleted"); } // Delete the entry, using strong etag (if available) as a precondition. URL editUrl = new URL(editLink.getHref()); state.service.delete(editUrl, GDataProtocol.isWeakEtag(state.etag) ? null : state.etag); }
/** * Deletes this entry by sending a request to the associated GData * service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the deletion. * * @throws UnsupportedOperationException * If deletion is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public void delete() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be deleted"); } // Delete the entry, using strong etag (if available) as a precondition. URL editUrl = new URL(editLink.getHref()); state.service.delete(editUrl, GDataProtocol.isWeakEtag(state.etag) ? null : state.etag); }
/** * Deletes this entry by sending a request to the associated GData * service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the deletion. * * @throws UnsupportedOperationException * If deletion is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public void delete() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be deleted"); } // Delete the entry, using strong etag (if available) as a precondition. URL editUrl = new URL(editLink.getHref()); state.service.delete(editUrl, GDataProtocol.isWeakEtag(state.etag) ? null : state.etag); }
/** * Returns the current representation of the feed by requesting it from the * associated service using the feed's self link. * * @return the current state of the feed. */ public Feed getSelf() throws IOException, ServiceException { if (feedState.service == null) { throw new ServiceException( CoreErrorDomain.ERR.feedNotAssociated); } Link selfLink = getSelfLink(); if (selfLink == null) { throw new UnsupportedOperationException("Feed cannot be retrieved"); } URL feedUrl = selfLink.getHrefUri().toURL(); try { // Use Etag if available to conditionalize the retrieval, otherwise use // the updated value. String etag = getEtag(); if (etag != null) { return feedState.service.getFeed(feedUrl, this.getClass(), etag); } else { return feedState.service.getFeed( feedUrl, this.getClass(), getUpdated()); } } catch (NotModifiedException e) { return this; } }
/** * Deletes this entry by sending a request to the associated GData service. * * @throws ServiceException If there is no associated GData service or the * service is unable to perform the deletion. * * @throws UnsupportedOperationException If deletion is not supported for the * target entry. * * @throws IOException If there is an error communicating with the GData * service. */ public void delete() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException(CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be deleted"); } // Delete the entry, using strong etag (if available) as a precondition. URI editUrl = editLink.getHrefUri(); String etag = getEtag(); state.service.delete(editUrl, GDataProtocol.isWeakEtag(etag) ? null : etag); }
/** * Deletes this entry by sending a request to the associated GData service. * * @throws ServiceException If there is no associated GData service or the * service is unable to perform the deletion. * * @throws UnsupportedOperationException If deletion is not supported for the * target entry. * * @throws IOException If there is an error communicating with the GData * service. */ public void delete() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException(CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be deleted"); } // Delete the entry, using strong etag (if available) as a precondition. URI editUrl = editLink.getHrefUri(); String etag = getEtag(); state.service.delete(editUrl, GDataProtocol.isWeakEtag(etag) ? null : etag); }
/** * Deletes this entry by sending a request to the associated GData * service. * * @throws ServiceException * If there is no associated GData service or the service is * unable to perform the deletion. * * @throws UnsupportedOperationException * If deletion is not supported for the target entry. * * @throws IOException * If there is an error communicating with the GData service. */ public void delete() throws IOException, ServiceException { if (state.service == null) { throw new ServiceException( CoreErrorDomain.ERR.entryNotAssociated); } Link editLink = getEditLink(); if (editLink == null) { throw new UnsupportedOperationException("Entry cannot be deleted"); } // Delete the entry, using strong etag (if available) as a precondition. URI editUrl = editLink.getHrefUri(); String etag = getEtag(); state.service.delete(editUrl, GDataProtocol.isWeakEtag(etag) ? null : etag); }