Project

General

Profile

« Previous | Next » 

Revision 7048

for good measure, use the D1 encoding util for url decoding the parameters for listObjects
https://redmine.dataone.org/issues/2460

View differences:

src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
74 74
import org.dataone.service.types.v1.SystemMetadata;
75 75
import org.dataone.service.util.Constants;
76 76
import org.dataone.service.util.DateTimeMarshaller;
77
import org.dataone.service.util.EncodingUtilities;
77 78
import org.dataone.service.util.TypeMarshaller;
78 79
import org.jibx.runtime.JiBXException;
79 80
import org.xml.sax.SAXException;
......
1041 1042

  
1042 1043
        Date startTime = null;
1043 1044
        Date endTime = null;
1044
        ObjectFormat objectFormat = null;
1045
        ObjectFormatIdentifier fmtid = null;
1045 1046
        boolean replicaStatus = false;
1046 1047
        int start = 0;
1047 1048
        int count = -1;
......
1049 1050
        while (paramlist.hasMoreElements()) {
1050 1051
            // parse the params and make the call
1051 1052
            String name = paramlist.nextElement();
1052
            String[] value = request.getParameterValues(name);
1053
            String[] values = request.getParameterValues(name);
1054
            String value = null;
1055
            if (values != null && values.length > 0) {
1056
            	value = values[0];
1057
            	value = EncodingUtilities.decodeString(value);
1058
            }
1053 1059

  
1054 1060
            if (name.equals("fromDate") && value != null) {
1055 1061
                try {
1056
                    startTime = DateTimeMarshaller
1057
                            .deserializeDateToUTC(value[0]);
1062
                    startTime = DateTimeMarshaller.deserializeDateToUTC(value);
1058 1063
                } catch (Exception e) {
1059 1064
                    // if we can't parse it, just don't use the startTime param
1060
                    logMetacat.warn("Could not parse fromDate: " + value[0]);
1065
                    logMetacat.warn("Could not parse fromDate: " + value);
1061 1066
                    startTime = null;
1062 1067
                }
1063 1068
            } else if (name.equals("toDate") && value != null) {
1064 1069
                try {
1065
                    endTime = DateTimeMarshaller.deserializeDateToUTC(value[0]);
1070
                    endTime = DateTimeMarshaller.deserializeDateToUTC(value);
1066 1071
                } catch (Exception e) {
1067 1072
                    // if we can't parse it, just don't use the endTime param
1068
                    logMetacat.warn("Could not parse toDate: " + value[0]);
1073
                    logMetacat.warn("Could not parse toDate: " + value);
1069 1074
                    endTime = null;
1070 1075
                }
1071 1076
            } else if (name.equals("objectFormat") && value != null) {
1072
                objectFormat = ObjectFormatCache.getInstance().getFormat(
1073
                        value[0]);
1077
            	fmtid = new ObjectFormatIdentifier();
1078
            	fmtid.setValue(value);
1074 1079
            } else if (name.equals("replicaStatus") && value != null) {
1075
                replicaStatus = Boolean.parseBoolean(value[0]);
1080
                replicaStatus = Boolean.parseBoolean(value);
1076 1081
            } else if (name.equals("start") && value != null) {
1077
                start = Integer.valueOf(value[0]);
1082
                start = Integer.valueOf(value);
1078 1083
            } else if (name.equals("count") && value != null) {
1079
                count = Integer.valueOf(value[0]);
1084
                count = Integer.valueOf(value);
1080 1085
            }
1081 1086
        }
1082 1087
        // make the call
1083 1088
        logMetacat.debug("session: " + session + " fromDate: " + startTime
1084
                + " toDate: " + endTime + " objectFormat: " + objectFormat
1089
                + " toDate: " + endTime + " objectFormat: " + fmtid
1085 1090
                + " replicaStatus: " + replicaStatus + " start: " + start
1086
                + " count: " + count);
1091
                + " count: " + count);        
1087 1092

  
1088
        ObjectFormatIdentifier fmtid = null;
1089
        if (objectFormat != null) {
1090
            fmtid = objectFormat.getFormatId();
1091
        }
1092

  
1093 1093
        // get the list
1094 1094
        ObjectList ol = CNodeService.getInstance(request).listObjects(session,
1095 1095
                startTime, endTime, fmtid, replicaStatus, start, count);

Also available in: Unified diff