Changeset 1277:461b8da4b5fc

Show
Ignore:
Timestamp:
06/18/10 21:15:41 (3 years ago)
Author:
Thomas Gambet <tgambet@…>
Branch:
default
Message:

implemented error messages observer_not_found and observer_internal_error

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/org/w3c/unicorn/request/UploadRequest.java

    r1126 r1277  
    44package org.w3c.unicorn.request; 
    55 
     6import java.io.FileNotFoundException; 
    67import java.io.IOException; 
     8import java.io.InputStream; 
    79import java.net.MalformedURLException; 
    810import java.util.Hashtable; 
    911import java.util.Map; 
    1012 
     13import org.w3c.unicorn.Framework; 
    1114import org.w3c.unicorn.contract.EnumInputMethod; 
    1215import org.w3c.unicorn.input.UploadInputModule; 
     
    9295        public Response doRequest() throws UnicornException { 
    9396                logger.trace("doRequest"); 
     97                String observerName = Framework.mapOfObserver.get(observerId).getName(sLang.split(",")[0]); 
    9498                try { 
    9599                        aClientHttpRequest = new ClientHttpRequest(sURL); 
     
    108112                        } 
    109113                         
    110                         // TODO How to find the response content encoding here ? 
    111                         return ResponseFactory.getResponse(aClientHttpRequest.post(), responseType, sURL.toString(), null, observerId); 
     114                        InputStream stream = null; 
     115                        try { 
     116                                stream = aClientHttpRequest.post(); 
     117                                // TODO How to find the response content encoding here ? 
     118                                return ResponseFactory.getResponse(stream, responseType, sURL.toString(), null, observerId); 
     119                        } catch (FileNotFoundException e) { 
     120                                throw new UnicornException(Message.ERROR, "$message_observer_not_found", null, observerName); 
     121                        } catch (IOException e) { 
     122                                if (e.getMessage().contains("Server returned HTTP response code: 500")) 
     123                                        throw new UnicornException(Message.ERROR, "$message_observer_internal_error", null, observerName); 
     124                                else 
     125                                        throw e; 
     126                        }                        
    112127 
    113128                } catch (MalformedURLException e) {