1 31 32 package org.opencms.workplace.commons; 33 34 import org.opencms.file.CmsFile; 35 import org.opencms.file.CmsResource; 36 import org.opencms.i18n.CmsEncoder; 37 import org.opencms.jsp.CmsJspActionElement; 38 import org.opencms.security.CmsPermissionSet; 39 import org.opencms.util.CmsStringUtil; 40 import org.opencms.workplace.CmsDialog; 41 import org.opencms.workplace.CmsWorkplaceSettings; 42 43 import javax.servlet.http.HttpServletRequest ; 44 import javax.servlet.http.HttpServletResponse ; 45 import javax.servlet.jsp.JspException ; 46 import javax.servlet.jsp.PageContext ; 47 48 63 public class CmsEditPointer extends CmsDialog { 64 65 66 public static final String DIALOG_TYPE = "newlink"; 67 68 69 public static final String PARAM_LINKTARGET = "linktarget"; 70 71 72 private String m_paramLinkTarget; 73 74 79 public CmsEditPointer(CmsJspActionElement jsp) { 80 81 super(jsp); 82 } 83 84 91 public CmsEditPointer(PageContext context, HttpServletRequest req, HttpServletResponse res) { 92 93 this(new CmsJspActionElement(context, req, res)); 94 } 95 96 101 public void actionChangeLinkTarget() throws JspException { 102 103 try { 104 checkLock(getParamResource()); 106 CmsFile editFile = getCms().readFile(getParamResource()); 108 editFile.setContents(getParamLinkTarget().getBytes()); 109 getCms().writeFile(editFile); 110 actionCloseDialog(); 112 } catch (Throwable e) { 113 setParamMessage(Messages.get().getBundle(getLocale()).key(Messages.ERR_CHANGE_LINK_TARGET_0)); 115 includeErrorpage(this, e); 116 } 117 } 118 119 126 public String getOldTargetValue() throws JspException { 127 128 String linkTarget = ""; 129 if (CmsStringUtil.isEmpty(getParamLinkTarget())) { 130 try { 132 CmsFile file = getCms().readFile(getParamResource()); 134 linkTarget = new String (file.getContents()); 135 } catch (Throwable e1) { 136 setParamMessage(Messages.get().getBundle(getLocale()).key( 138 Messages.ERR_GET_LINK_TARGET_1, 139 getParamResource())); 140 includeErrorpage(this, e1); 141 142 } 143 } 144 return CmsEncoder.escapeXml(linkTarget); 145 } 146 147 152 public String getParamLinkTarget() { 153 154 return m_paramLinkTarget; 155 } 156 157 162 public void setParamLinkTarget(String linkTarget) { 163 164 m_paramLinkTarget = linkTarget; 165 } 166 167 170 protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { 171 172 fillParamValues(request); 174 175 if (! checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) { 177 setParamAction(DIALOG_CANCEL); 179 } 180 181 setParamDialogtype(DIALOG_TYPE); 183 if (DIALOG_OK.equals(getParamAction())) { 185 setAction(ACTION_OK); 187 } else if (DIALOG_CANCEL.equals(getParamAction())) { 188 setAction(ACTION_CANCEL); 190 } else { 191 setAction(ACTION_DEFAULT); 193 setParamTitle(key(Messages.GUI_CHLINK_1, new Object [] {CmsResource.getName(getParamResource())})); 195 } 196 } 197 198 } 199 | Popular Tags |