Project

General

Profile

« Previous | Next » 

Revision 6803

new jars with many changes -- including new CN methods: ping, describe, listChecksumAlgorithm. Removed MN.setAccessPolicy. Refactored CN.setOwner() to CN.setRightsHolder().

View differences:

MNResourceHandler.java
22 22
 */
23 23
package edu.ucsb.nceas.metacat.restservice;
24 24

  
25
import java.io.ByteArrayInputStream;
26 25
import java.io.File;
27 26
import java.io.FileInputStream;
28 27
import java.io.IOException;
......
61 60
import org.dataone.service.exceptions.ServiceFailure;
62 61
import org.dataone.service.exceptions.SynchronizationFailed;
63 62
import org.dataone.service.exceptions.UnsupportedType;
64
import org.dataone.service.types.v1.AccessPolicy;
65 63
import org.dataone.service.types.v1.Checksum;
66 64
import org.dataone.service.types.v1.DescribeResponse;
67 65
import org.dataone.service.types.v1.Event;
......
76 74
import org.dataone.service.types.v1.Permission;
77 75
import org.dataone.service.types.v1.Subject;
78 76
import org.dataone.service.types.v1.SystemMetadata;
77
import org.dataone.service.util.Constants;
79 78
import org.dataone.service.util.DateTimeMarshaller;
80 79
import org.dataone.service.util.ExceptionHandler;
81 80
import org.dataone.service.util.TypeMarshaller;
82 81
import org.jibx.runtime.JiBXException;
83 82
import org.xml.sax.SAXException;
84 83

  
85
import edu.ucsb.nceas.metacat.dataone.CNodeService;
86 84
import edu.ucsb.nceas.metacat.dataone.MNodeService;
87 85

  
88 86
/**
......
175 173
                    // node response
176 174
                    node();
177 175
                    status = true;
178
                } else if (resource.startsWith(RESOURCE_ACCESS_RULES)) {
179
                    if (httpVerb == PUT) {
180
                    	// after the command
181
                        extra = parseTrailing(resource, RESOURCE_ACCESS_RULES);
182
	                	// set the access rules
183
	                    setAccess(extra);
184
	                    status = true;
185
	                    logMetacat.debug("done setting access");
186
                    }
187 176
                } else if (resource.startsWith(RESOURCE_IS_AUTHORIZED)) {
188 177
                    if (httpVerb == GET) {
189 178
                    	// after the command
......
248 237
                    if (httpVerb == GET) {
249 238
                    	// after the command
250 239
                        extra = parseTrailing(resource, RESOURCE_MONITOR);
251
                    	// health monitoring calls
252
                        status = monitor(extra);
240
                        
241
                        // ping
242
                        if (extra.toLowerCase().equals("ping")) {
243
                            logMetacat.debug("processing ping request");
244
                            Date result = MNodeService.getInstance(request).ping();
245
                            // TODO: send to output	
246
                            status = true;
247
                            
248
                        } else {
249
	                    	// health monitoring calls
250
	                        status = monitor(extra);
251
                        }
252
                        
253 253
                    }
254 254
                } else if (resource.startsWith(RESOURCE_REPLICATE)) {
255 255
                	if (httpVerb == POST) {
......
452 452
        logMetacat.debug("verb is GET");
453 453
        logMetacat.debug("pathInfo is " + pathInfo);
454 454
        
455
        if (pathInfo.toLowerCase().equals("ping")) {
456
            logMetacat.debug("processing ping request");
457
            boolean result = MNodeService.getInstance(request).ping();
458
            return result;
459
            
460
        } else if (pathInfo.toLowerCase().equals("status")) {
455
        if (pathInfo.toLowerCase().equals("status")) {
461 456
            logMetacat.debug("processing status request");
462 457
            // TODO: implement in MNCore
463 458
            //MNodeService.getInstance().getStatus();
......
1075 1070
        TypeMarshaller.marshalTypeToOutputStream(id, out);
1076 1071
        
1077 1072
    }    
1078
    
1079
    /**
1080
     * set the access perms on a document
1081
     * @throws JiBXException 
1082
     * @throws InvalidRequest 
1083
     * @throws NotImplemented 
1084
     * @throws NotAuthorized 
1085
     * @throws NotFound 
1086
     * @throws ServiceFailure 
1087
     * @throws InvalidToken 
1088
     * @throws IllegalAccessException 
1089
     * @throws InstantiationException 
1090
     * @throws IOException 
1091
     * @throws SAXException 
1092
     * @throws ParserConfigurationException 
1093
     */
1094
    protected void setAccess(String pid) throws JiBXException, InvalidToken, ServiceFailure, NotFound, NotAuthorized, NotImplemented, InvalidRequest, IOException, InstantiationException, IllegalAccessException, ParserConfigurationException, SAXException
1095
    {
1096
    
1097
        //String pid = params.get("pid")[0];
1098
        Identifier id = new Identifier();
1099
        id.setValue(pid);
1100
        
1101
        AccessPolicy accessPolicy = collectAccessPolicy();
1102
        MNodeService.getInstance(request).setAccessPolicy(session, id, accessPolicy);
1103
        
1104
        
1105
    }
1106 1073

  
1107 1074
	protected SynchronizationFailed collectSynchronizationFailed() throws IOException, ServiceFailure, InvalidRequest, JiBXException, InstantiationException, IllegalAccessException, ParserConfigurationException, SAXException  {
1108 1075
		

Also available in: Unified diff