Project

General

Profile

« Previous | Next » 

Revision 5640

Added by berkley over 13 years ago

got the streaming mime multipart working

View differences:

ResourceHandler.java
1111 1111
            InputStream is, String boundary, String searchString, File f)
1112 1112
        throws IOException
1113 1113
    {
1114
        Logger logMetacat = Logger.getLogger(ResourceHandler.class);
1115
        logMetacat.info("writing MMP parts");
1114 1116
        String s = beginSearch;
1115 1117
        FileOutputStream fos = new FileOutputStream(f);
1116 1118
        int numread = 0;
......
1129 1131
        
1130 1132
        while(numread != -1)
1131 1133
        {
1132
            //System.out.println("////////////////////////iterating");
1133
            //System.out.println("searchForBoundary: " + searchForBoundary);
1134
            logMetacat.info("////////////////////////iterating");
1135
            logMetacat.info("searchForBoundary: " + searchForBoundary);
1136
            logMetacat.info("useCurrentS: " + useCurrentS);
1134 1137
            if(searchForBoundary)
1135 1138
            {
1136 1139
                seekString = boundary;
......
1154 1157
                }
1155 1158
            }
1156 1159
            
1157
            //System.out.println("searchString: " + searchString);
1158
            //System.out.println("seekString: " + seekString);
1159
            //System.out.println("in string: " + s);
1160
            logMetacat.info("seekString: " + seekString);
1161
            logMetacat.info("in string: " + s);
1160 1162
            
1161 1163
            if(result[0] >= 0 && result[1] == seekString.length())
1162 1164
            {
1163
              //searchString is full in s
1165
                //searchString is full in s
1166
                logMetacat.info("seekstring is fully in s");
1164 1167
                if(!searchForBoundary)
1165 1168
                {   //we're looking for searchString and we found it
1166 1169
                    //chop off the searchString itself and start writing
......
1180 1183
                {   //we're writing, but we found the boundary in this chunk
1181 1184
                    
1182 1185
                    writeString = s.substring(0, result[0]);
1186
                    System.out.println("writing1: " + writeString);
1183 1187
                    fos.write(writeString.getBytes());
1184 1188
                    //we're done.  break and return;
1185 1189
                    return s.substring(result[0] + result[1], s.length());
......
1187 1191
            }
1188 1192
            else if(result[0] > 0 && result[1] != seekString.length())
1189 1193
            {
1194
                logMetacat.info("seekstring is partially in s");
1190 1195
                //seekString is partially in s
1191 1196
                //more specifically, the beginning of seekString is at the end
1192 1197
                //of s
......
1195 1200
                numread = is.read(b, 0, 1024);
1196 1201
                String s2 = new String(b, 0, numread);
1197 1202
                s += s2;
1198
                useCurrentS = false;
1203
                useCurrentS = true;
1199 1204
            }
1200 1205
            else
1201 1206
            {
1207
                logMetacat.info("seekstring is not in s");
1202 1208
                //searchString is not in s 
1203 1209
                if(searchForBoundary)
1204 1210
                {
1211
                    System.out.println("writing2: " + s);
1205 1212
                    fos.write(s.getBytes());
1206 1213
                }
1207 1214
                numread = is.read(b, 0, 1024);
......
1213 1220
                {
1214 1221
                    break;
1215 1222
                }
1223
                useCurrentS = true;
1216 1224
            }
1217 1225
        }
1218 1226
        return "";
......
1221 1229
    protected Hashtable<String, File> writeMMPPartsToFiles(InputStream is)
1222 1230
        throws IOException
1223 1231
    {
1232
        Logger logMetacat = Logger.getLogger(ResourceHandler.class);
1233
        logMetacat.info("Processing Mime Multipart");
1224 1234
        String[] boundaryResults = findBoundaryString(is);
1225 1235
        String boundary = boundaryResults[0];
1226 1236
        String s = boundaryResults[1];
......
1230 1240
        
1231 1241
        File[] fileArr = getMMPTempFiles();
1232 1242
        Hashtable<String, File> h = new Hashtable<String, File>();
1233
        System.out.println("==========================Looking for SM");
1243
        //System.out.println("==========================Looking for SM");
1244
        //System.out.println("writing sm to " + fileArr[0].getAbsolutePath());
1245
        logMetacat.info("writing mime system metadata to " + fileArr[0].getAbsolutePath());
1234 1246
        s = writeMMPPartToFile(s, is, boundary, searchStrings[0], fileArr[0]);
1235
        System.out.println("==========================Looking for Object");
1247
        //System.out.println("==========================Looking for Object");
1248
        //System.out.println("writing obj to " + fileArr[1].getAbsolutePath());
1249
        logMetacat.info("writing mime object to " + fileArr[1].getAbsolutePath());
1236 1250
        writeMMPPartToFile(s, is, boundary, searchStrings[1], fileArr[1]);
1237 1251
        h.put("sysmeta", fileArr[0]);
1238 1252
        h.put("object", fileArr[1]);

Also available in: Unified diff