📄 cmsavailability.java
字号:
* Sets the value of the leaveexpire parameter.<p>
*
* @param paramLeaveexpire the value of the leaveexpire parameter
*/
public void setParamLeaveexpire(String paramLeaveexpire) {
m_paramLeaveexpire = paramLeaveexpire;
}
/**
* Sets the value of the modify siblings parameter.<p>
*
* @param value the value to set
*/
public void setParamModifysiblings(String value) {
m_paramModifysiblings = value;
}
/**
* Sets the value of the new timestamp parameter.<p>
*
* @param value the value to set
*/
public void setParamNotificationinterval(String value) {
m_paramNotificationinterval = value;
}
/**
* Sets the value of the recursive parameter.<p>
*
* @param value the value to set
*/
public void setParamRecursive(String value) {
m_paramRecursive = value;
}
/**
* Sets the value of the releasedate parameter.<p>
*
* @param value the value to set
*/
public void setParamReleasedate(String value) {
m_paramReleasedate = value;
}
/**
* Sets the value of the resetexpire parameter.<p>
*
* @param paramResetexpire the value of the resetexpire parameter
*/
public void setParamResetexpire(String paramResetexpire) {
m_paramResetexpire = paramResetexpire;
}
/**
* Sets the value of the resetrelease parameter.<p>
*
* @param paramResetrelease the value of the resetrelease parameter
*/
public void setParamResetrelease(String paramResetrelease) {
m_paramResetrelease = paramResetrelease;
}
/**
* Returns a localized String for "Group", if the flag of a group ACE, and the localization for "User" otherwise.<p>
*
* @param flags the flags of the ACE
*
* @return localization for "Group", if the flag belongs to a group ACE
*/
protected String getLocalizedType(int flags) {
if ((flags & CmsAccessControlEntry.ACCESS_FLAGS_USER) > 0) {
return key(Messages.GUI_LABEL_USER_0);
} else {
return key(Messages.GUI_LABEL_GROUP_0);
}
}
/**
* @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 modify the resource
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_OK);
} else if (DIALOG_WAIT.equals(getParamAction())) {
setAction(ACTION_WAIT);
} 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 dialog
setDialogTitle(
Messages.GUI_AVAILABILITY_NOTIFICATION_SETTINGS_1,
Messages.GUI_AVAILABILITY_NOTIFICATION_MULTI_2);
}
}
/**
* Modifies the release and expire date of a resource, and changes the notification interval. <p>
*
* @return true, if the operation was performed, otherwise false
* @throws CmsException if modification is not successful
*/
protected boolean performDialogOperation() throws CmsException {
// check if the current resource is a folder for single operation
boolean isFolder = isOperationOnFolder();
// on folder deletion or multi operation display "please wait" screen, not for simple file deletion
if ((isMultiOperation() || isFolder) && !DIALOG_WAIT.equals(getParamAction())) {
// return false, this will trigger the "please wait" screen
return false;
}
// get the new release date for the resource(s) from request parameter
long releaseDate = CmsResource.DATE_RELEASED_DEFAULT;
boolean resetReleaseDate = Boolean.valueOf(getParamResetrelease()).booleanValue();
boolean leaveReleaseDate = false;
if (!resetReleaseDate) {
try {
if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamReleasedate()))
&& (!getParamReleasedate().startsWith(CmsTouch.DEFAULT_DATE_STRING))) {
releaseDate = CmsCalendarWidget.getCalendarDate(getMessages(), getParamReleasedate(), true);
} else {
leaveReleaseDate = true;
}
} catch (ParseException e) {
throw new CmsException(
Messages.get().container(Messages.ERR_PARSE_RELEASEDATE_1, getParamReleasedate()),
e);
}
}
// get the new expire date for the resource(s) from request parameter
long expireDate = CmsResource.DATE_EXPIRED_DEFAULT;
boolean resetExpireDate = Boolean.valueOf(getParamResetexpire()).booleanValue();
boolean leaveExpireDate = false;
if (!resetExpireDate) {
try {
if ((CmsStringUtil.isNotEmptyOrWhitespaceOnly(getParamExpiredate()))
&& (!getParamExpiredate().startsWith(CmsTouch.DEFAULT_DATE_STRING))) {
expireDate = CmsCalendarWidget.getCalendarDate(getMessages(), getParamExpiredate(), true);
} else {
leaveExpireDate = true;
}
} catch (ParseException e) {
throw new CmsException(
Messages.get().container(Messages.ERR_PARSE_EXPIREDATE_1, getParamExpiredate()),
e);
}
}
// get the flag if the operation is recursive from request parameter
boolean modifyRecursive = Boolean.valueOf(getParamRecursive()).booleanValue();
// get the flag if the operation should be executed on resource siblings, too
boolean modifySiblings = Boolean.valueOf(getParamModifysiblings()).booleanValue();
// now iterate the resource(s)
Iterator i = getResourceList().iterator();
while (i.hasNext()) {
String resName = (String)i.next();
try {
performSingleResource(
resName,
releaseDate,
expireDate,
leaveReleaseDate,
leaveExpireDate,
modifyRecursive,
modifySiblings);
} catch (CmsException e) {
// collect exceptions to create a detailed output
addMultiOperationException(e);
}
}
checkMultiOperationException(Messages.get(), Messages.ERR_AVAILABILITY_MULTI_0);
return true;
}
/**
* Performs the availability and notification operations on a single resource.<p>
*
* @param resName the VFS path of the resource
* @param releaseDate the new release date
* @param expireDate the new expiration date
* @param leaveRelease flag indicating if the release date should be left untouched
* @param leaveExpire flag indicating if the expiration date should be left untouched
* @param modifyRecursive flag indicating if the operation is recursive for folders
* @param modifySiblings flag indicating to include resource siblings
* @throws CmsException if the availability and notification operations fail
*/
protected void performSingleResource(
String resName,
long releaseDate,
long expireDate,
boolean leaveRelease,
boolean leaveExpire,
boolean modifyRecursive,
boolean modifySiblings) throws CmsException {
List resources = new ArrayList();
if (modifySiblings) {
// modify all siblings of a resource
resources = getCms().readSiblings(resName, CmsResourceFilter.IGNORE_EXPIRATION);
} else {
// modify only resource without siblings
resources.add(getCms().readResource(resName, CmsResourceFilter.IGNORE_EXPIRATION));
}
Iterator i = resources.iterator();
while (i.hasNext()) {
CmsResource resource = (CmsResource)i.next();
String resourcePath = getCms().getRequestContext().removeSiteRoot(resource.getRootPath());
// lock resource if autolock is enabled
checkLock(resourcePath);
if (!leaveRelease && !leaveExpire) {
if (expireDate < releaseDate) {
throw new CmsIllegalArgumentException(Messages.get().container(
Messages.ERR_AVAILABILITY_BAD_TIMEWINDOW_0));
}
}
// modify release and expire date of the resource if desired
if (!leaveRelease) {
getCms().setDateReleased(resourcePath, releaseDate, modifyRecursive);
}
if (!leaveExpire) {
getCms().setDateExpired(resourcePath, expireDate, modifyRecursive);
}
// write notification settings
writeProperty(
resourcePath,
CmsPropertyDefinition.PROPERTY_NOTIFICATION_INTERVAL,
getParamNotificationinterval());
writeProperty(
resourcePath,
CmsPropertyDefinition.PROPERTY_ENABLE_NOTIFICATION,
getParamEnablenotification());
}
}
/**
* Writes a property value for a resource.<p>
*
* @param resourcePath the path of the resource
* @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 resourcePath, 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(resourcePath, 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(resourcePath, newProp);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -