1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import org.apache.log4j.Logger; 27 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionController; 28 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionControllerProxy; 29 import org.infoglue.cms.entities.content.ContentVersionVO; 30 import org.infoglue.cms.exception.ConstraintException; 31 import org.infoglue.cms.util.ConstraintExceptionBuffer; 32 33 38 39 public class UpdateContentVersionAction extends ViewContentVersionAction 40 { 41 private static final long serialVersionUID = 1L; 42 43 public final static Logger logger = Logger.getLogger(UpdateContentVersionAction.class.getName()); 44 45 private ContentVersionVO contentVersionVO; 46 private Integer contentId; 47 private Integer languageId; 48 private Integer contentVersionId; 49 private Integer currentEditorId; 50 private String attributeName; 51 private long oldModifiedDateTime = -1; 52 private boolean concurrentModification = false; 53 54 private ConstraintExceptionBuffer ceb; 55 56 public UpdateContentVersionAction() 57 { 58 this(new ContentVersionVO()); 59 } 60 61 public UpdateContentVersionAction(ContentVersionVO contentVersionVO) 62 { 63 this.contentVersionVO = contentVersionVO; 64 this.ceb = new ConstraintExceptionBuffer(); 65 } 66 67 public String doExecute() throws Exception  68 { 69 super.initialize(this.contentVersionId, this.contentId, this.languageId); 70 ceb.throwIfNotEmpty(); 71 72 ContentVersionVO currentContentVersionVO = null; 73 if(this.contentVersionVO.getId() != null) 74 { 75 currentContentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(this.contentVersionVO.getId()); 76 } 77 78 if(currentContentVersionVO != null) 79 { 80 logger.info("oldModifiedDateTime:" + oldModifiedDateTime); 81 logger.info("modifiedDateTime2:" + currentContentVersionVO.getModifiedDateTime().getTime()); 82 } 83 84 if(currentContentVersionVO == null || this.oldModifiedDateTime == currentContentVersionVO.getModifiedDateTime().getTime()) 85 { 86 this.contentVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName()); 87 88 try 89 { 90 this.contentVersionVO = ContentVersionControllerProxy.getController().acUpdate(this.getInfoGluePrincipal(), this.contentId, this.languageId, this.contentVersionVO); 91 this.oldModifiedDateTime = this.contentVersionVO.getModifiedDateTime().getTime(); 92 } 93 catch(ConstraintException ce) 94 { 95 super.contentVersionVO = this.contentVersionVO; 96 throw ce; 97 } 98 } 99 else 100 { 101 this.contentVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName()); 102 super.contentVersionVO = this.contentVersionVO; 103 108 concurrentModification = true; 109 } 110 111 return "success"; 112 } 113 114 public String doStandalone() throws Exception  115 { 116 super.initialize(this.contentVersionId, this.contentId, this.languageId); 117 ceb.throwIfNotEmpty(); 118 119 this.contentVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName()); 120 this.contentVersionVO = ContentVersionControllerProxy.getController().acUpdate(this.getInfoGluePrincipal(), this.contentId, this.languageId, this.contentVersionVO); 121 122 return "standalone"; 123 } 124 125 public String doSaveAndExit() throws Exception  126 { 127 doExecute(); 128 129 return "saveAndExit"; 130 } 131 132 public String doSaveAndExitStandalone() throws Exception  133 { 134 doExecute(); 135 136 return "saveAndExitStandalone"; 137 } 138 139 public String doBackground() throws Exception  140 { 141 doExecute(); 142 143 return "background"; 144 } 145 146 public void setContentVersionId(Integer contentVersionId) 147 { 148 this.contentVersionVO.setContentVersionId(contentVersionId); 149 } 150 151 public java.lang.Integer getContentVersionId() 152 { 153 return this.contentVersionVO.getContentVersionId(); 154 } 155 156 public void setStateId(Integer stateId) 157 { 158 this.contentVersionVO.setStateId(stateId); 159 } 160 161 public java.lang.Integer getStateId() 162 { 163 return this.contentVersionVO.getStateId(); 164 } 165 166 public void setContentId(Integer contentId) 167 { 168 this.contentId = contentId; 169 } 170 171 public java.lang.Integer getContentId() 172 { 173 return this.contentId; 174 } 175 176 public void setLanguageId(Integer languageId) 177 { 178 this.languageId = languageId; 179 } 180 181 public java.lang.Integer getLanguageId() 182 { 183 return this.languageId; 184 } 185 186 public java.lang.String getVersionValue() 187 { 188 return this.contentVersionVO.getVersionValue(); 189 } 190 191 public void setVersionValue(java.lang.String versionValue) 192 { 193 this.contentVersionVO.setVersionValue(versionValue); 194 } 195 196 public Integer getCurrentEditorId() 197 { 198 return currentEditorId; 199 } 200 201 public void setCurrentEditorId(Integer integer) 202 { 203 currentEditorId = integer; 204 } 205 206 public String getAttributeName() 207 { 208 return this.attributeName; 209 } 210 211 public String getVersionComment() 212 { 213 return this.contentVersionVO.getVersionComment(); 214 } 215 216 public void setAttributeName(String attributeName) 217 { 218 this.attributeName = attributeName; 219 } 220 221 public long getOldModifiedDateTime() 222 { 223 return oldModifiedDateTime; 224 } 225 226 public void setOldModifiedDateTime(long oldModifiedDateTime) 227 { 228 this.oldModifiedDateTime = oldModifiedDateTime; 229 } 230 231 public boolean getConcurrentModification() 232 { 233 return concurrentModification; 234 } 235 236 } 237 | Popular Tags |