Sunteți pe pagina 1din 73

Advanced DSpace

plugins, configurable submission, & core API


James Rutherford, DSUG Rome !!"

Part #$ plugins

%i&i'dspace'org(Plugin)anager
Part #$ plugins

*hree t+pes of plugin$
,
,
,
singleton plugins
named plugins
se-uence plugins

singleton plugins

&e+ characteristic$ onl+ one implementing class

e.ample$ site authentication

plugin.single.org.dspace.app.webui.SiteAuthenticator = com.hp.hpl.CustomAuthenticator
e.ample$ site authentication

plugin.single.org.dspace.app.webui.SiteAuthenticator = com.hp.hpl.CustomAuthenticator
e.ample$ site authentication

plugin.single.org.dspace.app.webui.SiteAuthenticator = com.hp.hpl.CustomAuthenticator
dspace'cfg$
/ooServlet'0ava$
SiteAuthenticator siteAuth = (SiteAuthenticator)
PluginManager.getSinglePlugin(SiteAuthenticator.class);

%hen to use$

1hen +ou need a uniform mechanism to perform a given function,
but don2t %ant to be constrained to that mechanism forever'
%hen to use$

named plugins

&e+ characteristic$ multiple implementations available, app choses one b+ name

e.ample$ cross%al&s

plugin.named.org.dspace.content.crosswalk.DisseminationCrosswalk =
org.dspace.content.Crosswalk.SimpleDCDisseminationCrosswalk = dc
org.dspace.content.Crosswalk.M!"SDisseminationCrosswalk = mets
e.ample$ cross%al&s

plugin.named.org.dspace.content.crosswalk.DisseminationCrosswalk =
org.dspace.content.Crosswalk.SimpleDCDisseminationCrosswalk = dc
org.dspace.content.Crosswalk.M!"SDisseminationCrosswalk = mets
e.ample$ cross%al&s

