Project

General

Profile

« Previous | Next » 

Revision 6241

Implement [MN|CN]Storage.create() in D1NodeService. Since MetacatHandler requires an IP for event logging, we pass in the metacat URL (hold over from CrudService). To do this in the abstract D1NodeService, change the constructors to take metacatUrl as a parameter and get the URL from the metacat properties file in getInstance() of the subclasses. Needs testing.

View differences:

MNodeService.java
66 66
import edu.ucsb.nceas.metacat.EventLog;
67 67
import edu.ucsb.nceas.metacat.IdentifierManager;
68 68
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
69
import edu.ucsb.nceas.metacat.properties.PropertyService;
70
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
69 71

  
70 72
/**
71 73
 * Represents Metacat's implementation of the DataONE Member Node 
......
83 85
  private Logger logMetacat = null;
84 86

  
85 87
  /**
86
   * singleton accessor
88
   * Singleton accessor to get an instance of MNodeService.
89
   * 
90
   * @return instance - the instance of MNodeService
87 91
   */
88
  public static MNodeService getInstance() 
89
  {
92
  public static MNodeService getInstance() {
90 93
    if (instance == null) {
91
      instance = new MNodeService();
94
    	String metacatUrl = "";
95
      String server;
96
      String port;
97
      String context;
98
      String serviceName;
99
      
100
      try {
101
	      server = PropertyService.getProperty("server.name");
102
	      port = PropertyService.getProperty("server.httpPort");
103
	      context = PropertyService.getProperty("application.context");
104
	      serviceName = PropertyService.getProperty("dataone.serviceName");
105
      
106
      } catch (PropertyNotFoundException e) {
107
        throw new RuntimeException("Error getting the servlet url in MNodeService: " + 
108
        	e.getMessage());
109
        
110
      }
111
      metacatUrl = "http://" + server + ":" + port + "/" + context + "/" + serviceName;
112

  
113
      instance = new MNodeService(metacatUrl);
114
      
92 115
    }
93 116
    
94 117
    return instance;
......
96 119
  
97 120
  /**
98 121
   * Constructor, private for singleton access
122
   * 
123
   * @param metacatUrl - the URL of the metacat service, including the context
124
   *                     and serviceName (/d1)
99 125
   */
100
  private MNodeService() {
101
  	super();
126
  private MNodeService(String metacatUrl) {
127
  	super(metacatUrl);
102 128
    logMetacat = Logger.getLogger(MNodeService.class);
103 129
        
104 130
  }
105 131
    
106 132
	/**
107
	 * Adds a new object to the Member Node, where the object is either a data 
108
	 * object or a science metadata object. This method is called by clients 
109
	 * to create new data objects on Member Nodes
110
	 * 
111
	 * @param session - the Session object containing the credentials for the Subject
112
	 * @param pid - The object identifier to be created
113
	 * @param object - the object bytes
114
	 * @param sysmeta - the system metadata that describes the object  
115
	 * 
116
	 * @return pid - the object identifier created
117
	 * 
118
	 * @throws InvalidToken
119
	 * @throws ServiceFailure
120
	 * @throws NotAuthorized
121
	 * @throws IdentifierNotUnique
122
	 * @throws UnsupportedType
123
	 * @throws InsufficientResources
124
	 * @throws InvalidSystemMetadata
125
	 * @throws NotImplemented
126
	 * @throws InvalidRequest
127
	 */
128
  @Override
129
	public Identifier create(Session session, Identifier pid, InputStream object,
130
	  SystemMetadata sysmeta) 
131
    throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
132
    UnsupportedType, InsufficientResources, InvalidSystemMetadata, 
133
    NotImplemented, InvalidRequest {
134

  
135
		return null;
136
	}
137

  
138
	/**
139 133
	 * Deletes an object from the Member Node, where the object is either a 
140 134
	 * data object or a science metadata object.
141 135
	 * 

Also available in: Unified diff