Project

General

Profile

« Previous | Next » 

Revision 6302

handle data objects (not sci meta) and also set the resulting pid so that create() can succeed

View differences:

src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
219 219

  
220 220
        }
221 221
                    
222
      }
223
        
224

  
225
    } else {
226
        
227
      // DEFAULT CASE: DATA (needs to be checked and completed)
228
      //localId = insertDataObject(object, pid, session);
229
        
222
      } else {
223
	        
224
	      // DEFAULT CASE: DATA (needs to be checked and completed)
225
	      localId = insertDataObject(object, pid, session);
226
      }   
227
    
230 228
    }
231

  
229
    
232 230
    // setting the resulting identifier failed
233
    if (resultPid == null ) {
234
      throw new ServiceFailure("1190", "The Node is unable to create the object. " +
235
        "The resulting identifier was null.");
236
      
231
    if (localId == null ) {
232
      throw new ServiceFailure("1190", "The Node is unable to create the object. ");
237 233
    }
238 234
    
235
    resultPid = pid;
236
    
239 237
    return resultPid;
240 238
  }
241 239

  
......
823 821
    doctext[0] = xml;
824 822
    params.put("doctext", doctext);
825 823
    
826
    String username = "public";
824
    String username = Constants.PUBLIC_SUBJECT;
827 825
    String[] groupnames = null;
828
    if( session != null ) {
829
      username = session.getSubject().getValue();
830
      List<Group> groupList = session.getSubjectList().getGroupList();
831
      for ( int i = 0; i > groupList.size(); i++ ) {
832
      	groupnames[i] = groupList.get(i).getGroupName();
833
      	
834
      }
826
    if (session != null ) {
827
    	username = session.getSubject().getValue();
828
    	if (session.getSubjectList() != null) {
829
    		List<Group> groupList = session.getSubjectList().getGroupList();
830
    		if (groupList != null) {
831
    			groupnames = new String[groupList.size()];
832
    			for (int i = 0; i > groupList.size(); i++ ) {
833
    				groupnames[i] = groupList.get(i).getGroupName();
834
    			}
835
    		}
836
    	}
835 837
    }
836 838
    
837 839
    // do the insert or update action
......
867 869
  protected String insertDataObject(InputStream object, Identifier pid, 
           Session session) throws ServiceFailure {
       
-    String username = "public";
870
    String username = Constants.PUBLIC_SUBJECT;
868 871
    String[] groupnames = null;
869
    if( session != null ) {
870
      username = session.getSubject().getValue();
871
      List<Group> groupList = session.getSubjectList().getGroupList();
872
      for ( int i = 0; i > groupList.size(); i++ ) {
873
      	groupnames[i] = groupList.get(i).getGroupName();
874
      	
875
      }
876
      
872
    if (session != null ) {
873
    	username = session.getSubject().getValue();
874
    	if (session.getSubjectList() != null) {
875
    		List<Group> groupList = session.getSubjectList().getGroupList();
876
    		if (groupList != null) {
877
    			groupnames = new String[groupList.size()];
878
    			for (int i = 0; i > groupList.size(); i++ ) {
879
    				groupnames[i] = groupList.get(i).getGroupName();
880
    			}
881
    		}
882
    	}
877 883
    }
878 884
  
     // generate pid/localId pair for object

Also available in: Unified diff