Project

General

Profile

« Previous | Next » 

Revision 6634

Added by Chris Jones over 12 years ago

Since we're using a multipart form to encode parameters, extract the params out of the multipart form prior to doing a get() from the multipartparams map in setReplicationStatus(). Likewise, do the same in updateReplicationMetadata() and setReplicationPolicy().

View differences:

CNResourceHandler.java
41 41
import org.apache.commons.io.IOUtils;
42 42
import org.apache.log4j.Logger;
43 43
import org.dataone.client.ObjectFormatCache;
44
import org.dataone.mimemultipart.MultipartRequest;
45
import org.dataone.mimemultipart.MultipartRequestResolver;
44 46
import org.dataone.service.exceptions.BaseException;
45 47
import org.dataone.service.exceptions.IdentifierNotUnique;
46 48
import org.dataone.service.exceptions.InsufficientResources;
......
1042 1044
        Identifier identifier = new Identifier();
1043 1045
        identifier.setValue(pid);
1044 1046
        
1047
        policy = collectReplicationPolicy();
1048

  
1045 1049
        // get the serialVersion
1046 1050
        try {
1047 1051
            serialVersionStr = multipartparams.get("serialVersion").get(0);
......
1053 1057
            throw new InvalidRequest("4883", msg);
1054 1058
            
1055 1059
        }
1056
        policy = collectReplicationPolicy();
1057 1060
        result = 
1058 1061
            CNodeService.getInstance(request).setReplicationPolicy(session, identifier, policy, serialVersion);
1059 1062
        response.setStatus(200);
......
1078 1081
        throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized, 
1079 1082
        InvalidRequest, NotFound {
1080 1083

  
1084
        File tmpDir = getTempDirectory();
1085
        MultipartRequest mr = null;
1081 1086
        boolean result = false;
1082 1087
        Identifier identifier = new Identifier();
1083 1088
        identifier.setValue(pid);
......
1088 1093
        NodeReference targetNodeRef = null;
1089 1094
        String targetNode = null;
1090 1095
        
1096
        // Parse the params out of the multipart form data
1097
        // Read the incoming data from its Mime Multipart encoding
1098
        logMetacat.debug("Parsing ReplicaStatus from the mime multipart entity");
1099

  
1100
        // handle MMP inputs
1101
        MultipartRequestResolver mrr = 
1102
            new MultipartRequestResolver(tmpDir.getAbsolutePath(),1000000000, 0);
1103
        
1104
        try {
1105
            mr = mrr.resolveMultipart(request);
1106
            multipartparams = mr.getMultipartParameters();
1107
            logMetacat.debug("Resolved the ReplicaStatus multipart request.");
1108
            
1109
        } catch (IOException e) {
1110
            throw new ServiceFailure("4852", "Couldn't resolve the multipart request: " +
1111
                e.getMessage());
1112
            
1113
        } catch (FileUploadException e) {
1114
            throw new ServiceFailure("4852", "Couldn't resolve the multipart request: " +
1115
                    e.getMessage());
1116
            
1117
        } catch (Exception e) {
1118
            throw new ServiceFailure("4852", "Couldn't resolve the multipart request: " +
1119
                    e.getMessage());
1120
            
1121
        }
1122

  
1091 1123
        // get the serialVersion
1092 1124
        try {
1093 1125
            serialVersionStr = multipartparams.get("serialVersion").get(0);
......
1145 1177
        Identifier identifier = new Identifier();
1146 1178
        identifier.setValue(pid);
1147 1179

  
1180
        replica = collectReplicaMetadata();
1181
        
1148 1182
        // get the serialVersion
1149 1183
        try {
1150 1184
            serialVersionStr = multipartparams.get("serialVersion").get(0);
......
1157 1191
            
1158 1192
        }
1159 1193

  
1160
        replica = collectReplicaMetadata();
1161 1194
        result = 
1162 1195
            CNodeService.getInstance(request).updateReplicationMetadata(session, identifier, replica, serialVersion);
1163 1196
        response.setStatus(200);

Also available in: Unified diff