1 23 24 package org.infoglue.cms.applications.contenttool.wizards.actions; 25 26 import java.net.URLEncoder ; 27 import java.util.ArrayList ; 28 import java.util.List ; 29 30 import org.infoglue.cms.applications.common.VisualFormatter; 31 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 32 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 33 import org.infoglue.cms.entities.content.ContentVO; 34 import org.infoglue.cms.util.ConstraintExceptionBuffer; 35 36 39 40 public class CreateContentWizardInputContentAction extends InfoGlueAbstractAction 41 { 42 private List contentTypeDefinitionVOList = new ArrayList (); 43 private String returnAddress; 44 private ContentVO contentVO; 45 private Integer contentTypeDefinitionId; 46 private ConstraintExceptionBuffer ceb; 47 48 private String [] allowedContentTypeIds = null; 49 50 51 public CreateContentWizardInputContentAction() 52 { 53 this(new ContentVO()); 54 } 55 56 public CreateContentWizardInputContentAction(ContentVO contentVO) 57 { 58 this.contentVO = contentVO; 59 this.ceb = new ConstraintExceptionBuffer(); 60 } 61 62 private void initialiaze() throws Exception 63 { 64 if(allowedContentTypeIds == null) 65 { 66 this.contentTypeDefinitionVOList = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList(); 67 } 68 else 69 { 70 for(int i=0; i < allowedContentTypeIds.length; i++) 71 { 72 String allowedContentTypeDefinitionIdString = allowedContentTypeIds[i]; 73 this.contentTypeDefinitionVOList.add(ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(new Integer (allowedContentTypeDefinitionIdString))); 74 } 75 } 76 } 77 78 84 85 public String doInput() throws Exception 86 { 87 initialiaze(); 88 return "input"; 89 } 90 91 97 98 public String doExecute() throws Exception 99 { 100 this.contentVO.setCreatorName(this.getInfoGluePrincipal().getName()); 101 102 ceb = this.contentVO.validate(); 103 104 if(!ceb.isEmpty()) 105 initialiaze(); 106 107 ceb.throwIfNotEmpty(); 108 109 return "success"; 110 } 111 112 115 116 public List getContentTypeDefinitions() throws Exception 117 { 118 return this.contentTypeDefinitionVOList; 119 } 120 121 public java.lang.String getName() 122 { 123 return this.contentVO.getName(); 124 } 125 126 public void setName(String name) 127 { 128 this.contentVO.setName(name); 129 } 130 131 public String getPublishDateTime() 132 { 133 return new VisualFormatter().formatDate(this.contentVO.getPublishDateTime(), "yyyy-MM-dd HH:mm"); 134 } 135 136 public void setPublishDateTime(String publishDateTime) 137 { 138 this.contentVO.setPublishDateTime(new VisualFormatter().parseDate(publishDateTime, "yyyy-MM-dd HH:mm")); 139 } 140 141 public String getExpireDateTime() 142 { 143 return new VisualFormatter().formatDate(this.contentVO.getExpireDateTime(), "yyyy-MM-dd HH:mm"); 144 } 145 146 public void setExpireDateTime(String expireDateTime) 147 { 148 this.contentVO.setExpireDateTime(new VisualFormatter().parseDate(expireDateTime, "yyyy-MM-dd HH:mm")); 149 } 150 151 public long getPublishDateTimeAsLong() 152 { 153 return this.contentVO.getPublishDateTime().getTime(); 154 } 155 156 public long getExpireDateTimeAsLong() 157 { 158 return this.contentVO.getExpireDateTime().getTime(); 159 } 160 161 public Boolean getIsBranch() 162 { 163 return this.contentVO.getIsBranch(); 164 } 165 166 public void setIsBranch(Boolean isBranch) 167 { 168 this.contentVO.setIsBranch(isBranch); 169 } 170 171 public Integer getContentTypeDefinitionId() 172 { 173 return this.contentTypeDefinitionId; 174 } 175 176 public void setContentTypeDefinitionId(Integer contentTypeDefinitionId) 177 { 178 this.contentTypeDefinitionId = contentTypeDefinitionId; 179 } 180 181 public String getReturnAddress() 182 { 183 return returnAddress; 184 } 185 186 public void setReturnAddress(String string) 187 { 188 returnAddress = string; 189 } 190 191 public String getAllowedContentTypeIdsAsUrlEncodedString() throws Exception 192 { 193 StringBuffer sb = new StringBuffer (); 194 195 for(int i=0; i<allowedContentTypeIds.length; i++) 196 { 197 if(i > 0) 198 sb.append("&"); 199 200 sb.append("allowedContentTypeIds=" + URLEncoder.encode(allowedContentTypeIds[i], "UTF-8")); 201 } 202 203 return sb.toString(); 204 } 205 206 public String [] getAllowedContentTypeIds() 207 { 208 return allowedContentTypeIds; 209 } 210 211 public void setAllowedContentTypeIds(String [] allowedContentTypeIds) 212 { 213 this.allowedContentTypeIds = allowedContentTypeIds; 214 } 215 216 } 217 | Popular Tags |