Project

General

Profile

« Previous | Next » 

Revision 5616

Added by berkley about 14 years ago

fixing trac bug 828

View differences:

src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
1015 1015
        //stream into memory.
1016 1016
        InputStream object = null;
1017 1017
        InputStream sysmeta = null;
1018
        String s = streamToString(is);
1019
        //System.out.println("s: " + s);
1018
        String s = IOUtils.toString(is);
1019
        System.out.println("mime: " + s);
1020 1020
        //figure out what the boundary marker is
1021 1021
        String searchString = "boundary=";
1022 1022
        int searchStringIndex = s.indexOf(searchString);
......
1028 1028
        //find the system metadata
1029 1029
        searchString = "Content-Disposition: attachment; filename=systemmetadata";
1030 1030
        searchStringIndex = s.indexOf(searchString);
1031
        sysmeta = new ByteArrayInputStream(
1032
                s.substring(searchStringIndex +
1033
                        searchString.length(), 
1034
                        s.indexOf(boundary, searchStringIndex)).trim().getBytes());
1031
        String sm = s.substring(searchStringIndex +
1032
                searchString.length() + 2, 
1033
                s.indexOf(boundary, searchStringIndex));
1034
        sysmeta = new ByteArrayInputStream(sm.getBytes());
1035 1035
        
1036 1036
        //find the object
1037 1037
        searchString = "Content-Disposition: attachment; filename=object";
1038 1038
        searchStringIndex = s.indexOf(searchString);
1039
        object = new ByteArrayInputStream(
1040
                s.substring(searchStringIndex +
1041
                        searchString.length(), 
1042
                        s.indexOf(boundary, searchStringIndex)).trim().getBytes());
1039
        String o = s.substring(searchStringIndex +
1040
                searchString.length() + 2, 
1041
                s.indexOf(boundary, searchStringIndex));
1042
        object = new ByteArrayInputStream(o.getBytes());
1043 1043
        
1044 1044
        Hashtable h = new Hashtable();
1045 1045
        h.put("object", object);
1046 1046
        h.put("systemmetadata", sysmeta);
1047
                
1048
        System.out.println("o: \"" + o + "\"");
1049
        System.out.println("sm: \"" + sm + "\"");
1047 1050
        return h;
1048 1051
    }
1049 1052
    
......
1073 1076
            
1074 1077
            Hashtable parts = processMMP(request.getInputStream());
1075 1078
            object = (InputStream)parts.get("object");
1079
            
1076 1080
            sysmeta = (InputStream)parts.get("systemmetadata");
1077 1081
            
1078 1082
            if ( action.equals(FUNCTION_NAME_INSERT)) { //handle inserts

Also available in: Unified diff