Project

General

Profile

« Previous | Next » 

Revision 6296

Added by Chris Jones over 13 years ago

Fixed problems in IdentifierManager asSystemMetadata(), getSystemMetadata(), and querySystemMetadata() that were using ObjectFormat.toString() rather than ObjectFormat.getFmtid().getValue(). Metacat was storing the string memory pointer rather than the actual format string in the systemmetadata table.

View differences:

src/edu/ucsb/nceas/metacat/IdentifierManager.java
107 107
    public SystemMetadata asSystemMetadata(Date dateUploaded, String rightsHolder,
108 108
            String checksum, String checksumAlgorithm, String originMemberNode,
109 109
            String authoritativeMemberNode, Date dateModified, String submitter, 
110
            String guid, String objectFormat, long size) {
110
            String guid, String fmtidStr, long size) {
111 111
        SystemMetadata sysMeta = new SystemMetadata();
112 112

  
113 113
        Identifier sysMetaId = new Identifier();
......
132 132
        submitterSubject.setValue(submitter);
133 133
        sysMeta.setSubmitter(submitterSubject);
134 134
        try {
135
	        sysMeta.setObjectFormat(ObjectFormatCache.getInstance().getFormat(objectFormat));
135
	        sysMeta.setObjectFormat(ObjectFormatCache.getInstance().getFormat(fmtidStr));
136 136
        } catch (NotFound nfe) {
137
          logMetacat.error("The objectFormat " + objectFormat +
137
          logMetacat.error("The objectFormat " + fmtidStr +
138 138
          	" is not registered. Setting the default format.");
139 139
          ObjectFormat of = new ObjectFormat();
140 140
          ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
......
267 267
                String authoritativeMemberNode = rs.getString(7);
268 268
                Timestamp dateModified = rs.getTimestamp(8);
269 269
                String submitter = rs.getString(9);
270
                String objectFormat = rs.getString(10);
270
                String fmtidStr = rs.getString(10);
271 271
                long size = new Long(rs.getString(11)).longValue();
272 272
                
273 273
                Identifier sysMetaId = new Identifier();
......
292 292
                submitterSubject.setValue(submitter);
293 293
                sysMeta.setSubmitter(submitterSubject);
294 294
                try {
295
        	        sysMeta.setObjectFormat(ObjectFormatCache.getInstance().getFormat(objectFormat));
295
        	        sysMeta.setObjectFormat(ObjectFormatCache.getInstance().getFormat(fmtidStr));
296 296
                } catch (NotFound nfe) {
297
                  logMetacat.error("The objectFormat " + objectFormat +
297
                  logMetacat.error("The objectFormat " + fmtidStr +
298 298
                  	" is not registered. Setting the default format.");
299 299
                  ObjectFormat of = new ObjectFormat();
300 300
                  ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
......
1541 1541
            {
1542 1542
                stmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1543 1543
                stmt.setTimestamp(2, new Timestamp(endTime.getTime()));
1544
                stmt.setString(3, objectFormat.toString());
1544
                stmt.setString(3, objectFormat.getFmtid().getValue());
1545 1545
            }
1546 1546
            else if(f1 && f2 && !f3)
1547 1547
            {
......
1551 1551
            else if(f1 && !f2 && f3)
1552 1552
            {
1553 1553
                stmt.setTimestamp(1, new Timestamp(startTime.getTime()));
1554
                stmt.setString(2, objectFormat.toString());
1554
                stmt.setString(2, objectFormat.getFmtid().getValue());
1555 1555
            }
1556 1556
            else if(f1 && !f2 && !f3)
1557 1557
            {
......
1560 1560
            else if(!f1 && f2 && f3)
1561 1561
            {
1562 1562
                stmt.setTimestamp(1, new Timestamp(endTime.getTime()));
1563
                stmt.setString(2, objectFormat.toString());
1563
                stmt.setString(2, objectFormat.getFmtid().getValue());
1564 1564
            }
1565 1565
            else if(!f1 && !f2 && f3)
1566 1566
            {
1567
                stmt.setString(1, objectFormat.toString());
1567
                stmt.setString(1, objectFormat.getFmtid().getValue());
1568 1568
            }
1569 1569
            else if(!f1 && f2 && !f3)
1570 1570
            {
......
1605 1605
                String authoritiveMemberNode = rs.getString(7);
1606 1606
                Timestamp dateModified = rs.getTimestamp(8);
1607 1607
                //String submitter = rs.getString(9);
1608
                String format = rs.getString(10);
1608
                String fmtidStr = rs.getString(10);
1609 1609
                String sz = rs.getString(11);
1610 1610
                long size = 0;
1611 1611
                if(sz != null && !sz.trim().equals(""))
......
1627 1627
                //cs.setAlgorithm(ChecksumAlgorithm.convert(checksumAlgorithm));
1628 1628
                oi.setChecksum(cs);
1629 1629
                
1630
                ObjectFormat oFormat = ObjectFormatCache.getInstance().getFormat(format);
1631
                if(oFormat != null)
1632
                {
1633
                    oi.setObjectFormat(oFormat);
1630
                try {
1631
                ObjectFormat oFormat = ObjectFormatCache.getInstance().getFormat(fmtidStr);
1632
                oi.setObjectFormat(oFormat);
1633

  
1634
                } catch (NotFound nfe) {
1635
                  oi.setObjectFormat(ObjectFormatCache.getInstance().getFormat("application/octet-stream"));
1636
	
1634 1637
                }
1635
                else
1636
                { //if there is no object format, just default to text/plain
1637
                    oi.setObjectFormat(ObjectFormatCache.getInstance().getFormat("application/octet-stream"));
1638
                }
1639 1638
                                
1640 1639
                oi.setSize(size);
1641 1640
                

Also available in: Unified diff