Formatierungen und Kommentierungen.
git-svn-id: https://svn.libreccm.org/ccm/trunk@540 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
1d86f7e869
commit
e37d4ae055
|
|
@ -663,7 +663,7 @@ public class PageState {
|
|||
* Set the control event. The control event is a <i>delayed</i> event
|
||||
* that only gets acted on when another request to this <code>Page</code>
|
||||
* is made. It is used to set which component should receive the
|
||||
* submission and lets the component set one comonent-specific name-value
|
||||
* submission and lets the component set one component-specific name-value
|
||||
* pair to be used in the submission.
|
||||
* <p>
|
||||
* After calling this method links and hidden form controls generated
|
||||
|
|
|
|||
|
|
@ -39,18 +39,18 @@ import org.apache.log4j.Logger;
|
|||
* @see com.arsdigita.kernel.KernelConfig
|
||||
* @see com.arsdigita.kernel.KernelContext
|
||||
* @see com.arsdigita.kernel.KernelExcursion
|
||||
*
|
||||
* @version $Id: Kernel.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class Kernel {
|
||||
public static final String versionId =
|
||||
"$Id: Kernel.java 287 2005-02-22 00:29:02Z sskracic $" +
|
||||
"$Author: sskracic $" +
|
||||
"$DateTime: 2004/08/16 18:10:38 $";
|
||||
|
||||
/** Private logger instance for debugging */
|
||||
private static final Logger s_log = Logger.getLogger(Kernel.class);
|
||||
|
||||
// The ID of the user that represents "the public", i.e. a non-logged-in user.
|
||||
// Created by insert-users.sql.
|
||||
/** The ID of the user that represents "the public", i.e. a non-logged-in
|
||||
* user. Created by insert-users.sql (during load step) . */
|
||||
private static final BigDecimal PUBLIC_USER_ID = new BigDecimal(-200);
|
||||
/** Public (i.e. a non-logged-in) User object (retrieved by PUBLIC_USER_ID) */
|
||||
private static User s_publicUser;
|
||||
|
||||
private static KernelContext s_initialContext;
|
||||
|
|
@ -138,11 +138,11 @@ public class Kernel {
|
|||
public static final User getPublicUser() {
|
||||
init();
|
||||
if (s_publicUser == null) {
|
||||
// We could synchronize this method, but we don't really care if the User
|
||||
// object gets loaded more than once.
|
||||
// We could synchronize this method, but we don't really care if the
|
||||
// User object gets loaded more than once.
|
||||
s_publicUser = User.retrieve(PUBLIC_USER_ID);
|
||||
// Disconnect the object so we can use it across multiple transactions, and
|
||||
// so it cannot be modified/deleted.
|
||||
// Disconnect the object so we can use it across multiple transactions,
|
||||
// and so it cannot be modified/deleted.
|
||||
s_publicUser.disconnect();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,18 +41,16 @@ import org.apache.log4j.Logger;
|
|||
|
||||
/**
|
||||
* A utility class for controlling user access to domain/data objects.
|
||||
* @see com.arsdigita.kernel.permissions.PermissionDescriptor
|
||||
*
|
||||
* @author Oumi Mehrotra
|
||||
* @author Michael Bryzek
|
||||
* @version 1.0
|
||||
* @see com.arsdigita.kernel.permissions.PermissionDescriptor
|
||||
**/
|
||||
* @version $Id: PermissionService.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class PermissionService extends DomainService {
|
||||
public static final String versionId =
|
||||
"$Id: PermissionService.java 287 2005-02-22 00:29:02Z sskracic $" +
|
||||
"$Author: sskracic $" +
|
||||
"$DateTime: 2004/08/16 18:10:38 $";
|
||||
|
||||
/** Private logger instance for debugging purpose */
|
||||
private static final Logger s_log = Logger.getLogger(PermissionService.class);
|
||||
|
||||
// Reference to the PermissionManager to use for permissions checks.
|
||||
|
|
@ -95,8 +93,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @return True if permission checks are currently enabled, false if they
|
||||
* are disabled.
|
||||
**/
|
||||
|
||||
*/
|
||||
public static final boolean isEnabled() {
|
||||
return s_enabled;
|
||||
}
|
||||
|
|
@ -107,8 +104,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @param value If value is false then permission wide system checks are
|
||||
* disabled.
|
||||
**/
|
||||
|
||||
*/
|
||||
public static final void setEnabled(boolean value) {
|
||||
s_enabled = value;
|
||||
}
|
||||
|
|
@ -118,7 +114,7 @@ public class PermissionService extends DomainService {
|
|||
* given PermissionDescriptor is false.
|
||||
*
|
||||
* @param permission the {@link PermissionDescriptor} to check
|
||||
**/
|
||||
*/
|
||||
public static void assertPermission(PermissionDescriptor permission) {
|
||||
if (!isEnabled()) { return; }
|
||||
if (!checkPermission(permission)) {
|
||||
|
|
@ -136,7 +132,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @return <code>true</code> if the PermissionDescriptor's base object has the
|
||||
* specified permission; <code>false</code> otherwise.
|
||||
**/
|
||||
*/
|
||||
public static boolean checkPermission(PermissionDescriptor permission) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("checking " + permission.getPrivilegeDescriptor()
|
||||
|
|
@ -159,7 +155,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @see com.arsdigita.kernel.ACSObject
|
||||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
**/
|
||||
*/
|
||||
public static void grantPermission(PermissionDescriptor permission) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("granting " + permission.getPrivilegeDescriptor()
|
||||
|
|
@ -179,7 +175,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @see com.arsdigita.kernel.ACSObject
|
||||
* @see com.arsdigita.kernel.permissions.PrivilegeDescriptor
|
||||
**/
|
||||
*/
|
||||
public static void revokePermission(PermissionDescriptor permission) {
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("revoking " + permission.getPrivilegeDescriptor()
|
||||
|
|
@ -203,7 +199,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @see com.arsdigita.kernel.ACSObject
|
||||
* @see com.arsdigita.persistence.OID
|
||||
**/
|
||||
*/
|
||||
public static DataObject getContext(OID oid) {
|
||||
return getPermissionManager().getContext(oid);
|
||||
}
|
||||
|
|
@ -223,7 +219,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @see com.arsdigita.kernel.ACSObject
|
||||
* @see com.arsdigita.persistence.OID
|
||||
**/
|
||||
*/
|
||||
public static DataObject getContext(ACSObject acsObject) {
|
||||
return getPermissionManager().getContext(acsObject);
|
||||
}
|
||||
|
|
@ -298,7 +294,6 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @param acsObject the object whose permission context is being
|
||||
* set
|
||||
*
|
||||
*/
|
||||
public static void clonePermissions(ACSObject acsObject)
|
||||
throws PersistenceException
|
||||
|
|
@ -317,7 +312,6 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @param acsObjectOID the object whose permission context is being
|
||||
* set
|
||||
*
|
||||
*/
|
||||
public static void clonePermissions(OID acsObjectOID)
|
||||
throws PersistenceException
|
||||
|
|
@ -356,7 +350,8 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @return the permissions that have been granted on the specified
|
||||
* object (direct permissions followed by inherited
|
||||
* permisions). */
|
||||
* permisions).
|
||||
*/
|
||||
public static ObjectPermissionCollection
|
||||
getDirectGrantedPermissions(OID acsObjectOID)
|
||||
{
|
||||
|
|
@ -390,7 +385,6 @@ public class PermissionService extends DomainService {
|
|||
* a collection of type ACSObject.
|
||||
* @param privilege the required privilege
|
||||
* @param userOID the OID of the user whose access is being filtered
|
||||
*
|
||||
*/
|
||||
public static void filterObjects(DataCollection dataCollection,
|
||||
PrivilegeDescriptor privilege,
|
||||
|
|
@ -408,7 +402,6 @@ public class PermissionService extends DomainService {
|
|||
* @param domainCollection the collection to filter
|
||||
* @param privilege the required privilege
|
||||
* @param userOID the OID of the user whose access is being filtered
|
||||
*
|
||||
*/
|
||||
public static void filterObjects(DomainCollection domainCollection,
|
||||
PrivilegeDescriptor privilege,
|
||||
|
|
@ -433,7 +426,6 @@ public class PermissionService extends DomainService {
|
|||
* @param privilege the required privilege
|
||||
*
|
||||
* @param userOID the OID of the user whose access is being filtered
|
||||
*
|
||||
*/
|
||||
public static void filterQuery(DataQuery dataQuery,
|
||||
String propertyName,
|
||||
|
|
@ -468,7 +460,6 @@ public class PermissionService extends DomainService {
|
|||
* @param privilege the required privilege
|
||||
*
|
||||
* @param objectOID the OID of the object that the users are trying to access
|
||||
*
|
||||
*/
|
||||
public static void objectFilterQuery(DataQuery dataQuery,
|
||||
String propertyName,
|
||||
|
|
@ -500,7 +491,8 @@ public class PermissionService extends DomainService {
|
|||
* @param partyOID the OID of the user whose access is being filtered
|
||||
*
|
||||
* @return a filter which is true if the user has the required permission
|
||||
* on the specified property */
|
||||
* on the specified property
|
||||
*/
|
||||
public static Filter getFilterQuery(FilterFactory factory,
|
||||
String propertyName,
|
||||
PrivilegeDescriptor privilege,
|
||||
|
|
@ -524,7 +516,7 @@ public class PermissionService extends DomainService {
|
|||
*
|
||||
* @param object the OID of the specified object
|
||||
* @param party the OID of the specified party
|
||||
**/
|
||||
*/
|
||||
public static Iterator getDirectPrivileges(OID object, OID party) {
|
||||
checkType(object, ACSObject.BASE_DATA_OBJECT_TYPE);
|
||||
checkType(party, Party.BASE_DATA_OBJECT_TYPE);
|
||||
|
|
@ -551,7 +543,7 @@ public class PermissionService extends DomainService {
|
|||
* @param party the OID of the party that privileges are to be returned for
|
||||
*
|
||||
* @return an iterator of PrivilegeDescriptors.
|
||||
**/
|
||||
*/
|
||||
public static Iterator getPrivileges(OID object, OID party) {
|
||||
return getPermissionManager().getPrivileges(object, party);
|
||||
}
|
||||
|
|
@ -568,7 +560,7 @@ public class PermissionService extends DomainService {
|
|||
* @return an iterator of PrivilegeDescriptors.
|
||||
*
|
||||
* @see #getPrivileges(OID, OID)
|
||||
**/
|
||||
*/
|
||||
public static Iterator getImpliedPrivileges(OID object, OID party) {
|
||||
return getPermissionManager().getImpliedPrivileges(object, party);
|
||||
}
|
||||
|
|
@ -578,7 +570,7 @@ public class PermissionService extends DomainService {
|
|||
* Revoke all permissions belonging to the specified party.
|
||||
*
|
||||
* @param partyOID OID of the party whose permissions are to be revoked.
|
||||
**/
|
||||
*/
|
||||
public static void revokePartyPermissions(OID partyOID) {
|
||||
DataOperation revoke = getDataOperation("RevokePartyPermissions");
|
||||
revoke.setParameter("partyID", partyOID.get("id"));
|
||||
|
|
@ -592,7 +584,7 @@ public class PermissionService extends DomainService {
|
|||
* @param baseTypeName the type the OID is checked for
|
||||
* @throws RuntimeException when specified OID is not an instance of the
|
||||
* specified type.
|
||||
**/
|
||||
*/
|
||||
private static void checkType(OID objectOID, String baseTypeName) {
|
||||
try {
|
||||
ObjectType.verifySubtype(baseTypeName,
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ public class PrivilegeDescriptor {
|
|||
* Equivalent to getName().
|
||||
* @return the privilege name
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,11 @@ import org.w3c.dom.Attr;
|
|||
* <code>org.jdom.Element</code> using <code>org.w3c.dom.Element</code>.
|
||||
*
|
||||
* @author Patrick McNeill
|
||||
* @version $Revision: #17 $ $Date: 2004/08/16 $
|
||||
* @since ACS 4.5a
|
||||
* @version $Revision: #17 $ $Date: 2004/08/16 $
|
||||
* @version $Id: Element.java 1372 2006-11-13 09:22:54Z chrisgilbert23 $
|
||||
*/
|
||||
public class Element {
|
||||
public static final String versionId =
|
||||
"$Id: Element.java 1372 2006-11-13 09:22:54Z chrisgilbert23 $" +
|
||||
"$Author: chrisgilbert23 $" +
|
||||
"$DateTime: 2004/08/16 18:10:38 $";
|
||||
|
||||
private static final Logger s_log = Logger.getLogger
|
||||
(Element.class.getName());
|
||||
|
|
@ -57,6 +54,7 @@ public class Element {
|
|||
private org.w3c.dom.Document m_doc;
|
||||
|
||||
private static ThreadLocal s_localDocument = new ThreadLocal() {
|
||||
@Override
|
||||
public Object initialValue() {
|
||||
try {
|
||||
DocumentBuilderFactory builder =
|
||||
|
|
@ -490,57 +488,58 @@ public class Element {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve an unordered list of strings relating to node tree including
|
||||
* and below the current element. Strings include element names, attribute names,
|
||||
* attribute values, text and CData sections
|
||||
* @return
|
||||
*/
|
||||
private List getXMLFragments() {
|
||||
|
||||
List unsortedList = new ArrayList();
|
||||
unsortedList.add(getName());
|
||||
unsortedList.add(getText());
|
||||
// CData sections are not included in getChildren()
|
||||
unsortedList.add(getCDATASection());
|
||||
Iterator it = getAttributes().entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
|
||||
unsortedList.add(entry.getKey());
|
||||
unsortedList.add(entry.getValue());
|
||||
}
|
||||
Iterator childElements = getChildren().iterator();
|
||||
while (childElements.hasNext()) {
|
||||
Element el = (Element) childElements.next();
|
||||
unsortedList.addAll(el.getXMLFragments());
|
||||
|
||||
}
|
||||
return unsortedList;
|
||||
/**
|
||||
* retrieve an unordered list of strings relating to node tree including
|
||||
* and below the current element. Strings include element names, attribute names,
|
||||
* attribute values, text and CData sections
|
||||
* @return
|
||||
*/
|
||||
private List getXMLFragments() {
|
||||
|
||||
List unsortedList = new ArrayList();
|
||||
unsortedList.add(getName());
|
||||
unsortedList.add(getText());
|
||||
// CData sections are not included in getChildren()
|
||||
unsortedList.add(getCDATASection());
|
||||
Iterator it = getAttributes().entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
java.util.Map.Entry entry = (java.util.Map.Entry) it.next();
|
||||
unsortedList.add(entry.getKey());
|
||||
unsortedList.add(entry.getValue());
|
||||
}
|
||||
/**
|
||||
* retrieve a string that is an ordered concatenation of all information describing
|
||||
* this node and its subnodes, suitable as the basis of a hashCode or equals
|
||||
* implementation.
|
||||
* @return
|
||||
*/
|
||||
protected String getXMLHashString() {
|
||||
// attributes and child nodes are retrieved as HashMap and List
|
||||
// respectively. These make no guarantees about the order of
|
||||
// iteration, and so we sort here to make sure the same element
|
||||
// will return the same XMLHash
|
||||
List sortedList = getXMLFragments();
|
||||
Collections.sort(sortedList);
|
||||
StringBuffer xml = new StringBuffer();
|
||||
Iterator xmlFragments = sortedList.iterator();
|
||||
while (xmlFragments.hasNext()) {
|
||||
xml.append(xmlFragments.next());
|
||||
}
|
||||
s_log.debug("getXMLHashString: " + xml.toString());
|
||||
return xml.toString();
|
||||
Iterator childElements = getChildren().iterator();
|
||||
while (childElements.hasNext()) {
|
||||
Element el = (Element) childElements.next();
|
||||
unsortedList.addAll(el.getXMLFragments());
|
||||
}
|
||||
return unsortedList;
|
||||
|
||||
public int hashCode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve a string that is an ordered concatenation of all information describing
|
||||
* this node and its subnodes, suitable as the basis of a hashCode or equals
|
||||
* implementation.
|
||||
* @return
|
||||
*/
|
||||
protected String getXMLHashString() {
|
||||
// attributes and child nodes are retrieved as HashMap and List
|
||||
// respectively. These make no guarantees about the order of
|
||||
// iteration, and so we sort here to make sure the same element
|
||||
// will return the same XMLHash
|
||||
List sortedList = getXMLFragments();
|
||||
Collections.sort(sortedList);
|
||||
StringBuffer xml = new StringBuffer();
|
||||
Iterator xmlFragments = sortedList.iterator();
|
||||
while (xmlFragments.hasNext()) {
|
||||
xml.append(xmlFragments.next());
|
||||
}
|
||||
s_log.debug("getXMLHashString: " + xml.toString());
|
||||
return xml.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
Date start = new Date();
|
||||
String hashString = getXMLHashString();
|
||||
s_log.debug(
|
||||
|
|
@ -550,8 +549,9 @@ public class Element {
|
|||
|
||||
return hashString.hashCode();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
s_log.debug("equals invoked");
|
||||
Date start = new Date();
|
||||
|
|
|
|||
Loading…
Reference in New Issue