1 23 24 package org.infoglue.cms.applications.publishingtool.actions; 25 26 import java.util.ArrayList ; 27 import java.util.HashMap ; 28 import java.util.List ; 29 30 import org.apache.log4j.Logger; 31 import org.infoglue.cms.applications.common.ImageButton; 32 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction; 33 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController; 34 import org.infoglue.cms.entities.management.RepositoryVO; 35 import org.infoglue.cms.util.CmsPropertyHandler; 36 37 42 43 public class ViewPublishingToolToolBarAction extends InfoGlueAbstractAction 44 { 45 private final static Logger logger = Logger.getLogger(ViewPublishingToolToolBarAction.class.getName()); 46 47 private static final long serialVersionUID = 1L; 48 49 private String title = ""; 50 private String name = ""; 51 private String toolbarKey = ""; 52 private String url = ""; 53 54 private Integer repositoryId = null; 56 private Integer systemUserId = null; 57 private Integer roleId = null; 58 private Integer languageId = null; 59 private Integer functionId = null; 60 private Integer serviceDefinitionId = null; 61 private Integer availableServiceBindingId = null; 62 private Integer siteNodeTypeDefinitionId = null; 63 64 private static HashMap buttonsMap = new HashMap (); 65 66 public String doExecute() throws Exception 67 { 68 return "success"; 69 } 70 71 public Integer getRepositoryId() 72 { 73 return this.repositoryId; 74 } 75 76 public void setRepositoryId(Integer repositoryId) 77 { 78 this.repositoryId = repositoryId; 79 } 80 81 public Integer getSystemUserId() 82 { 83 return this.systemUserId; 84 } 85 86 public void setSystemUserId(Integer systemUserId) 87 { 88 this.systemUserId = systemUserId; 89 } 90 91 public Integer getLanguageId() 92 { 93 return this.languageId; 94 } 95 96 public void setLanguageId(Integer languageId) 97 { 98 this.languageId = languageId; 99 } 100 101 public Integer getRoleId() 102 { 103 return this.roleId; 104 } 105 106 public void setRoleId(Integer roleId) 107 { 108 this.roleId = roleId; 109 } 110 111 public Integer getFunctionId() 112 { 113 return this.functionId; 114 } 115 116 public void setFunctionId(Integer functionId) 117 { 118 this.functionId = functionId; 119 } 120 121 public Integer getServiceDefinitionId() 122 { 123 return this.serviceDefinitionId; 124 } 125 126 public void setServiceDefinitionId(Integer serviceDefinitionId) 127 { 128 this.serviceDefinitionId = serviceDefinitionId; 129 } 130 131 public Integer getAvailableServiceBindingId() 132 { 133 return this.availableServiceBindingId; 134 } 135 136 public void setAvailableServiceBindingId(Integer availableServiceBindingId) 137 { 138 this.availableServiceBindingId = availableServiceBindingId; 139 } 140 141 public Integer getSiteNodeTypeDefinitionId() 142 { 143 return this.siteNodeTypeDefinitionId; 144 } 145 146 public void setSiteNodeTypeDefinitionId(Integer siteNodeTypeDefinitionId) 147 { 148 this.siteNodeTypeDefinitionId = siteNodeTypeDefinitionId; 149 } 150 151 public String getTitle() 152 { 153 return this.title; 154 } 155 156 public void setTitle(String title) 157 { 158 this.title = title; 159 } 160 161 public String getName() 162 { 163 return this.name; 164 } 165 166 public void setName(String name) 167 { 168 this.name = name; 169 } 170 171 public String getToolbarKey() 172 { 173 return this.toolbarKey; 174 } 175 176 public void setToolbarKey(String toolbarKey) 177 { 178 this.toolbarKey = toolbarKey; 179 } 180 181 public void setUrl(String url) 182 { 183 this.url = url; 184 } 185 186 public String getUrl() 187 { 188 return this.url; 189 } 190 191 public List getButtons() 192 { 193 logger.info("Title:" + this.title); 194 195 if(this.toolbarKey.equalsIgnoreCase("publications")) 196 return getPublicationsButtons(); 197 198 return null; 199 } 200 201 202 private List getPublicationsButtons() 203 { 204 List buttons = new ArrayList (); 205 buttons.add(new ImageButton(true, "javascript:submitToPreview();", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.previewContent"), "tool.publishtool.preview.header", "Preview marked versions")); 206 buttons.add(new ImageButton(true, "javascript:submitToCreate();", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.createEdition"), "tool.publishtool.createEdition.header", "Create a new edition of the marked versions")); 207 buttons.add(new ImageButton(true, "javascript:submitToUnpublish('publication');", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.unpublishEdition"), "tool.publishtool.unpublishEdition.header", "Unpublish the marked edition and send the versions back to publishable state")); 208 buttons.add(new ImageButton(true, "javascript:submitToDeny();", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.denyPublishing"), "tool.publishtool.denyPublication.header", "Deny the checked items from publication")); 209 210 try 211 { 212 RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(this.repositoryId); 213 214 String repositoryName = repositoryVO.getName(); 215 String dnsName = repositoryVO.getDnsName(); 216 217 String previewUrl = null; 218 219 String keyword = "preview="; 220 int startIndex = (dnsName == null) ? -1 : dnsName.indexOf(keyword); 221 if(startIndex != -1) 222 { 223 int endIndex = dnsName.indexOf(",", startIndex); 224 if(endIndex > -1) 225 dnsName = dnsName.substring(startIndex, endIndex); 226 else 227 dnsName = dnsName.substring(startIndex); 228 229 previewUrl = dnsName.split("=")[1] + CmsPropertyHandler.getComponentRendererUrl().replaceAll("Working", "Preview") + "ViewPage.action"; 230 } 231 else 232 { 233 previewUrl = CmsPropertyHandler.getStagingDeliveryUrl(); 234 } 235 236 buttons.add(new ImageButton(true, "javascript:openPopup('" + previewUrl + "?repositoryName=" + repositoryName + "', 'StagingPreview', 'width=800,height=600,resizable=yes,toolbar=yes,scrollbars=yes,status=yes,location=yes,menubar=yes');", getLocalizedString(getSession().getLocale(), "images.publishingtool.buttons.previewEnvironment"), "tool.publishtool.previewEnvironment.header")); 237 } 238 catch(Exception e) 239 { 240 e.printStackTrace(); 241 } 242 243 return buttons; 244 } 245 246 247 } 248 | Popular Tags |