cmssecure.java
来自「找了很久才找到到源代码」· Java 代码 · 共 471 行 · 第 1/2 页
JAVA
471 行
if (CmsStringUtil.isNotEmpty(folderPropVal)) {
return key(Messages.GUI_SECURE_INHERIT_FROM_2, new Object[] {folderPropVal, folderName});
} else {
return key(Messages.GUI_SECURE_NOT_SET_0);
}
}
/**
* Returns the path under which the resource is accessible.<p>
*
* @return the path under which the resource is accessible
*/
public String getResourceUrl() {
return OpenCms.getLinkManager().getOnlineLink(getCms(), getParamResource());
}
/**
* Returns true if the export user has read permission on a specified resource.<p>
*
* @return true, if the export user has the permission to read the resource
*/
public boolean exportUserHasReadPermission() {
String vfsName = getParamResource();
CmsObject cms = getCms();
try {
// static export must always be checked with the export users permissions,
// not the current users permissions
CmsObject exportCms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserExport());
exportCms.getRequestContext().setSiteRoot(getCms().getRequestContext().getSiteRoot());
// let's look up if the export user has the permission to read
return exportCms.hasPermissions(
cms.readResource(vfsName, CmsResourceFilter.IGNORE_EXPIRATION),
CmsPermissionSet.ACCESS_READ);
} catch (CmsException e) {
// ignore this exception
}
return false;
}
/**
* Returns value of the the intern property of the resource.<p>
*
* @return the value of the intern property of the resource
*/
public String readInternProp() {
boolean internProp = false;
try {
internProp = getCms().readResource(getParamResource(), CmsResourceFilter.IGNORE_EXPIRATION).isInternal();
} catch (CmsException e) {
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
return String.valueOf(internProp);
}
/**
* Returns value of the property of the resource.<p>
*
* @param propertyName the name of the property to read
*
* @return the value of the secure property of the resource
*/
public String readProperty(String propertyName) {
String propVal = null;
try {
propVal = getCms().readPropertyObject(getParamResource(), propertyName, false).getValue();
} catch (CmsException e) {
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
if (CmsStringUtil.isEmpty(propVal)) {
propVal = "";
}
return propVal;
}
/**
* returns if the resource to be changed is a folder.<p>
*
* @return true if the resource is a folder
*
* @throws CmsException if the reading of the resource fails
*/
public boolean resourceIsFolder() throws CmsException {
return getCms().readResource(getParamResource(), CmsResourceFilter.IGNORE_EXPIRATION).isFolder();
}
/**
* Sets the value of the export parameter.<p>
*
* @param value for the export parameter
*/
public void setParamExport(String value) {
m_paramExport = value;
}
/**
* Sets the value of the export name parameter.<p>
*
* @param value for the export name parameter
*/
public void setParamExportname(String value) {
m_paramExportname = value;
}
/**
* Sets the value of the intern parameter.<p>
*
* @param value for the intern parameter
*/
public void setParamIntern(String value) {
m_paramIntern = value;
}
/**
* Sets the value of the secure parameter.<p>
*
* @param value for the secure parameter
*/
public void setParamSecure(String value) {
m_paramSecure = value;
}
/**
* Determines whether to show the export settings dialog depending on the users settings.<p>
*
* @return true if dialogs should be shown, otherwise false
*/
public boolean showExportSettings() {
return getSettings().getUserSettings().getDialogShowExportSettings();
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// fill the parameter values in the get/set methods
fillParamValues(request);
// check the required permissions to change the resource properties
if (!checkResourcePermissions(CmsPermissionSet.ACCESS_WRITE, false)) {
// no write permissions for the resource, set cancel action to close dialog
setParamAction(DIALOG_CANCEL);
}
// set the dialog type
setParamDialogtype(DIALOG_TYPE);
// set the action for the JSP switch
if (DIALOG_TYPE.equals(getParamAction())) {
setAction(ACTION_CHSECEXP);
} else if (DIALOG_LOCKS_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_LOCKS_CONFIRMED);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else {
setAction(ACTION_DEFAULT);
// build title for chnav dialog
setParamTitle(key(
Messages.GUI_SECURE_EXPORT_RESOURCE_1,
new Object[] {CmsResource.getName(getParamResource())}));
}
}
/**
* Writes a property value for a resource.<p>
*
* @param propertyName the name of the property
* @param propertyValue the new value of the property
*
* @throws CmsException if something goes wrong
*/
protected void writeProperty(String propertyName, String propertyValue) throws CmsException {
if (CmsStringUtil.isEmpty(propertyValue)) {
propertyValue = CmsProperty.DELETE_VALUE;
}
CmsProperty newProp = new CmsProperty();
newProp.setName(propertyName);
CmsProperty oldProp = getCms().readPropertyObject(getParamResource(), propertyName, false);
if (oldProp.isNullProperty()) {
// property value was not already set
if (OpenCms.getWorkplaceManager().isDefaultPropertiesOnStructure()) {
newProp.setStructureValue(propertyValue);
} else {
newProp.setResourceValue(propertyValue);
}
} else {
if (oldProp.getStructureValue() != null) {
newProp.setStructureValue(propertyValue);
newProp.setResourceValue(oldProp.getResourceValue());
} else {
newProp.setResourceValue(propertyValue);
}
}
newProp.setAutoCreatePropertyDefinition(true);
String oldStructureValue = oldProp.getStructureValue();
String newStructureValue = newProp.getStructureValue();
if (CmsStringUtil.isEmpty(oldStructureValue)) {
oldStructureValue = CmsProperty.DELETE_VALUE;
}
if (CmsStringUtil.isEmpty(newStructureValue)) {
newStructureValue = CmsProperty.DELETE_VALUE;
}
String oldResourceValue = oldProp.getResourceValue();
String newResourceValue = newProp.getResourceValue();
if (CmsStringUtil.isEmpty(oldResourceValue)) {
oldResourceValue = CmsProperty.DELETE_VALUE;
}
if (CmsStringUtil.isEmpty(newResourceValue)) {
newResourceValue = CmsProperty.DELETE_VALUE;
}
// change property only if it has been changed
if (!oldResourceValue.equals(newResourceValue) || !oldStructureValue.equals(newStructureValue)) {
getCms().writePropertyObject(getParamResource(), newProp);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?