1 package org.jboss.test.bpel.ws.consumption.partner; 2 3 import java.rmi.Remote ; 4 import java.rmi.RemoteException ; 5 import java.util.HashMap ; 6 import java.util.Locale ; 7 import java.util.Map ; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 import org.jboss.test.bpel.ws.consumption.partner.spi.Dictionary; 13 import org.jboss.test.bpel.ws.consumption.partner.spi.DictionaryFactory; 14 import org.jboss.test.bpel.ws.consumption.partner.types.TDictionaryNotAvailable; 15 import org.jboss.test.bpel.ws.consumption.partner.types.TDocument; 16 import org.jboss.test.bpel.ws.consumption.partner.types.TQuotationRequest; 17 import org.jboss.test.bpel.ws.consumption.partner.types.TQuoteStatus; 18 import org.jboss.test.bpel.ws.consumption.partner.types.TStatusRequest; 19 import org.jboss.test.bpel.ws.consumption.partner.types.TStatusResponse; 20 import org.jboss.test.bpel.ws.consumption.partner.types.TTextNotTranslatable; 21 import org.jboss.test.bpel.ws.consumption.partner.types.TTranslationRequest; 22 23 27 public class DocumentTranslator_Impl implements DocumentTranslator, Remote { 28 29 private static Map quotationRequests = new HashMap (); 30 31 private static final Log log = LogFactory.getLog(DocumentTranslator_Impl.class); 32 33 public TDocument translate(TTranslationRequest translationRequest) 34 throws TDictionaryNotAvailable, TTextNotTranslatable, RemoteException { 35 TDocument document = translationRequest.getDocument(); 36 Locale sourceLocale = new Locale (document.getHead().getLanguage()); 37 Locale targetLocale = new Locale (translationRequest.getTargetLanguage()); 38 DictionaryFactory dictionaryFactory = DictionaryFactory.getInstance(sourceLocale, targetLocale); 39 Dictionary dictionary = dictionaryFactory.createDictionary(sourceLocale, targetLocale); 40 return dictionary.translate(document); 41 } 42 43 public void quoteTranslation(TQuotationRequest quotationRequest) throws RemoteException { 44 String clientName = quotationRequest.getClientName(); 45 log.debug("received quotation request: clientName=" + clientName); 46 quotationRequests.put(clientName, quotationRequest); 47 } 48 49 public TStatusResponse getQuotationStatus(TStatusRequest statusRequest) 50 throws RemoteException { 51 TStatusResponse statusResponse = new TStatusResponse(); 52 TQuoteStatus quoteStatus = quotationRequests.containsKey(statusRequest.getClientName()) ? 53 TQuoteStatus.received : TQuoteStatus.none; 54 statusResponse.setStatus(quoteStatus); 55 return statusResponse; 56 } 57 } 58 | Popular Tags |