@ Override public void update ( ) throws ProponoException { if ( partial ) { throw new ProponoException ( "ERROR: attempt to update partial entry" ) ; } EntityEnclosingMethod method = null ; final Content updateContent = getContents ( ) . get ( 0 ) ; try { if ( getMediaLinkURI ( ) != null && getBytes ( ) != null ) { // existing media entry and new file, so PUT file to edit-media URI method = new PutMethod ( getMediaLinkURI ( ) ) ; if ( inputStream != null ) { method . setRequestEntity ( new InputStreamRequestEntity ( inputStream ) ) ; } else { method . setRequestEntity ( new InputStreamRequestEntity ( new ByteArrayInputStream ( getBytes ( ) ) ) ) ; } method . setRequestHeader ( "Content-type" , updateContent . getType ( ) ) ; } else if ( getEditURI ( ) != null ) { // existing media entry and NO new file, so PUT entry to edit URI method = new PutMethod ( getEditURI ( ) ) ; final StringWriter sw = new StringWriter ( ) ; Atom10Generator . serializeEntry ( this , sw ) ; method . setRequestEntity ( new StringRequestEntity ( sw . toString ( ) , null , null ) ) ; method . setRequestHeader ( "Content-type" , "application/atom+xml; charset=utf8" ) ; } else { throw new ProponoException ( "ERROR: media entry has no edit URI or media-link URI" ) ; } getCollection ( ) . addAuthentication ( method ) ; method . addRequestHeader ( "Title" , getTitle ( ) ) ; getCollection ( ) . getHttpClient ( ) . executeMethod ( method ) ; if ( inputStream != null ) { inputStream . close ( ) ; } final InputStream is = method . getResponseBodyAsStream ( ) ; if ( method . getStatusCode ( ) != 200 && method . getStatusCode ( ) != 201 ) { throw new ProponoException ( "ERROR HTTP status=" + method . getStatusCode ( ) + " : " + Utilities . streamToString ( is ) ) ; } } catch ( final Exception e ) { throw new ProponoException ( "ERROR: saving media entry" ) ; } if ( method . getStatusCode ( ) != 201 ) { throw new ProponoException ( "ERROR HTTP status=" + method . getStatusCode ( ) ) ; } }
Update entry on server .