1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import java.util.HashMap ; 27 import java.util.List ; 28 import java.util.Map ; 29 30 import org.apache.log4j.Logger; 31 import org.infoglue.cms.applications.common.actions.InfoGluePropertiesAbstractAction; 32 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 33 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 34 import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController; 35 import org.infoglue.cms.entities.content.ContentVO; 36 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO; 37 38 import com.opensymphony.module.propertyset.PropertySet; 39 import com.opensymphony.module.propertyset.PropertySetManager; 40 41 47 48 public class ViewContentPropertiesAction extends InfoGluePropertiesAbstractAction 49 { 50 private final static Logger logger = Logger.getLogger(ViewContentPropertiesAction.class.getName()); 51 52 private static final long serialVersionUID = 1L; 53 54 private ContentVO contentVO = new ContentVO(); 55 private PropertySet propertySet = null; 56 private List contentTypeDefinitionVOList = null; 57 private List languageVOList = null; 58 59 private String allowedContentTypeNames = null; 60 private String defaultContentTypeName = null; 61 private String initialLanguageId = null; 62 63 public ViewContentPropertiesAction() 64 { 65 } 66 67 protected void initialize(Integer contentId) throws Exception 68 { 69 this.contentVO = ContentController.getContentController().getContentVOWithId(contentId); 70 this.contentTypeDefinitionVOList = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOList(ContentTypeDefinitionVO.CONTENT); 71 this.languageVOList = LanguageController.getController().getLanguageVOList(this.contentVO.getRepositoryId()); 72 73 Map args = new HashMap (); 74 args.put("globalKey", "infoglue"); 75 PropertySet ps = PropertySetManager.getInstance("jdbc", args); 76 77 if ( ps.exists("content_" + this.getContentId() + "_allowedContentTypeNames" ) ) 78 { 79 this.allowedContentTypeNames = ps.getString("content_" + this.getContentId() + "_allowedContentTypeNames"); 80 } 81 this.defaultContentTypeName = ps.getString("content_" + this.getContentId() + "_defaultContentTypeName"); 82 this.initialLanguageId = ps.getString("content_" + this.getContentId() + "_initialLanguageId"); 83 logger.info("allowedContentTypeNames:" + allowedContentTypeNames); 84 logger.info("defaultContentTypeName:" + defaultContentTypeName); 85 logger.info("initialLanguageId:" + initialLanguageId); 86 } 87 88 91 92 public String doExecute() throws Exception 93 { 94 this.initialize(getContentId()); 95 96 return "success"; 97 } 98 99 102 103 public String doSave() throws Exception 104 { 105 String allowedContentTypeNames = null; 106 String [] allowedContentTypeNameArray = getRequest().getParameterValues("allowedContentTypeName"); 107 if(allowedContentTypeNameArray != null) 108 { 109 logger.info("allowedContentTypeNameArray:" + allowedContentTypeNameArray); 110 allowedContentTypeNames = ""; 111 for(int i=0; i<allowedContentTypeNameArray.length; i++) 112 { 113 allowedContentTypeNames += allowedContentTypeNameArray[i] + ","; 114 } 115 } 116 117 Map args = new HashMap (); 118 args.put("globalKey", "infoglue"); 119 PropertySet ps = PropertySetManager.getInstance("jdbc", args); 120 121 if(allowedContentTypeNames != null ) 122 ps.setString("content_" + this.getContentId() + "_allowedContentTypeNames", allowedContentTypeNames); 123 if(defaultContentTypeName != null) 124 ps.setString("content_" + this.getContentId() + "_defaultContentTypeName", defaultContentTypeName); 125 if(initialLanguageId != null) 126 ps.setString("content_" + this.getContentId() + "_initialLanguageId", initialLanguageId); 127 128 return "save"; 129 } 130 131 134 135 public String doSaveAndExit() throws Exception 136 { 137 return "saveAndExit"; 138 } 139 140 public java.lang.Integer getContentId() 141 { 142 return this.contentVO.getContentId(); 143 } 144 145 public void setContentId(java.lang.Integer contentId) throws Exception 146 { 147 this.contentVO.setContentId(contentId); 148 } 149 150 public ContentVO getContentVO() 151 { 152 return contentVO; 153 } 154 155 public List getContentTypeDefinitionVOList() 156 { 157 return contentTypeDefinitionVOList; 158 } 159 160 public String getAllowedContentTypeNames() 161 { 162 return allowedContentTypeNames; 163 } 164 165 public String getDefaultContentTypeName() 166 { 167 return defaultContentTypeName; 168 } 169 170 public void setDefaultContentTypeName(String defaultContentTypeName) 171 { 172 this.defaultContentTypeName = defaultContentTypeName; 173 } 174 175 public List getLanguageVOList() 176 { 177 return languageVOList; 178 } 179 180 public String getInitialLanguageId() 181 { 182 return initialLanguageId; 183 } 184 185 public void setInitialLanguageId(String initialLanguageId) 186 { 187 this.initialLanguageId = initialLanguageId; 188 } 189 } 190 | Popular Tags |