1 17 package org.alfresco.repo.webservice.axis; 18 19 import org.alfresco.repo.webservice.Utils; 20 import org.alfresco.repo.webservice.types.QueryConfiguration; 21 import org.apache.axis.AxisFault; 22 import org.apache.axis.MessageContext; 23 import org.apache.axis.description.OperationDesc; 24 import org.apache.axis.handlers.BasicHandler; 25 import org.apache.axis.message.SOAPEnvelope; 26 import org.apache.axis.message.SOAPHeaderElement; 27 import org.apache.commons.logging.Log; 28 import org.apache.commons.logging.LogFactory; 29 30 37 public class QueryConfigHandler extends BasicHandler 38 { 39 public static final String ALF_FETCH_SIZE = "ALF_FETCH_SIZE"; 40 41 private static final long serialVersionUID = 6467938074555362971L; 42 private static Log logger = LogFactory.getLog(QueryConfigHandler.class); 43 44 47 public void invoke(MessageContext msgContext) throws AxisFault 48 { 49 try 50 { 51 String opName = "Unknown method"; 53 OperationDesc op = msgContext.getOperation(); 54 if (op != null) 55 { 56 opName = op.getName(); 57 } 58 59 SOAPEnvelope env = msgContext.getRequestMessage().getSOAPEnvelope(); 61 SOAPHeaderElement header = env.getHeaderByName(Utils.REPOSITORY_SERVICE_NAMESPACE, "QueryHeader"); 62 if (header != null) 63 { 64 if (logger.isDebugEnabled()) 65 logger.debug("Found QueryHeader for call to " + opName); 66 67 QueryConfiguration queryCfg = (QueryConfiguration)header.getObjectValue(QueryConfiguration.class); 68 if (queryCfg != null) 69 { 70 int fetchSize = queryCfg.getFetchSize(); 71 72 if (logger.isDebugEnabled()) 73 logger.debug("Fetch size for query = " + fetchSize); 74 75 msgContext.setProperty(ALF_FETCH_SIZE, new Integer (fetchSize)); 76 } 77 else 78 { 79 if (logger.isDebugEnabled()) 80 logger.debug("Failed to find QueryConfiguration within QueryHeader"); 81 } 82 } 83 else 84 { 85 if (logger.isDebugEnabled()) 86 { 87 logger.debug("QueryHeader was not found for call to " + opName); 88 } 89 } 90 } 91 catch (Throwable e) 92 { 93 if (logger.isDebugEnabled()) 94 logger.debug("Failed to determine fetch size", e); 95 } 96 } 97 } 98 | Popular Tags |