📄 cmschacc.java
字号:
String type = getParamType();
try {
// lock resource if autolock is enabled
checkLock(getParamResource());
getCms().rmacc(file, type, name);
return true;
} catch (CmsException e) {
m_errorMessages.add(key(Messages.ERR_CHACC_DELETE_ENTRY_0));
return false;
}
}
/**
* Builds a String with HTML code to display the users access rights for the current resource.<p>
*
* @return HTML String with the access rights of the current user
*/
public String buildCurrentPermissions() {
StringBuffer result = new StringBuffer(dialogToggleStart(key(Messages.GUI_PERMISSION_USER_0), "userpermissions", getSettings().getUserSettings().getDialogExpandUserPermissions()));
result.append(dialogWhiteBoxStart());
result.append(buildPermissionEntryForm(getSettings().getUser().getId(), getCurPermissions(), false, false));
result.append(dialogWhiteBoxEnd());
result.append("</div>\n");
return result.toString();
}
/**
* Returns the error messages if something went wrong.<p>
*
* @return all error messages
*/
public String buildErrorMessages() {
StringBuffer result = new StringBuffer(8);
String errorMessages = getErrorMessagesString();
if (!"".equals(errorMessages)) {
result.append(dialogBlock(HTML_START, key(Messages.GUI_PERMISSION_ERROR_0), true));
result.append(errorMessages);
result.append(dialogBlockEnd());
}
return result.toString();
}
/**
* Builds a detail view selector.<p>
*
* @param wp the dialog object
* @return the HTML code for the detail view selector
*/
public static String buildSummaryDetailsButtons(CmsDialog wp) {
StringBuffer result = new StringBuffer(512);
// create detail view selector
result.append("<table border=\"0\">\n<tr>\n\t<td>");
result.append(wp.key(Messages.GUI_PERMISSION_SELECT_VIEW_0));
result.append("</td>\n");
String selectedView = wp.getSettings().getPermissionDetailView();
result.append("\t<form action=\"").append(wp.getDialogUri()).append(
"\" method=\"post\" name=\"selectshortview\">\n");
result.append("\t<td>\n");
result.append("\t<input type=\"hidden\" name=\"");
result.append(PARAM_VIEW);
result.append("\" value=\"short\">\n");
// set parameters to show correct hidden input fields
wp.setParamAction(null);
result.append(wp.paramsAsHidden());
result.append("\t<input type=\"submit\" class=\"dialogbutton\" value=\"").append(wp.key(Messages.GUI_LABEL_SUMMARY_0)).append(
"\"");
if (!"long".equals(selectedView)) {
result.append(" disabled=\"disabled\"");
}
result.append(">\n");
result.append("\t</td>\n");
result.append("\t</form>\n\t<form action=\"").append(wp.getDialogUri()).append(
"\" method=\"post\" name=\"selectlongview\">\n");
result.append("\t<td>\n");
result.append("\t<input type=\"hidden\" name=\"");
result.append(PARAM_VIEW);
result.append("\" value=\"long\">\n");
result.append(wp.paramsAsHidden());
result.append("\t<input type=\"submit\" class=\"dialogbutton\" value=\"").append(wp.key(Messages.GUI_LABEL_DETAILS_0)).append(
"\"");
if ("long".equals(selectedView)) {
result.append(" disabled=\"disabled\"");
}
result.append(">\n");
result.append("\t</td>\n\t</form>\n");
result.append("</tr>\n</table>\n");
return result.toString();
}
/**
* Builds a String with HTML code to display the inherited and own access control entries of a resource.<p>
*
* @return HTML code for inherited and own entries of the current resource
*/
public String buildRightsList() {
StringBuffer result = new StringBuffer(dialogToggleStart(key(Messages.GUI_PERMISSION_BEQUEATH_SUBFOLDER_0), "inheritedpermissions",
getSettings().getUserSettings().getDialogExpandInheritedPermissions() || getShowInheritedPermissions()));
//result.append(buildSummaryDetailsButtons(this));
// get all access control entries of the current file
List allEntries = new ArrayList();
try {
allEntries = getCms().getAccessControlEntries(getParamResource(), true);
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
// store all parent folder ids together with path in a map
Map parents = new HashMap();
String path = CmsResource.getParentFolder(getParamResource());
List parentResources = new ArrayList();
try {
// get all parent folders of the current file
parentResources = getCms().readPath(path, CmsResourceFilter.IGNORE_EXPIRATION);
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
Iterator k = parentResources.iterator();
while (k.hasNext()) {
// add the current folder to the map
CmsResource curRes = (CmsResource)k.next();
parents.put(curRes.getResourceId(), curRes.getRootPath());
}
// create new ArrayLists in which inherited and non inherited entries are stored
ArrayList ownEntries = new ArrayList(0);
ArrayList inheritedEntries = new ArrayList(0);
for (int i = 0; i < allEntries.size(); i++) {
CmsAccessControlEntry curEntry = (CmsAccessControlEntry)allEntries.get(i);
if (curEntry.isInherited()) {
// add the entry to the inherited rights list for the "long" view
if ("long".equals(getSettings().getPermissionDetailView())) {
inheritedEntries.add(curEntry);
}
} else {
// add the entry to the own rights list
ownEntries.add(curEntry);
}
}
// now create the inherited entries box
result.append(dialogWhiteBox(HTML_START));
result.append(buildInheritedList(inheritedEntries, parents));
result.append(dialogWhiteBox(HTML_END));
// close div that toggles visibility of inherited permissions
result.append("</div>");
// create the add user/group form
result.append(buildAddForm());
// create the resource entries box
result.append(buildResourceList(ownEntries));
return result.toString();
}
/**
* Returns the current users permission set on the resource.<p>
*
* @return the users permission set
*/
public CmsPermissionSet getCurPermissions() {
return m_curPermissions;
}
/**
* Returns a list with all error messages which occured when trying to add a new access control entry.<p>
*
* @return List of error message Strings
*/
public ArrayList getErrorMessages() {
return m_errorMessages;
}
/**
* Returns a String with all error messages occuring when trying to add a new access control entry.<p>
*
* @return String with error messages, separated by <br>
*/
public String getErrorMessagesString() {
StringBuffer errors = new StringBuffer(8);
Iterator i = getErrorMessages().iterator();
while (i.hasNext()) {
errors.append((String)i.next());
if (i.hasNext()) {
errors.append("<br>");
}
}
return errors.toString();
}
/**
* Returns the value of the name parameter,
* or null if this parameter was not provided.<p>
*
* The name parameter stores the name of the group or user.<p>
*
* @return the value of the name parameter
*/
public String getParamName() {
return m_paramName;
}
/**
* Returns the value of the type parameter,
* or null if this parameter was not provided.<p>
*
* The type parameter stores the type of an ace (group or user).<p>
*
* @return the value of the type parameter
*/
public String getParamType() {
return m_paramType;
}
/**
* Initializes some member variables to display the form with the right options for the current user.<p>
*
* This method must be called after initWorkplaceRequestValues().<p>
*/
public void init() {
// the current user name
String userName = getSettings().getUser().getName();
if (m_typesLocalized[0] == null) {
m_typesLocalized[0] = key(Messages.GUI_LABEL_GROUP_0);
m_typesLocalized[1] = key(Messages.GUI_LABEL_USER_0);
}
// set flags to show editable or non editable entries
setEditable(false);
setInheritOption(false);
String resName = getParamResource();
try {
// get the current users' permissions
setCurPermissions(getCms().getPermissions(getParamResource(), userName));
// check if the current resource is a folder
CmsResource resource = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
if (resource.isFolder()) {
// only folders have the inherit option activated
setInheritOption(true);
if (! resName.endsWith("/")) {
// append manually a "/" to folder name to avoid issues with check if resource is in project
resName += "/";
}
}
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
// check the current users permission to change access control entries
if ((!getCms().getRequestContext().currentProject().isOnlineProject() && getCms().isInsideCurrentProject(resName))
&& (getCms().hasRole(CmsRole.VFS_MANAGER) || ((m_curPermissions.getAllowedPermissions()
& CmsPermissionSet.PERMISSION_CONTROL) > 0 && !((m_curPermissions.getDeniedPermissions()
& CmsPermissionSet.PERMISSION_CONTROL) > 0)))) {
setEditable(true);
}
}
/**
* Sets the value of the name parameter.<p>
*
* @param value the value to set
*/
public void setParamName(String value) {
m_paramName = value;
}
/**
* Sets the value of the type parameter.<p>
*
* @param value the value to set
*/
public void setParamType(String value) {
m_paramType = value;
}
/**
* Validates the user input when creating a new access control entry.<p>
*
* @param name the name of the new user/group
* @param arrayPosition the position in the types array
* @return true if everything is ok, otherwise false
*/
protected boolean checkNewEntry(String name, int arrayPosition) {
m_errorMessages.clear();
boolean inArray = false;
if (getTypes()[arrayPosition] != null) {
inArray = true;
}
if (!inArray) {
m_errorMessages.add(key(Messages.ERR_PERMISSION_SELECT_TYPE_0));
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) {
m_errorMessages.add(key(Messages.ERR_MISSING_GROUP_OR_USER_NAME_0));
}
if (m_errorMessages.size() > 0) {
return false;
}
return true;
}
/**
* Returns the resource on which the specified access control entry was set.<p>
*
* @param entry the current access control entry
* @param parents the parent resources to determine the connected resource
* @return the resource name of the corresponding resource
*/
protected String getConnectedResource(CmsAccessControlEntry entry, Map parents) {
CmsUUID resId = entry.getResource();
String resName = (String)parents.get(resId);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(resName)) {
return resName;
}
return resId.toString();
}
/**
* Returns the current editable flag for the user to change ACEs.<p>
*
* @return true if user can edit the permissions, otherwise false
*/
protected boolean getEditable() {
return m_editable;
}
/**
* Determines the type of the current access control entry.<p>
*
* @param flags the value of the current flags
* @return String representation of the ace type
*/
protected String getEntryType(int flags) {
for (int i = 0; i < getTypes().length; i++) {
if ((flags & getTypesInt()[i]) > 0) {
return getTypes()[i];
}
}
return "Unknown";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -