It looks like you need to install the item. You may want to have a look at the InstallItem class; it will transition the item out of the workspace and flag it as active. You should update your WorkspaceItem first (e.g. wi.update()).
~Matt -- Matt Cordial Research Programmer Grainger Engineering Library University of Illinois Urbana-Champaign Krishna wrote: > Hi everyone, > > I have written a java program which insert all the dc metadata like > title, author etc but i couldn't insert a file in DSpace. i m not > getting any errors or exceptions but when i go to the > DSpaceUI(http://localhost:8080/dspace), i could see that the item that > i m trying to submit in the collection has a status unfinished > submissions. > Please helpme out how to insert a file in the dspace repository > through a java program > Java Program: > public class ItemCreate { > public static void main(String[] args) { > try{ > System.getProperties().setProperty("dspace.configuration","c:/DSpace/config/dspace.cfg"); > > /* Creating a context and the setting the authorized current user who > can insert metadata into the dspace*/ > Context context=new Context(); > EPerson ep=EPerson.findByEmail(context, "[EMAIL PROTECTED]"); > context.setCurrentUser(ep); > System.out.println("eperson"+ep.toString()); > > Community community=Community.find(context,2); > Collection collection=Collection.find(context,2); > System.out.println("comm:"+community +" coll: "+collection); > > /*Creating a workspace for item to be inserted inthe repository*/ > WorkspaceItem wsi=WorkspaceItem.create(context, collection, false); > Item item=wsi.getItem(); > String schema="dc"; > String element="contributor"; > String qualifier="author"; > String lang="en"; > String value="DofD"; > > String schema1="dc"; > String element1="title"; > String qualifier1=null; > String lang1="en"; > String value1="DSpace Test Submission"; > > String schema2="dc"; > String element2="relation"; > String qualifier2="ispartofseries"; > String lang2="en"; > String value2[]=new String[2]; > value2[0]="ISO111"; > value2[1]="1111"; > > String schema3="dc"; > String element3="identifier"; > String qualifier3="issn"; > String lang3="en"; > String value3="12121"; > > String schema4="dc"; > String element4="type"; > String qualifier4=null; > String lang4="en"; > String value4="Article"; > > String schema5="dc"; > String element5="language"; > String qualifier5="iso"; > String lang5="en"; > String value5="en_US"; > > String schema6="dc"; > String element6="subject"; > String qualifier6="other"; > String lang6="en"; > String value6="ADL-R"; > > String schema7="dc"; > String element7="description"; > String qualifier7="abstract"; > String lang7="en"; > String value7="I am trying to insert a damn item which is > bloody bugging me for a long time"; > > String schema8="dc"; > String element8="description"; > String qualifier8="sponsorship"; > String lang8="en"; > String value8="University of Memphis"; > > String schema9="dc"; > String element9="description"; > String qualifier9=null; > String lang9="en"; > String value9="not much to say..as of know i m so tired of > modying this code"; > item.addMetadata(schema,element, qualifier, lang, value); > item.addMetadata(schema1,element1, qualifier1, lang1, value1); > item.addMetadata(schema2,element2, qualifier2, lang2, value2); > item.addMetadata(schema3,element3, qualifier3, lang3, value3); > item.addMetadata(schema4,element4, qualifier4, lang4, value4); > item.addMetadata(schema5,element5, qualifier5, lang5, value5); > item.addMetadata(schema6,element6, qualifier6, lang6, value6); > item.addMetadata(schema7,element7, qualifier7, lang7, value7); > item.addMetadata(schema8,element8, qualifier8, lang8, value8); > item.addMetadata(schema9,element9, qualifier9, lang9, value9); > > File file=new File("c:/sample.txt") ; > InputStream is=new FileInputStream(file); > System.out.println("size of the file:"+is.available()); > item.createSingleBitstream(is); > > collection.addItem(item); > item.update(); > collection.update(); > community.update(); > context.commit(); > }catch(Exception e){e.printStackTrace();} > } > > } > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier. > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > DSpace-tech mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/dspace-tech > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ DSpace-tech mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dspace-tech

