1 23 24 package org.infoglue.cms.applications.contenttool.actions; 25 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 import org.apache.log4j.Logger; 30 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController; 32 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy; 33 import org.infoglue.cms.controllers.kernel.impl.simple.RegistryController; 34 import org.infoglue.cms.entities.content.ContentVO; 35 36 41 42 public class DeleteContentAction extends InfoGlueAbstractAction 43 { 44 private final static Logger logger = Logger.getLogger(DeleteContentAction.class.getName()); 45 46 private static final long serialVersionUID = 1L; 47 48 private ContentVO contentVO; 49 private Integer parentContentId; 50 private Integer changeTypeId; 51 private String [] registryId; 52 53 private Integer siteNodeId; 55 56 private List referenceBeanList = new ArrayList (); 57 58 public DeleteContentAction() 59 { 60 this(new ContentVO()); 61 } 62 63 public DeleteContentAction(ContentVO contentVO) 64 { 65 this.contentVO = contentVO; 66 } 67 68 public String doExecute() throws Exception 69 { 70 this.referenceBeanList = RegistryController.getController().getReferencingObjectsForContent(this.contentVO.getContentId()); 71 if(this.referenceBeanList != null && this.referenceBeanList.size() > 0) 72 { 73 return "showRelations"; 74 } 75 else 76 { 77 try 78 { 79 this.parentContentId = ContentController.getParentContent(this.contentVO.getContentId()).getContentId(); 80 } 81 catch(Exception e) 82 { 83 logger.info("The content must have been a root-content because we could not find a parent."); 84 } 85 86 ContentControllerProxy.getController().acDelete(this.getInfoGluePrincipal(), this.contentVO); 87 88 return "success"; 89 } 90 } 91 92 public String doStandalone() throws Exception 93 { 94 this.referenceBeanList = RegistryController.getController().getReferencingObjectsForContent(this.contentVO.getContentId()); 95 if(this.referenceBeanList != null && this.referenceBeanList.size() > 0) 96 { 97 return "showRelations"; 98 } 99 else 100 { 101 try 102 { 103 this.parentContentId = ContentController.getParentContent(this.contentVO.getContentId()).getContentId(); 104 } 105 catch(Exception e) 106 { 107 logger.info("The content must have been a root-content because we could not find a parent."); 108 } 109 110 ContentControllerProxy.getController().acDelete(this.getInfoGluePrincipal(), this.contentVO); 111 112 return "successStandalone"; 113 } 114 } 115 116 public String doDeleteReference() throws Exception 117 { 118 for(int i=0; i<registryId.length; i++) 119 RegistryController.getController().delete(new Integer (registryId[i])); 120 121 return doExecute(); 122 } 123 124 public String doFixPage() throws Exception 125 { 126 return "fixPage"; 127 } 128 129 public String doFixPageHeader() throws Exception 130 { 131 return "fixPageHeader"; 132 } 133 134 public void setContentId(Integer contentId) 135 { 136 this.contentVO.setContentId(contentId); 137 } 138 139 public void setParentContentId(Integer parentContentId) 140 { 141 this.parentContentId = parentContentId; 142 } 143 144 public void setChangeTypeId(Integer changeTypeId) 145 { 146 this.changeTypeId = changeTypeId; 147 } 148 149 public Integer getContentId() 150 { 151 return this.parentContentId; 152 } 153 154 public Integer getOriginalContentId() 155 { 156 return this.contentVO.getContentId(); 157 } 158 159 public Integer getUnrefreshedContentId() 160 { 161 return this.parentContentId; 162 } 163 164 public Integer getChangeTypeId() 165 { 166 return this.changeTypeId; 167 } 168 169 public String getErrorKey() 170 { 171 return "ContentVersion.stateId"; 172 } 173 174 public String getReturnAddress() 175 { 176 return "ViewContent.action?contentId=" + this.contentVO.getId() + "&repositoryId=" + this.contentVO.getRepositoryId(); 177 } 178 179 public List getReferenceBeanList() 180 { 181 return referenceBeanList; 182 } 183 184 public Integer getSiteNodeId() 185 { 186 return siteNodeId; 187 } 188 189 public void setSiteNodeId(Integer siteNodeId) 190 { 191 this.siteNodeId = siteNodeId; 192 } 193 194 public String [] getRegistryId() 195 { 196 return registryId; 197 } 198 199 public void setRegistryId(String [] registryId) 200 { 201 this.registryId = registryId; 202 } 203 } 204 | Popular Tags |