1 23 24 package org.infoglue.cms.applications.publishingtool.actions; 25 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 import org.infoglue.cms.controllers.kernel.impl.simple.EventController; 30 import org.infoglue.cms.controllers.kernel.impl.simple.PublicationController; 31 import org.infoglue.cms.entities.publishing.PublicationVO; 32 import org.infoglue.cms.entities.workflow.EventVO; 33 import org.infoglue.cms.exception.SystemException; 34 import org.infoglue.cms.util.ConstraintExceptionBuffer; 35 import org.infoglue.cms.util.validators.ConstraintRule; 36 37 public class CreateEditionAction extends ViewPublicationsAction 38 { 39 40 private PublicationVO publicationVO; 41 private ConstraintExceptionBuffer ceb; 42 private String name; 43 private String description; 44 private List events; 45 46 public CreateEditionAction() 47 { 48 this(new PublicationVO()); 49 } 50 51 public CreateEditionAction(PublicationVO publicationVO) 52 { 53 this.publicationVO = publicationVO; 54 this.ceb = new ConstraintExceptionBuffer(); 55 56 } 57 58 public ConstraintRule getRule(String fieldName) 59 { 60 return publicationVO.getRule(fieldName); 61 } 62 63 public java.lang.String getName() 64 { 65 if(this.name != null) 66 return this.name; 67 68 return this.publicationVO.getName(); 69 } 70 71 public void setName(java.lang.String name) 72 { 73 this.publicationVO.setName(name); 74 } 75 76 77 public String getDescription() 78 { 79 if(this.description != null) 80 return this.description; 81 82 return this.publicationVO.getDescription(); 83 } 84 85 public void setDescription(String description) 86 { 87 this.publicationVO.setDescription(description); 88 } 89 90 public List getEvents() 91 { 92 return this.events; 93 } 94 95 public String doExecute() throws Exception 96 { 97 this.publicationVO.setRepositoryId(getRepositoryId()); 98 99 ceb = this.publicationVO.validate(); 100 101 setEvents(getRequest().getParameterValues("sel")); 103 104 109 ceb.throwIfNotEmpty(); 110 111 this.publicationVO = PublicationController.getController().createAndPublish(this.publicationVO, events, false, this.getInfoGluePrincipal()); 112 113 return "success"; 114 } 115 116 public String doInput() throws Exception 117 { 118 this.publicationVO.PrepareValidation(); 119 setEvents(getRequest().getParameterValues("sel")); 120 return "input"; 125 } 126 127 128 private void setEvents(String [] eventArguments) throws SystemException, Exception 129 { 130 List events = new ArrayList (); 131 132 for(int i=0; i < eventArguments.length; i++) 133 { 134 EventVO eventVO = EventController.getEventVOWithId(new Integer (eventArguments[i])); 135 events.add(eventVO); 136 } 137 138 this.events = events; 139 } 140 141 } 142 | Popular Tags |