private static void populateDC ( Context ctx , DigitalObject obj , DOWriter w , Date nowUTC ) throws IOException , ServerException { logger . debug ( "Adding/Checking default DC datastream" ) ; Datastream dc = w . GetDatastream ( "DC" , null ) ; DCFields dcf ; XMLDatastreamProcessor dcxml = null ; if ( dc == null ) { dcxml = new XMLDatastreamProcessor ( "DC" ) ; dc = dcxml . getDatastream ( ) ; //dc.DSMDClass=DatastreamXMLMetadata.DESCRIPTIVE; dc . DatastreamID = "DC" ; dc . DSVersionID = "DC1.0" ; //dc.DSControlGrp = "X"; set by XMLDatastreamProcessor instead dc . DSCreateDT = nowUTC ; dc . DSLabel = "Dublin Core Record for this object" ; dc . DSMIME = "text/xml" ; dc . DSFormatURI = OAI_DC2_0 . uri ; dc . DSSize = 0 ; dc . DSState = "A" ; dc . DSVersionable = true ; dcf = new DCFields ( ) ; if ( obj . getLabel ( ) != null && ! obj . getLabel ( ) . isEmpty ( ) ) { dcf . titles ( ) . add ( new DCField ( obj . getLabel ( ) ) ) ; } w . addDatastream ( dc , dc . DSVersionable ) ; } else { dcxml = new XMLDatastreamProcessor ( dc ) ; // note: context may be required to get through authz as content // could be filesystem file (or URL) dcf = new DCFields ( dc . getContentStream ( ctx ) ) ; } // set the value of the dc datastream according to what's in the // DCFields object // ensure one of the dc:identifiers is the pid ByteArrayOutputStream bytes = new ByteArrayOutputStream ( 512 ) ; PrintWriter out = new PrintWriter ( new OutputStreamWriter ( bytes , Charset . forName ( "UTF-8" ) ) ) ; dcf . getAsXML ( obj . getPid ( ) , out ) ; out . close ( ) ; dcxml . setXMLContent ( bytes . toByteArray ( ) ) ; }
Adds a minimal DC datastream if one isn t already present .