Project

General

Profile

« Previous | Next » 

Revision 5670

Added by berkley about 14 years ago

got getChecksum working. working on delete now. all tests in d1clienttest now pass

View differences:

src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
1225 1225
    {
1226 1226
        Logger logMetacat = Logger.getLogger(ResourceHandler.class);
1227 1227
        logMetacat.info("writing MMP parts");
1228
        String s = beginSearch;
1228
        //String s = beginSearch;
1229
        String s = null;
1229 1230
        FileOutputStream fos = new FileOutputStream(f);
1230 1231
        int numread = 0;
1231 1232
        byte[] b = new byte[1024];
......
1237 1238
            s = new String(b, 0, numread);
1238 1239
        }
1239 1240
        
1241
        if(beginSearch != null)
1242
        {
1243
            s = beginSearch + s;
1244
        }
1245
        
1240 1246
        boolean useCurrentS = true;
1241 1247
        boolean searchForBoundary = false;
1242 1248
        String seekString = searchString;
......
1246 1252
            logMetacat.info("////////////////////////iterating");
1247 1253
            logMetacat.info("searchForBoundary: " + searchForBoundary);
1248 1254
            logMetacat.info("useCurrentS: " + useCurrentS);
1255
            logMetacat.info("seekString: " + seekString);
1256
            logMetacat.info("in string: " + s);
1249 1257
            if(searchForBoundary)
1250 1258
            {
1251 1259
                seekString = boundary;
......
1269 1277
                }
1270 1278
            }
1271 1279
            
1272
            logMetacat.info("seekString: " + seekString);
1273
            logMetacat.info("in string: " + s);
1280
            logMetacat.info("2seekString: " + seekString);
1281
            logMetacat.info("2in string: " + s);
1274 1282
            
1275 1283
            if(result[0] >= 0 && result[1] == seekString.length())
1276 1284
            {
......
1355 1363
        //System.out.println("==========================Looking for SM");
1356 1364
        //System.out.println("writing sm to " + fileArr[0].getAbsolutePath());
1357 1365
        logMetacat.info("writing mime system metadata to " + fileArr[0].getAbsolutePath());
1358
        s = writeMMPPartToFile(s, is, boundary, searchStrings[0], fileArr[0]);
1366
        s = writeMMPPartToFile(s.trim(), is, boundary, searchStrings[0], fileArr[0]);
1367
        logMetacat.info("writeMMPPartToFile returned '" + s.trim() + "' after processing the system metadata");
1359 1368
        //System.out.println("==========================Looking for Object");
1360 1369
        //System.out.println("writing obj to " + fileArr[1].getAbsolutePath());
1361 1370
        logMetacat.info("writing mime object to " + fileArr[1].getAbsolutePath());
1362
        writeMMPPartToFile(s, is, boundary, searchStrings[1], fileArr[1]);
1371
        writeMMPPartToFile(s.trim(), is, boundary, searchStrings[1], fileArr[1]);
1363 1372
        h.put("sysmeta", fileArr[0]);
1364 1373
        h.put("object", fileArr[1]);
1365 1374
        return h;
......
1423 1432
            
1424 1433
            try
1425 1434
            {
1426
                parts = processMMP(request.getInputStream());
1435
                //String req = IOUtils.toString(request.getInputStream());
1436
                //System.out.println("request: " + req);
1437
                //InputStream reqStr = IOUtils.toInputStream(req);
1438
                InputStream reqStr = request.getInputStream();
1439
                parts = processMMP(reqStr);
1427 1440
                object = new FileInputStream(parts.get("object"));
1428 1441
                sysmeta = new FileInputStream(parts.get("sysmeta"));
1442
                
1443
                String obj = IOUtils.toString(object);
1444
                String sm = IOUtils.toString(sysmeta);
1445
                System.out.println("object: " + obj);
1446
                System.out.println("sm: " + sm);
1447
                object = IOUtils.toInputStream(obj);
1448
                sysmeta = IOUtils.toInputStream(sm);
1429 1449
            }
1430 1450
            catch(IOException ioe)
1431 1451
            {
src/edu/ucsb/nceas/metacat/dataone/CrudService.java
1065 1065
            NotAuthorized, NotFound, InvalidRequest, NotImplemented 
1066 1066
    {
1067 1067
        logCrud.info("getChecksum");
1068
        if(checksumAlgorithm == null)
1068
        SystemMetadata sm = getSystemMetadata(token, guid);
1069
        Checksum cs = sm.getChecksum();
1070
        if(cs.getAlgorithm().toString().equals(checksumAlgorithm))
1069 1071
        {
1070
            checksumAlgorithm = "MD5";
1072
            return cs;
1071 1073
        }
1072
        InputStream docStream = get(token, guid);
1073
        String checksum;
1074
        try
1074
        else
1075 1075
        {
1076
            checksum = checksum(docStream, checksumAlgorithm);
1076
            if(checksumAlgorithm == null)
1077
            {
1078
                checksumAlgorithm = "MD5";
1079
            }
1080
            InputStream docStream = get(token, guid);
1081
            String checksum;
1082
            try
1083
            {
1084
                checksum = checksum(docStream, checksumAlgorithm);
1085
            }
1086
            catch(Exception e)
1087
            {
1088
                throw new ServiceFailure("1410", "Error getting checksum: " + e.getMessage());
1089
            }
1090
            Checksum c = new Checksum();
1091
            c.setAlgorithm(ChecksumAlgorithm.convert(checksumAlgorithm));
1092
            c.setValue(checksum);
1093
            return c;
1077 1094
        }
1078
        catch(Exception e)
1079
        {
1080
            throw new ServiceFailure("1410", "Error getting checksum: " + e.getMessage());
1081
        }
1082
        Checksum c = new Checksum();
1083
        c.setAlgorithm(ChecksumAlgorithm.convert(checksumAlgorithm));
1084
        c.setValue(checksum);
1085
        return c;
1086 1095
    }
1087 1096

  
1088 1097
    /**

Also available in: Unified diff