Author: chathura
Date: Wed Feb  6 00:54:51 2008
New Revision: 13306

Log:


Blocked updating of system users from the registry realm.
Added javadoc for Resources.



Modified:
   
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
   
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryUserStoreAdmin.java
   
branches/registry/1_0/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java

Modified: 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
==============================================================================
--- 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
    (original)
+++ 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/Resource.java
    Wed Feb  6 00:54:51 2008
@@ -23,16 +23,70 @@
 import java.util.Date;
 import java.util.Properties;
 
+/**
+ * Represents any file or collection stored in the registry. It encapsulates 
both the content
+ * of the entity and its metadata. In addition to files and collections, 
instances of Resource
+ * are used to represent results of runtime queries. In such secenarios, 
comments, tags, ratings as
+ * well as collections of comments, etc. are also represented by Resource 
objects.
+ *
+ * Each resource instance contains a unique path within a Registry instance. 
Registry.get(...)
+ * method invocation using this path gives an instance of that resource. This 
path can be
+ * combined with the base URL of the registry server to generate a URI for the 
resource.
+ */
 public class Resource {
 
+    /**
+     * Unique identifier of the resource within the registry. Note that this 
is not an UUID.
+     */
     private long id;
+
+    /**
+     * Username of the user who added the resource to the registry.
+     */
     private String authorUserName;
+
+    /**
+     * Time at which the resource is first added to the registry.
+     */
     private Timestamp createdTime;
+
+    /**
+     * Username of the user who modified the resource most recently.
+     */
     private String lastUpdaterUserName;
+
+    /**
+     * Time at which the resource modified most recently.
+     */
     private Timestamp lastModified;
+
+    /**
+     * Description about the resource. This may contain any text including 
HTML fragments.
+     */
     private String description;
+
+    /**
+     * Unique path of the resource within the registry. This is generated by 
appending all
+     * ascendant paths to the resource name separated by "/". For example 
assume that the resource
+     * name is "users.xml". config.xml if inside the collection named 
"config". config collection
+     * is inside the root level collection named "servers". Then the path of 
the resource is
+     * /servers/config/users.xml.
+     */
     private String path;
+
+    /**
+     * Media type of the resource. Each resource can have a media type 
associated with it. This can
+     * be either a standart MIME media type or a custom media type defined by 
the users of the
+     * registry. Media type is used to activate media type handlers defined in 
the registry.
+     * Thus, by defining a media type for a resource and by registering a 
media type handler to
+     * handle that media type, it is possible to apply special processing for 
resources.
+     */
     private String mediaType;
+
+    /**
+     * Path of the parent collection of the resource. If the resource path is
+     * /servers/config/users.xml, parent path is /servers/config.
+     */
     private String parentPath;
 
     /**
@@ -48,14 +102,40 @@
      */
     private int state;
 
+    /**
+     * Properties associated with the resource. A resource can contain zero or 
more properties,
+     * where each property is a name->value pair. Both name and the value 
should be strings.
+     */
     private Properties properties;
 
+    /**
+     * Paths of the resources on which this resource depends on. This feature 
is not implemented
+     * currently.
+     */
     private String[] dependsOn;
+
+    /**
+     * Paths of the resources that depends on this resource. This feature is 
not implemented
+     * currently.
+     */
     private String[] dependedOnBy;
 
-    //To store any kind of object
+    /**
+     * Content of the resource. Object and the type stored in this field 
depends on the resource
+     * type. If the resource is a file with no special media type handling, 
this contains an array
+     * of bytes (byte[]) conatining the raw bytes of the file. If the resource 
is a collection, this
+     * contains a String[] containing the paths of child resources. If the 
resource is processed
+     * by a media type handler, it is upto the media type handler to set a 
content. In that case
+     * content can be anything ranging from String to custom type. Therefore, 
clients of the API
+     * should be aware of the media type and the content for that media type.
+     */
     private Object content;
 
+    /**
+     * Specified whether the resource is a collection (directory) or a file. 
By default all
+     * resources are considered as files. If you want to make a collection, 
you have to explicitly
+     * set the directory field to true.
+     */
     private boolean directory = false;
 
     public Resource() {

Modified: 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryUserStoreAdmin.java
==============================================================================
--- 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryUserStoreAdmin.java
   (original)
+++ 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/jdbc/realm/RegistryUserStoreAdmin.java
   Wed Feb  6 00:54:51 2008
@@ -72,4 +72,19 @@
 
         super.removeUserFromRole(userName, roleName);
     }
+
+
+    public void updateUser(String userName, Object newCredential, Object 
oldCredential)
+            throws UserManagerException {
+
+        // we should not allow to edit anoymous or system users.
+        if (RegistryConstants.SYSTEM_USER.equals(userName) || 
+                RegistryConstants.ANONYMOUS_USER.equals(userName)) {
+
+            String msg = "Could not edit the system defined user: " + userName;
+            throw new UserManagerException(msg);
+        }
+
+        super.updateUser(userName, newCredential, oldCredential);
+    }
 }

Modified: 
branches/registry/1_0/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
==============================================================================
--- 
branches/registry/1_0/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
    (original)
+++ 
branches/registry/1_0/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
    Wed Feb  6 00:54:51 2008
@@ -46,7 +46,8 @@
         SecureRegistry secureRegistry = (SecureRegistry) getRegistry();
         Realm realm = secureRegistry.getUserRealm();
 
-        if (getUserName().equals(displayUserName)) {
+        if (getUserName().equals(displayUserName) &&
+                !RegistryConstants.ANONYMOUS_USER.equals(displayUserName)) {
             userEditable = true;
         }
 

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to