Page History
...
Warning |
---|
Always use the factories, never create an implementation by using its constructor. It will resolve compile issues but will crash when testing. |
Step 2: Integrate the services
The next step is to use the factories to resolve a lot of compilation issues, below are some examples:
Code Block | ||
---|---|---|
| ||
//Before AuthorizeServiceImpl.authorizeAction(context, item, Constants.READ); ///After authorizeService.authorizeAction(context, item, Constants.READ); //Before HandleServiceImpl.resolveToObject(context, handle); //After handleService.resolveToObject(context, handle); //Before item.canEdit(); //After (requires the item & a context, because the service is a singleton & doesn't hold a state the database object should always be passed) itemService.canEdit(context, item); //Before collection.canEditBoolean(true); //After (requires the collection & a context, because the service is a singleton & doesn't hold a state the database object should always be passed) collectionService.canEditBoolean(context, collection, true); //There could even be some other methods that now require an additional argument that didn't need it before: //Before xHTMLHeadCrosswalk.disseminateList(item); //After (requires a context) xHTMLHeadCrosswalk.disseminateList(context, item); |
Step 3: Fix the rest
As seen in the example above some of the services require additional arguments, depending on the method this could be a context, database object, .... A complete list of methods that have changed in this manner is available here DSpace Service based api: API Changelist
...
Code Block | ||
---|---|---|
| ||
//Before
Community[] parents = c.getCommunities();
request.setAttribute("dspace.community", parents[0])
//After
List<Community> parents = c.getCommunities();
request.setAttribute("dspace.community", parents.get(0))
... |
Info |
---|
Use the shortcuts of your idea to quickly traverse these issues |
Overview
Content Tools