Why is this happening; Tasks are so weird.

http://www.nabble.com/file/p22717175/log.txt log.txt 

org.apache.synapse.SynapseException: Error occured in the mediation of the
class mediator.

Log is attached. The class works perfectly when called in other scripts.


Script is:
----------
<definitions xmlns="http://ws.apache.org/ns/synapse";>
  <task class="org.apache.synapse.startup.tasks.MessageInjector"
name="GetGuid">
    <property name="to" value="urn:doQuery"/>
    <property name="message">
      <doNothing/>
    </property>
    <trigger interval="30"/>
  </task>
  <in>
    <log level="full"/>
    <filter source="get-property('To')" regex="urn:doQuery">
      <then sequence="processStuff"/>
    </filter>
  </in>
  <out>
    <send/>
  </out>
  <sequence name="processStuff">
    <log level="custom">
      <property name="MSG" value="&gt;&gt;&gt;&gt;&gt;&gt;&gt; Submit
STUFF"/>
    </log>
    <property name="Username" value="username"/>
    <property name="Password" value="password"/>
    <class name="net.icsglobal.thelma.synapse.CreateBasicAuthMediator"/>
  </sequence>
</definitions>

CLASS is
---------
public class CreateBasicAuthMediator implements Mediator {
        private static final Log log =
LogFactory.getLog(CreateBasicAuthMediator.class);
        private String reqUsername = null;
        private String reqPassword = null;

        public int getTraceState() {
                return 0;
        }

        public void setTraceState(int traceState) {
                traceState = 0;
        }

        public String getType() {
                return this.getClass().getName();
        }

        public boolean mediate(MessageContext synCtx) {
                
                log.debug("CreateBasicAuthMediator: Create Auth Header 
Started...");
                
                reqUsername = (String) synCtx.getProperty("Username");
                reqPassword = (String) synCtx.getProperty("Password");

                if (reqUsername == null) {
                        log.debug("CreateBasicAuthMediator: ERROR: No 
UserName...");
                        throw new SynapseException("Username property MUST be 
provided!");
                }
                
                if (reqPassword == null) {
                        log.debug("CreateBasicAuthMediator: ERROR: No 
Password...");
                        throw new SynapseException("Password property MUST be 
provided!");
                }
                
                log.debug("CreateBasicAuthMediator: Creating Auth String...");
                
                String sAuth = reqUsername + ":" + reqPassword;
                
                log.debug("CreateBasicAuthMediator: Done String...");

                //      Extract authentication headers
                org.apache.axis2.context.MessageContext mc = 
((Axis2MessageContext)
synCtx).getAxis2MessageContext();
                Map map = (Map)
mc.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
                log.debug("CreateBasicAuthMediator: Got Map...");
                
                // Set the authentication headers
                map.put("Authorization", "Basic " + (String)
Base64.encode(sAuth.getBytes()));

                log.debug("CreateBasicAuthMediator: Auth Created succeeded!");

                return true;
        }

}




-- 
View this message in context: 
http://www.nabble.com/Class-Mediator-Exception-after-task-schedule-tp22717175p22717175.html
Sent from the Synapse - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to