Project

General

Profile

« Previous | Next » 

Revision 9123

Added by Jing Tao over 9 years ago

Added the code to handle put method in meta url. See bug https://projects.ecoinformatics.org/ecoinfo/issues/6666

View differences:

CNResourceHandler.java
24 24

  
25 25
import java.io.File;
26 26
import java.io.FileInputStream;
27
import java.io.FileNotFoundException;
27 28
import java.io.IOException;
28 29
import java.io.InputStream;
29 30
import java.io.OutputStream;
......
189 190
                        registerSystemMetadata();
190 191
                        status = true;
191 192
                    }
193
                    else if (httpVerb == PUT) {
194
                        logMetacat.debug("Using resource 'meta' for PUT");
195
                        updateSystemMetadata();
196
                        status = true;
197
                    }
192 198

  
193 199
                } else if (resource.startsWith(RESOURCE_RESERVE)) {
194 200
                    // reserve the ID (in params)
......
1702 1708
        return result;
1703 1709

  
1704 1710
    }
1711
    
1712
    /**
1713
     * Update the system metadata for a specified pid
1714
     * @throws ServiceFailure
1715
     * @throws InvalidRequest
1716
     * @throws InstantiationException
1717
     * @throws IllegalAccessException
1718
     * @throws IOException
1719
     * @throws JiBXException
1720
     * @throws NotImplemented
1721
     * @throws NotAuthorized
1722
     * @throws InvalidSystemMetadata
1723
     * @throws InvalidToken
1724
     */
1725
    protected void updateSystemMetadata() throws ServiceFailure, InvalidRequest, InstantiationException, 
1726
                        IllegalAccessException, IOException, JiBXException, NotImplemented, NotAuthorized, InvalidSystemMetadata, InvalidToken {
1727
        // Read the incoming data from its Mime Multipart encoding
1728
        Map<String, File> files = collectMultipartFiles();
1729
        
1730
        // get the encoded pid string from the body and make the object
1731
        String pidString = multipartparams.get("pid").get(0);
1732
        Identifier pid = new Identifier();
1733
        pid.setValue(pidString);
1734
        
1735
        logMetacat.debug("updateSystemMetadata: " + pid);
1705 1736

  
1737
        // get the system metadata from the request
1738
        File smFile = files.get("sysmeta");
1739
        FileInputStream sysmeta = new FileInputStream(smFile);
1740
        SystemMetadata systemMetadata = TypeMarshaller.unmarshalTypeFromStream(SystemMetadata.class, sysmeta);
1741

  
1742
        logMetacat.debug("updating system metadata with pid " + pid.getValue());
1743
        
1744
        CNodeService.getInstance(request).updateSystemMetadata(session, pid, systemMetadata);
1745
    }
1746

  
1706 1747
}

Also available in: Unified diff