Project

General

Profile

« Previous | Next » 

Revision 5550

Added by berkley over 13 years ago

added a check for bad data into listObjects

View differences:

CrudService.java
808 808
              //add the ObjectInfo to the ObjectList
809 809
              if(info.getIdentifier().getValue() != null)
810 810
              { //id can be null from tests.  should not happen in production.
811
                  ol.addObjectInfo(info);
811
                  try
812
                  { //try to serialize info.  if it cannot be serialized, then
813
                    //don't add it to the info.  bad SM can be added via tests
814
                    //which can break this code.
815
                      serializeObjectInfo(info);
816
                      ol.addObjectInfo(info);
817
                  }
818
                  catch(Exception e)
819
                  {} //don't do anything
820
                  
812 821
              }
813 822
             
814 823
          }
......
1650 1659
    }
1651 1660
    
1652 1661
    /**
1662
     * serialize an ObjectInfo object
1663
     * @param info
1664
     * @return
1665
     * @throws ServiceFailure
1666
     */
1667
    public static ByteArrayOutputStream serializeObjectInfo(ObjectInfo info)
1668
      throws ServiceFailure
1669
    {
1670
        IBindingFactory bfact;
1671
        ByteArrayOutputStream sysmetaOut = null;
1672
        try {
1673
            bfact = BindingDirectory.getFactory(ObjectInfo.class);
1674
            IMarshallingContext mctx = bfact.createMarshallingContext();
1675
            sysmetaOut = new ByteArrayOutputStream();
1676
            mctx.marshalDocument(info, "UTF-8", null, sysmetaOut);
1677
        } catch (JiBXException e) {
1678
            e.printStackTrace();
1679
            throw new ServiceFailure("1190", "Failed to serialize and insert SystemMetadata: " + e.getMessage());
1680
        }
1681
        
1682
        return sysmetaOut;
1683
    }
1684
    
1685
    /**
1653 1686
     * serialize a system metadata doc
1654 1687
     * @param sysmeta
1655 1688
     * @return

Also available in: Unified diff