Project

General

Profile

« Previous | Next » 

Revision 5449

Added by berkley over 14 years ago

fixed yet another null sessionData bug

View differences:

src/edu/ucsb/nceas/metacat/dataone/CrudService.java
466 466
    {
467 467
        try
468 468
        {
469
            final SessionData sessionData = getSessionData(token);
470
            if(sessionData == null)
471
            {
472
                throw new ServiceFailure("1000", "User must be logged in to set access.");
473
            }
469 474
            IdentifierManager im = IdentifierManager.getInstance();
470 475
            String docid = im.getLocalId(id.getValue());
471
            final SessionData sessionData = getSessionData(token);
476
        
472 477
            String permNum = "0";
473 478
            if(permission.equals("read"))
474 479
            {
......
1079 1084
                @Override
1080 1085
                public String produce(final OutputStream dataSink) throws Exception {
1081 1086
                    try {
1087
                        String username = "public";
1088
                        String[] groupnames = null;
1089
                        if(sessionData != null)
1090
                        {
1091
                            username = sessionData.getUserName();
1092
                            groupnames = sessionData.getGroupNames();
1093
                        }
1094
                        
1082 1095
                        handler.readFromMetacat(metacatUrl, null, 
1083 1096
                                dataSink, localId, "xml",
1084
                                sessionData.getUserName(), 
1085
                                sessionData.getGroupNames(), true, params);
1097
                                username, 
1098
                                groupnames, true, params);
1086 1099
                    } catch (PropertyNotFoundException e) {
1087 1100
                        e.printStackTrace();
1088 1101
                        throw new ServiceFailure("1030", "Property not found while reading system metadata from metacat: " + e.getMessage());
......
1530 1543
        // generate the right exceptions
1531 1544
        //ByteArrayOutputStream output = new ByteArrayOutputStream();
1532 1545
        //PrintWriter pw = new PrintWriter(output);
1546
        String username = "public";
1547
        String[] groupnames = null;
1548
        if(sessionData != null)
1549
        {
1550
            username = sessionData.getUserName();
1551
            groupnames = sessionData.getGroupNames();
1552
        }
1533 1553
        String result = handler.handleInsertOrUpdateAction(metacatUrl, null, 
1534
                            null, params, sessionData.getUserName(), sessionData.getGroupNames());
1554
                            null, params, username, groupnames);
1535 1555
        //String outputS = new String(output.toByteArray());
1536 1556
        logMetacat.debug("CrudService.insertDocument - Metacat returned: " + result);
1537 1557
        logMetacat.debug("Finsished inserting xml document with id " + localId);

Also available in: Unified diff