Guest User

Untitled

a guest
Apr 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. /**
  2.  *
  3.  */
  4. package pl.doa.blog.services;
  5.  
  6. import java.util.Date;
  7.  
  8. import pl.doa.GeneralDOAException;
  9. import pl.doa.container.IEntitiesContainer;
  10. import pl.doa.document.IDocument;
  11. import pl.doa.service.AbstractServiceDefinitionLogic;
  12. import pl.doa.service.annotation.EntityRef;
  13.  
  14. /**
  15.  * @author activey
  16.  *
  17.  */
  18. public class CreateEntryService extends AbstractServiceDefinitionLogic {
  19.  
  20.     @EntityRef(location = "/applications/doa-blog/entries")
  21.     private IEntitiesContainer entriesContainer;
  22.    
  23.     /* (non-Javadoc)
  24.      * @see pl.doa.service.AbstractServiceDefinitionLogic#align()
  25.      */
  26.     @Override
  27.     public void align() throws GeneralDOAException {       
  28.         if (entriesContainer == null) {
  29.             throw new GeneralDOAException("Unable to find entries container!");
  30.         }
  31.         IDocument input = getInput();
  32.         input.setFieldValue("created", new Date());
  33.         entriesContainer.addEntity(input);
  34.  
  35.         IDocument output =
  36.                 getPossibleOutputDefinition("createEntryOutput")
  37.                         .createDocumentInstance();
  38.         output.setFieldValue("createdEntryId", input.getId());
  39.         setOutput(output);
  40.     }
  41.  
  42. }
Add Comment
Please, Sign In to add comment