1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import java.util.List ; 27 28 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 29 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 30 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionControllerProxy; 32 import org.infoglue.cms.entities.content.ContentVersionVO; 33 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO; 34 35 41 42 public class ViewContentVersionDifferenceAction extends InfoGlueAbstractAction 43 { 44 private static final long serialVersionUID = 1L; 45 46 private Integer contentVersionId1; 47 private Integer contentVersionId2; 48 49 private ContentVersionVO contentVersionVO1; 50 private ContentVersionVO contentVersionVO2; 51 52 public ContentTypeDefinitionVO contentTypeDefinitionVO; 53 54 public List attributes = null; 55 56 57 protected String doExecute() throws Exception 58 { 59 this.contentVersionVO1 = ContentVersionControllerProxy.getController().getACContentVersionVOWithId(this.getInfoGluePrincipal(), contentVersionId1); 60 this.contentVersionVO2 = ContentVersionControllerProxy.getController().getACContentVersionVOWithId(this.getInfoGluePrincipal(), contentVersionId2); 61 62 this.contentTypeDefinitionVO = ContentController.getContentController().getContentTypeDefinition(contentVersionVO2.getContentId()); 63 64 if(this.contentTypeDefinitionVO != null) 65 { 66 this.attributes = ContentTypeDefinitionController.getController().getContentTypeAttributes(this.contentTypeDefinitionVO.getSchemaValue()); 67 } 68 69 return "success"; 70 } 71 72 73 77 78 public String getUnescapedAttributeValue(ContentVersionVO contentVersionVO, String key) 79 { 80 String value = ""; 81 82 if(contentVersionVO != null) 83 { 84 try 85 { 86 String xml = contentVersionVO.getVersionValue(); 87 88 int startTagIndex = xml.indexOf("<" + key + ">"); 89 int endTagIndex = xml.indexOf("]]></" + key + ">"); 90 91 if(startTagIndex > 0 && startTagIndex < xml.length() && endTagIndex > startTagIndex && endTagIndex < xml.length()) 92 { 93 value = xml.substring(startTagIndex + key.length() + 11, endTagIndex); 94 } 95 } 96 catch(Exception e) 97 { 98 e.printStackTrace(); 99 } 100 } 101 return value; 103 } 104 105 106 public Integer getContentVersionId1() 107 { 108 return contentVersionId1; 109 } 110 111 public void setContentVersionId1(Integer contentVersionId1) 112 { 113 this.contentVersionId1 = contentVersionId1; 114 } 115 116 public Integer getContentVersionId2() 117 { 118 return contentVersionId2; 119 } 120 121 public void setContentVersionId2(Integer contentVersionId2) 122 { 123 this.contentVersionId2 = contentVersionId2; 124 } 125 126 public List getAttributes() 127 { 128 return attributes; 129 } 130 131 public ContentTypeDefinitionVO getContentTypeDefinitionVO() 132 { 133 return contentTypeDefinitionVO; 134 } 135 136 public ContentVersionVO getContentVersionVO1() 137 { 138 return contentVersionVO1; 139 } 140 141 public ContentVersionVO getContentVersionVO2() 142 { 143 return contentVersionVO2; 144 } 145 } 146 | Popular Tags |