Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example

Old Form

New Form

WorkspaceItem Example

Code Block
Context context = new Context();
WorkspaceItem wi = WorkspaceItem.create(context, col, true);
context.commit();
Code Block
DSpace dspace = new DSpace();
Workspace ws = dspace.getSingletonService(Workspace.class);
WorkspaceItem workspaceItem = ws.create(col, true);

// Create Item in someone elses workspace
// ws.create(col, eperson, true);

WorkflowManager Example

Code Block
Context context = new Context();
WorkflowManager.start(context, wi);
context.commit();


Code Block
DSpace dspace = new DSpace();
Workflow workflow = dspace.getSingletonService(Workflow.class)
workflow.start(wi);

// Starting workflow for another user
// workflow.start(wi, eperson);

Collection Edit Example

Code Block
Context context = new Context();
Collection col = Collection.find(context, id);
col.setName("Some text.");
col.update();
context.commit();


Code Block
DSpace dspace = new DSpace();
CollectionService cs = dspace.getSingletonService(CollectionService.class);
Collection col = cs.find(id);
col.setName("Some text");
cs.update(col);

 

  



End of Context?!

I the above examples, it clear that the context object has been dropped and replaced with a new object called "DSpace", note that "DSpace" is the entry point into all Services that interact with the DSpace Domain model, Services apply to one or more levels of the Application Stack:

  • Persistence Tier: Services can be provided that interact with the storage level, these services will be aggregated together to form a solution for persistence of the Domain model into one or more alternative storage platforms.
  • Domain Services Tier:  Expose Domain Model Objects and provide Business Services that can perform important actions abstracted from both the Persistence and Presentation Tiers.
  • Presentation Tier: One or more "Applications" responsible for receiving requests from clients and controlling presentation of results.

The Legacy DSpace Context, is now internalized, stored within the DSpace request and provided via a Legacy Context Service when applications still require direct acces to it.  It is no longer the responsibility of the Application developer to track the context and its state, any open context will be committed or aborted at the end of the cycle for the current application request.

However, if the application developer does need access to the context for legacy purposes, it will be available via the Service manager.

Code Block
public interface IContextService {

     public IContext getCurrentContext();

}
Code Block

DSpace dspace = new DSpace();
Context context = dspace.getSingletonService(IContextService.class).getCurrentContext();

API Contracts for the DSpace Domain Model

...