dspace'cfg$
DisseminationCrosswalk #walk = (DisseminationCrosswalk)
PluginManager.get$amedPlugin(DisseminationCrosswalk.class% &dc');
plugin.named.org.dspace.content.crosswalk.DisseminationCrosswalk =
org.dspace.content.Crosswalk.SimpleDCDisseminationCrosswalk = dc
org.dspace.content.Crosswalk.M!"SDisseminationCrosswalk = mets
/ooDisseminator'0ava

note$
named plugins must have names 3&e+s4 that are uni-ue for the interface

note$
names ma+ contain an+ characters other than
2,2 and 252, but alphanumeric is preferred

%hen to use$

%hen to use$
1hen +ou need multiple implementations to be available ( supported
throughout the application, leaving the implementing classes to choose
%hich option to use'

se-uence plugins

&e+ characteristic$ 6stac& of singletons7

e.ample$ stac&able authentication

plugin.se(uence.org.dspace.authenticate.AuthenticationMethod =
org.dspace.authenticate.)*+,Authentication%
org.dspace.authenticate.PasswordAuthentication
e.ample$ stac&able authentication

plugin.se(uence.org.dspace.authenticate.AuthenticationMethod =
org.dspace.authenticate.)*+,Authentication%
org.dspace.authenticate.PasswordAuthentication
e.ample$ stac&able authentication

dspace'cfg$
plugin.se(uence.org.dspace.authenticate.AuthenticationMethod =
org.dspace.authenticate.)*+,Authentication%
org.dspace.authenticate.PasswordAuthentication
Authentication)anager'0ava$
pri-ate static AuthenticationMethod stack./ = (AuthenticationMethod./)
PluginManager.getPluginSe(uence(AuthenticationMethod.class);

%hen to use$

1hen +ou %ant to pass the responsibilit+ for processing through a
stac& of implementing classes'
%hen to use$

Part $ DSpace API
%i&i'dspace'org(static8files("("d(DevelopersDocumentation'pdf
%i&i'dspace'org(DA98Protot+pe 3needs updating4

Section #$ #':'. & #';

-uic& overvie%$ creating a hierarch+

Communit0 communit0 = Communit0.create(null% conte#t);
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0.update();

parent communit+ 3optional4
Communit0 communit0 = Communit0.create(null% conte#t);
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0.update();

Collection collection = communit0.createCollection();
collection.setMetadata(&short1description'% &collection 3oo');
collection.update();
Communit0 communit0 = Communit0.create(null% conte#t);
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0.update();

Collection collection = communit0.createCollection();
collection.setMetadata(&short1description'% &collection 3oo');
collection.update();
chec&s authori<ation, creates =ollection, &
establishes parent ( child relationship

4tem item = 4tem.create(conte#t);
collection.add4tem(item);
Communit0 communit0 = Communit0.create(null% conte#t);
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0.update();
Collection collection = communit0.createCollection();
collection.setMetadata(&short1description'% &collection 3oo');
collection.update();

performs authori<ation chec&s and establishes
the parent ( child relationship
4tem item = 4tem.create(conte#t);
collection.add4tem(item);

or

5orkspace4tem wsi = 5orkspace4tem.create(conte#t% collection% 3alse);
4tem item = wsi.get4tem();
destination =ollection
Item %ill start as a cop+ of
the =ollection2s template

Communit0 communit0 = Communit0.create(null% conte#t);
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0.update();
Collection collection = communit0.createCollection();
collection.setMetadata(&short1description'% &collection 3oo');
collection.update();
4tem item = 4tem.create(conte#t);
collection.add4tem(item);
22 or 22
5orkspace4tem wsi = 5orkspace4tem.create(conte#t% collection% 3alse);
4tem item = wsi.get4tem();

Section $ #'>?@
@ core API for #'>? releases still needs to be finalised

comparison %ith e.isting API$ creating a hierarch+

Communit0DA6 communit0DA6 = Communit0DA67actor0.get4nstance(conte#t);
CollectionDA6 collectionDA6 = CollectionDA67actor0.get4nstance(conte#t);
4temDA6 itemDA6 = 4temDA67actor0.get4nstance(conte#t);

Communit0DA6 communit0DA6 = Communit0DA67actor0.get4nstance(conte#t);
CollectionDA6 collectionDA6 = CollectionDA67actor0.get4nstance(conte#t);
4temDA6 itemDA6 = 4temDA67actor0.get4nstance(conte#t);
implementation defined in configuration

Communit0 communit0 = communit0DA6.create();
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0DA6.update(communit0);
Communit0DA6 communit0DA6 = Communit0DA67actor0.get4nstance(conte#t);
CollectionDA6 collectionDA6 = CollectionDA67actor0.get4nstance(conte#t);
4temDA6 itemDA6 = 4temDA67actor0.get4nstance(conte#t);

Communit0DA6 communit0DA6 = Communit0DA67actor0.get4nstance(conte#t);
CollectionDA6 collectionDA6 = CollectionDA67actor0.get4nstance(conte#t);
4temDA6 itemDA6 = 4temDA67actor0.get4nstance(conte#t);
Communit0 communit0 = communit0DA6.create();
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0DA6.update(communit0);
Collection collection = collectionDA6.create();
collection.setMetadata(&short1description'% &collection 3oo');
collectionDA6.update(collection);

4tem item = 4temDA6.create();
Communit0DA6 communit0DA6 = Communit0DA67actor0.get4nstance(conte#t);
CollectionDA6 collectionDA6 = CollectionDA67actor0.get4nstance(conte#t);
4temDA6 itemDA6 = 4temDA67actor0.get4nstance(conte#t);
Communit0 communit0 = communit0DA6.create();
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0DA6.update(communit0);
Collection collection = collectionDA6.create();
collection.setMetadata(&short1description'% &collection 3oo');
collectionDA6.update(collection);

communit0DA6.link(communit0% collection);
collectionDA6.link(collection% item);
Communit0DA6 communit0DA6 = Communit0DA67actor0.get4nstance(conte#t);
CollectionDA6 collectionDA6 = CollectionDA67actor0.get4nstance(conte#t);
4temDA6 itemDA6 = 4temDA67actor0.get4nstance(conte#t);
Communit0 communit0 = communit0DA6.create();
communit0.setMetadata(&short1description'% &top2le-el communit0');
communit0DA6.update(communit0);
Collection collection = collectionDA6.create();
collection.setMetadata(&short1description'% &collection 3oo');
collectionDA6.update(collection);
4tem item = 4temDA6.create();

Section a$ other changes coming in #'>

Section a$ other changes coming in #'>
, S89!#ceptions

Section a$ other changes coming in #'>
, S89!#ceptions

Section a$ other changes coming in #'>
, S89!#ceptions
, DSpace6b:ect.get;andle()

Section a$ other changes coming in #'>
, S89!#ceptions
, DSpace6b:ect.get;andle()

Section a$ other changes coming in #'>
, S89!#ceptions
, DSpace6b:ect.get;andle()
, <<4Ds

Section a$ other changes coming in #'>
, S89!#ceptions
, DSpace6b:ect.get;andle()
, <<4Ds
, 6b:ect4denti3ier

Section a$ other changes coming in #'>
, S89!#ceptions
, DSpace6b:ect.get;andle()
, <<4Ds
, 6b:ect4denti3ier
, item.update() ,,A itemDA6.update(item)

Section B$ org'dspace'core'=onte.t

e.ample #$ basic use

Conte#t c = null;
tr0
=
c = new Conte#t();
...
c.commit();
...
c.complete();
>
catch (S89!#ception s(le)
=
c.abort();
c = null;
log.warn(&conte#t aborted');
S0stem.err.println(&conte#t aborted'% s(le);
>

e.ample $ cache

conte#t.cache(ob:% id);

conte#t.cache(ob:% id);
ob0ect to cache
uni-ue identifier 3int4

conte#t.cache(ob:% id);
7oo ob: = (7oo) conte#t.3romCache(7oo.class% id);

7oo ob: = (7oo) conte#t.3romCache(7oo.class% id);
once an ob0ect is cached, %e can retrieve
it from memor+ if %e &no% the id

conte#t.cache(ob:% id);
7oo ob: = (7oo) conte#t.3romCache(7oo.class% id);
conte#t.remo-eCached(ob:% id);

conte#t.remo-eCached(ob:% id);
clean up after +ourself $4

conte#t.cache(ob:% id);
7oo ob: = (7oo) conte#t.3romCache(7oo.class% id);
conte#t.remo-eCached(ob:% id);
conte#t.clearCache();

conte#t.clearCache();
clean up after others $4

conte#t.cache(ob:% id);
7oo ob: = (7oo) conte#t.3romCache(7oo.class% id);
conte#t.remo-eCached(ob:% id);
conte#t.clearCache();

cache tips$
, al%a+s inspect cache before reading from data store
, don2t cache unnecessaril+

than&s
%i&i'dspace'org(=ategor+$C91*9
%i&i'dspace'org(Guide8to8Developing8%ith8DSpace
dspace,develDlists'sourceforge'net

S-ar putea să vă placă și