Package nexj.core.rpc

Examples of nexj.core.rpc.TransferObject$Iterator


         }

         m_instanceMap = new HashTab();
         m_processedSet = new HashTab2D();

         TransferObject tobj = (TransferObject)transfer(in.getObject(), message.getRoot());

         GenericServer.auditResponse(m_instanceMap, m_context);

         if (s_logger.isDumpEnabled())
         {
View Full Code Here


      try
      {
         m_instanceMap = new HashTab();
         m_processedSet = new HashTab2D();
        
         TransferObject tobj = (TransferObject)transfer(in.getObject(), message.getRoot());

         GenericServer.auditResponse(m_instanceMap, m_context);

         if (s_logger.isDumpEnabled())
         {
View Full Code Here

   {
      MessagePart processedPart = msg;
      String sMessageName = null;
      Metaclass metaclass;
      Instance instance = (obj instanceof Instance) ? (Instance)obj : null;
      TransferObject srcTobj = (obj instanceof TransferObject) ? (TransferObject)obj : null;
      Message message = null;

      if (instance != null || srcTobj != null)
      {
         if (msg instanceof CompositeMessagePartRef)
         {
            CompositeMessagePartRef ref = (CompositeMessagePartRef)msg;
            CompositeMessagePart referencedPart = ref.getRefPart();

            message = ((ObjectMessagePartMapping)referencedPart.getMapping()).getMessage();
         }
         else if (msg.getParent() == null)
         {
            message = ((ObjectMessagePartMapping)msg.getRoot().getMapping()).getMessage();
         }
      }

      // Process inheritance
      if (message != null)
      {
         metaclass = (instance != null) ? instance.getMetaclass() :
            m_context.getMetadata().getMetaclass(srcTobj.getClassName());

         Message derivedMessage = findDerivedMessage(message, metaclass);

         if (derivedMessage == null)
         {
            throw new IntegrationException("err.integration.object.missingMapping",
               new Object[]{metaclass.getName(), message.getName(), msg.getFullPath()});
         }

         Message.validatePolymorphism(message, derivedMessage, msg);
         msg = derivedMessage.getRoot();
         message = derivedMessage;
         sMessageName = message.getName();
      }

      ObjectMessagePartMapping mapping = (ObjectMessagePartMapping)msg.getMapping();

      if (m_context.isSecure())
      {
         if (mapping.getAttribute() != null)
         {
            mapping.getAttribute().checkReadAccess(m_context.getPrivilegeSet());
         }
         else
         {
            mapping.getMetaclass().checkReadAccess(m_context.getPrivilegeSet());
         }
      }

      if (obj == null)
      {
         if (msg.isRequired())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{msg.getFullPath()});
         }
        
         return null;
      }
     
      if (msg instanceof PrimitiveMessagePart)
      {
         return ((PrimitiveMessagePart)msg).convertValue(obj);
      }

      CompositeMessagePart composite = (CompositeMessagePart)msg;
      int nCount = composite.getPartCount();
     
      if (obj instanceof TransferObject)
      {
         if (isFetchInstance())
         {
            instance = (Instance)RPCUtil.instantiateClean(srcTobj, new HashTab(), m_context);
         }
         else
         {
            TransferObject tobj = new TransferObject(sMessageName, composite.getPartCount());

            tobj.setEventName(srcTobj.getEventName());
            tobj.setOID(srcTobj.getOID());
  
            for (int i = 0; i < nCount; ++i)
            {
               MessagePart part = composite.getPart(i);
               ObjectMessagePartMapping objectMessagePartMapping = (ObjectMessagePartMapping)part.getMapping();
               Attribute attribute = objectMessagePartMapping.getAttribute();
               Object value = null;

               if (attribute != null)
               {
                  value = transfer(srcTobj.findValue(attribute.getName()), part);
               }
               else
               {
                  switch (objectMessagePartMapping.getSystemAttribute())
                  {
                     case ObjectMessagePartMapping.ATTR_OID:
                        value = srcTobj.getOID().toBinary();
                        break;

                     case ObjectMessagePartMapping.ATTR_CLASS:
                        value = srcTobj.getClassName();
                        break;

                     case ObjectMessagePartMapping.ATTR_EVENT:
                        value = srcTobj.getEventName();
                        break;
                  }
               }

               tobj.setValue(part.getName(), value);
            }
  
            return tobj;
         }
      }

      if (m_context.isSecure() && !instance.isReadable())
      {
         return null;
      }

      metaclass = instance.getMetaclass();

      TransferObject tobj = new TransferObject(sMessageName, composite.getPartCount());
     
      if (!mapping.getMetaclass().isUpcast(metaclass))
      {
         throw new IntegrationException("err.integration.object.partClass",
            new Object[]{mapping.getMetaclass().getName(), composite.getFullPath()});
      }

      String sEvent = null;
      boolean bProcessed = m_processedSet.put(instance, processedPart, Boolean.TRUE) != null;
     
      m_instanceMap.put(instance, tobj);
      tobj.setOID(instance.getOID());

      if (srcTobj != null)
      {
         sEvent = srcTobj.getEventName();
      }
      else
      {
         switch (instance.getState())
         {
            case Instance.NEW:
               sEvent = "create";
               break;

            case Instance.DIRTY:
               sEvent = "update";
               break;

            case Instance.DELETED:
               sEvent = "delete";
               break;
         }
      }

      tobj.setEventName(sEvent);

      for (int i = 0; i < nCount; ++i)
      {
         MessagePart part = composite.getPart(i);
         ObjectMessagePartMapping objectMessagePartMapping = (ObjectMessagePartMapping)part.getMapping();
         Attribute attribute = objectMessagePartMapping.getAttribute();
         Object value = null;

         if (attribute != null)
         {
            if (bProcessed && objectMessagePartMapping.isKey() && !(part instanceof PrimitiveMessagePart))
            {
               throw new IntegrationException("err.integration.object.recursive", new Object[]{msg.getName()});
            }
           
            if (!bProcessed || objectMessagePartMapping.isKey())
            {
               value = transfer(instance.getValue(attribute.getOrdinal()), part);
               tobj.setValue(part.getName(), value);
            }
         }
         else
         {
            switch (objectMessagePartMapping.getSystemAttribute())
            {
               case ObjectMessagePartMapping.ATTR_OID:
                   value = (instance.getOID() == null) ? null : instance.getOID().toBinary();
                   break;

               case ObjectMessagePartMapping.ATTR_CLASS:
                  value = instance.getMetaclass().getName();
                  break;

               case ObjectMessagePartMapping.ATTR_EVENT:
                  value = sEvent;
                  break;
            }

            tobj.setValue(part.getName(), value);
         }
      }

      if (!bProcessed)
      {
View Full Code Here

    * @param writer The writer.
    * @param context The context.
    */
   protected void serializeValues(Writer writer, InvocationContext context)
   {
      TransferObject tobj = new TransferObject(m_map.size());
      Lookup identityMap = null;

      for (Lookup.Iterator itr = m_map.valueIterator(); itr.hasNext();)
      {
         Object value = itr.next();
         String sName = (String)itr.getKey();

         if (value instanceof Instance || value instanceof InstanceList)
         {
            if (identityMap == null)
            {
               identityMap = new HashTab();
            }

            value = RPCUtil.transferState(value, null, identityMap,
               (m_nSafeMode == FAIL || m_nSafeMode == RAW) ? RPCUtil.TF_ALL : RPCUtil.TF_ALL | RPCUtil.TF_SERIALIZABLE);
         }

         tobj.setValue(sName, value);
      }

      try
      {
         createMarshaller(context).serialize(tobj, writer);
View Full Code Here

      {
         m_map = null;
      }
      else
      {
         TransferObject tobj;

         try
         {
            Reader reader;

            if (serializedValues instanceof String)
            {
               reader = new StringReader((String)serializedValues);
            }
            else
            {
               reader = new InputStreamReader(((Binary)serializedValues).getInputStream(), "UTF-8");
            }

            tobj = (TransferObject)createUnmarshaller(context).deserialize(reader);
         }
         catch (IOException e)
         {
            throw new UncheckedException("err.rpc.valueDeserialization", e);
         }

         m_map = new PropertyHashTab(tobj.getValueCount());

         InstanceFactory factory = null;

         for (PropertyIterator itr = tobj.getIterator(); itr.hasNext();)
         {
            String sName = (String)itr.next();
            Object value = itr.getValue();

            if ((value instanceof List || value instanceof TransferObject) && m_nSafeMode != RAW)
View Full Code Here

         prepareAudit();
         GenericServer.auditRequest(m_instanceByTobjMap, null, m_context);

         for (int i = 0, n = m_invocationList.size(); i != n; ++i)
         {
            TransferObject nextTobj = (TransferObject)m_invocationList.get(i);
            Instance inst = (Instance)m_instanceByTobjMap.get(nextTobj);
            boolean bInvoke = true;

            if (inst.isEventPending())
            {
               // For a change from an external system, the event could be set to create. Additionally, the internal
               // instance may already exist. In such a case, the instance should simply be updated and not create
               // any duplicates in the internal system.
               bInvoke = (("create".equals(nextTobj.getEventName()) && inst.getState() == Instance.DIRTY) &&
                  "update".equals(inst.getPendingEventName()))
                  ? false
                  : !inst.getPendingEventName().equals(nextTobj.getEventName());

               inst.invokePendingEvent();
            }

            if (bInvoke && nextTobj.getEventName() != null
               // Ignore pending "update" events - they should only run if there has been an actual update.
               && (!nextTobj.getEventName().equals("update") || inst.getState() == Instance.DIRTY)
               // Instance update or insert was rejected (e.g. by sync engine)
               && inst.getState() != Instance.DELETED)
            {
               inst.invoke(nextTobj.getEventName());
            }
         }

         finalizeInstantiate();
         s_logger.debug("Completed formatting the object message");
View Full Code Here

               if (!(childObj instanceof TransferObject))
               {
                  return false;
               }

               TransferObject childTobj = (TransferObject)childObj;

               if (m_instanceByTobjMap.get(childTobj) == null && !"create".equals(childTobj.getEventName()))
               {
                  return false;
               }
            }
         }
View Full Code Here

            return validatedValue;
         }
      }

      CompositeMessagePart composite = (CompositeMessagePart)derivedPart;
      TransferObject tobj = (TransferObject)obj;
      Instance instance = (Instance)m_instanceByTobjMap.get(tobj);

      if (instance == null && "delete".equals(tobj.getEventName())) // Obsolete delete
      {
         if (part.isRequired())
         {
            throw new IntegrationException("err.integration.minPartCount", new Object[]{part.getFullPath()});
         }
View Full Code Here

      CSVMessagePartMapping rootMapping = (CSVMessagePartMapping)rootPart.getMapping();
      CompositeMessagePart rowPart = (CompositeMessagePart)rootPart.getPart(0);
      CSVMessagePartMapping rowMapping = (CSVMessagePartMapping)rowPart.getMapping();
      MessagePart[] partsInOrder = rootMapping.getPartsInOrder();

      TransferObject result = null;
      List listResult;

      try
      {
         if (rootMapping.isHeader())
         {
            if (firstRow == null)
            {
               firstRow = rawReadRow(null, rowMapping);
            }

            consumeComments(rootMapping);
            partsInOrder = makePartsInHeaderOrder(firstRow, rootMapping);
            firstRow = null;
         }

         listResult = parseBody(partsInOrder, rowMapping, firstRow);
      }
      catch (Exception innerEx)
      {
         throw new IntegrationException("err.integration.parse",
            new Object[]{msg.getName()}, innerEx);
      }

      result = new TransferObject(msg.getName());
      result.setValue(rowPart.getName(), listResult);

      return result;
   }
View Full Code Here

    * @throws IOException
    */
   protected List parseBody(MessagePart[] partsInOrder, CSVMessagePartMapping rowMapping, Object[] firstRowData) throws IOException
   {
      Object[] rawRow = firstRowData;
      TransferObject rowResult;
      List listResult;

      if (rowMapping.getPageSize() > 0)
      {
         listResult = new PagedArrayList(rowMapping.getPageSize());
View Full Code Here

TOP

Related Classes of nexj.core.rpc.TransferObject$Iterator

Copyright © 2018 www.massapicom. 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.