Package org.openeai.uportal.handlers

Source Code of org.openeai.uportal.handlers.GeneralUpdateHandler

package org.openeai.uportal.handlers;

import org.openeai.moa.jmsobjects.JmsEnterpriseObject;
import org.openeai.jms.producer.PointToPointProducer;
import org.any_openeai_enterprise.moa.objects.resources.v1_0.LightweightPerson;
import org.jasig.portal.services.LogService;

public class GeneralUpdateHandler extends UportalFormHandlerBase implements UportalFormHandler {
  public GeneralUpdateHandler() {
  }
  public String process() throws UportalFormHandlerException {
    String messageObjectName = getProperties().getProperty(MESSAGE_OBJECT_NAME_PROP);
    String producerName = getProperties().getProperty(PRODUCER_NAME_PROP);
    String xml = INITIAL_XML;
    try {
      // get the baseline (current value of 'xml' variable)
      JmsEnterpriseObject baselineJeo = (JmsEnterpriseObject)getAppConfig().getObject(messageObjectName);
      baselineJeo.getXmlEnterpriseObject().getEnterpriseFields().setIgnoreValidation(true);
      baselineJeo.getXmlEnterpriseObject().buildObjectFromXmlString(getBaselineXml());

      // where to get the newdata (the form data)?
      JmsEnterpriseObject newJeo = (JmsEnterpriseObject)getAppConfig().getObject(messageObjectName);

      // use the UPortalFormDataLayout manager to build the new version of the object.
      newJeo.getXmlEnterpriseObject().getEnterpriseFields().setIgnoreValidation(true);
      newJeo.getXmlEnterpriseObject().buildObjectFromInput(getChannelRuntimeData());
       
      newJeo.getXmlEnterpriseObject().setBaseline(baselineJeo.getXmlEnterpriseObject());
     
      LogService.log(LogService.INFO, "[GeneralUpdateHandler] built " + messageObjectName + " from form data, performing Update...");

      // todo - use producer pool
      // todo - map producer name based on message object since different message
      // objects may be going against different sources.
      newJeo.update((PointToPointProducer)getAppConfig().getObject(producerName));
      LogService.log(LogService.INFO, "[GeneralUpdateHandler] " + messageObjectName + " update is done.");

      xml = INITIAL_XML;
      xml += newJeo.getXmlEnterpriseObject().toXmlString();
    }
    catch (Exception openeaiExc) {
      LogService.log(LogService.ERROR, openeaiExc);
      openeaiExc.printStackTrace();
      throw new UportalFormHandlerException("[GeneralUpdateHandler] Error performing update action", openeaiExc);
    }
    return xml;
  }
}
TOP

Related Classes of org.openeai.uportal.handlers.GeneralUpdateHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.