1 23 24 package org.infoglue.cms.applications.managementtool.actions; 25 26 import java.net.URLEncoder ; 27 import java.util.Collections ; 28 import java.util.List ; 29 30 import org.apache.log4j.Logger; 31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController; 32 import org.infoglue.cms.controllers.kernel.impl.simple.GroupControllerProxy; 33 import org.infoglue.cms.controllers.kernel.impl.simple.GroupPropertiesController; 34 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO; 35 import org.infoglue.cms.entities.management.GroupProperties; 36 import org.infoglue.cms.entities.management.GroupPropertiesVO; 37 import org.infoglue.cms.security.InfoGlueGroup; 38 import org.infoglue.cms.util.CmsPropertyHandler; 39 40 public class ViewGroupPropertiesAction extends ViewEntityPropertiesAction 41 { 42 private final static Logger logger = Logger.getLogger(ViewGroupPropertiesAction.class.getName()); 43 44 private static final long serialVersionUID = 1L; 45 46 private String groupName; 47 private GroupPropertiesVO groupPropertiesVO; 48 private List groupPropertiesVOList; 49 50 51 public ViewGroupPropertiesAction() 52 { 53 this.setCurrentAction("ViewGroupProperties.action"); 54 this.setUpdateAction("UpdateGroupProperties"); 55 this.setCancelAction("ViewGroup.action"); 56 this.setToolbarKey("tool.managementtool.viewGroupProperties.header"); 57 this.setTitleKey("tool.managementtool.viewGroupProperties.header"); 58 this.setArguments(""); 59 this.setEntityName(GroupProperties.class.getName()); 60 } 61 62 67 68 protected void initialize(String groupName) throws Exception 69 { 70 super.initialize(); 71 72 logger.info("groupName:" + groupName); 73 74 List contentTypeDefinitionVOList = GroupPropertiesController.getController().getContentTypeDefinitionVOList(groupName); 75 if(contentTypeDefinitionVOList != null && contentTypeDefinitionVOList.size() > 0) 76 this.setContentTypeDefinitionVO((ContentTypeDefinitionVO)contentTypeDefinitionVOList.get(0)); 77 78 InfoGlueGroup infoGlueGroup = GroupControllerProxy.getController().getGroup(groupName); 79 groupPropertiesVOList = GroupPropertiesController.getController().getGroupPropertiesVOList(groupName, this.getLanguageId()); 80 if(groupPropertiesVOList != null && groupPropertiesVOList.size() > 0) 81 { 82 this.groupPropertiesVO = (GroupPropertiesVO)groupPropertiesVOList.get(0); 83 this.setContentTypeDefinitionId(this.groupPropertiesVO.getContentTypeDefinitionId()); 84 } 85 else 86 { 87 this.setContentTypeDefinitionId(this.getContentTypeDefinitionVO().getContentTypeDefinitionId()); 88 } 89 90 logger.info("this.groupPropertiesVO:" + this.groupPropertiesVO); 91 92 this.setAttributes(ContentTypeDefinitionController.getController().getContentTypeAttributes(this.getContentTypeDefinitionVO().getSchemaValue())); 93 94 logger.info("attributes:" + this.getContentTypeAttributes().size()); 95 logger.info("availableLanguages:" + this.getAvailableLanguages().size()); 96 97 } 98 99 public String doExecute() throws Exception 100 { 101 this.initialize(getGroupName()); 102 103 return "success"; 104 } 105 106 107 110 111 public List getDigitalAssets() 112 { 113 List digitalAssets = null; 114 115 try 116 { 117 if(this.groupPropertiesVO != null && this.groupPropertiesVO.getId() != null) 118 { 119 digitalAssets = GroupPropertiesController.getController().getDigitalAssetVOList(this.groupPropertiesVO.getId()); 120 } 121 } 122 catch(Exception e) 123 { 124 logger.warn("We could not fetch the list of digitalAssets: " + e.getMessage(), e); 125 } 126 127 return digitalAssets; 128 } 129 130 131 132 133 134 139 public List getRelatedCategories(String attribute) 140 { 141 try 142 { 143 if(this.groupPropertiesVO != null && this.groupPropertiesVO.getId() != null) 144 return getPropertiesCategoryController().findByPropertiesAttribute(attribute, GroupProperties.class.getName(), this.groupPropertiesVO.getId()); 145 } 146 catch(Exception e) 147 { 148 logger.warn("We could not fetch the list of defined category keys: " + e.getMessage(), e); 149 } 150 151 return Collections.EMPTY_LIST; 152 } 153 154 155 public String getXML() 156 { 157 return (this.groupPropertiesVO == null) ? null : this.groupPropertiesVO.getValue(); 158 } 159 160 161 public String getGroupName() 162 { 163 return groupName; 164 } 165 166 public GroupPropertiesVO getGroupPropertiesVO() 167 { 168 return groupPropertiesVO; 169 } 170 171 public List getGroupPropertiesVOList() 172 { 173 return groupPropertiesVOList; 174 } 175 176 public void setGroupName(String groupName) 177 { 178 this.groupName = groupName; 179 this.setOwnerEntityId(groupName); 180 } 181 182 public Integer getEntityId() 183 { 184 return this.groupPropertiesVO.getId(); 185 } 186 187 public void setOwnerEntityId(String ownerEntityId) 188 { 189 super.setOwnerEntityId(ownerEntityId); 190 this.groupName = ownerEntityId; 191 } 192 193 public String getReturnAddress() throws Exception 194 { 195 String URIEncoding = CmsPropertyHandler.getURIEncoding(); 196 return this.getCurrentAction() + "?groupName=" + URLEncoder.encode(this.groupName, URIEncoding) + "&languageId=" + this.getLanguageId(); 197 } 198 199 public String getCancelAddress() throws Exception 200 { 201 String URIEncoding = CmsPropertyHandler.getURIEncoding(); 202 return this.getCancelAction() + "?groupName=" + URLEncoder.encode(this.groupName, URIEncoding); 203 } 204 205 } 206 | Popular Tags |