roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r580997 - in /roller/branches/roller_4.1_dev: apps/weblogger/src/java/org/apache/roller/weblogger/pojos/ apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/ apps/weblogger/src/java/org/apache/roller/weblogger/webservices/ad...
Date Mon, 01 Oct 2007 15:48:33 GMT
Author: snoopdave
Date: Mon Oct  1 08:48:32 2007
New Revision: 580997

URL: http://svn.apache.org/viewvc?rev=580997&view=rev
Log:
More user mgmt externalization: removing weblog.user as persistent field

Modified:
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.java
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.orm.xml
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/adminprotocol/RollerWeblogHandler.java
    roller/branches/roller_4.1_dev/apps/weblogger/src/sql/400-to-410-migration.vm
    roller/branches/roller_4.1_dev/apps/weblogger/src/sql/createdb.vm
    roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
    roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogTest.java
    roller/branches/roller_4.1_dev/metadata/database/macros.vm

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.java?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.java
Mon Oct  1 08:48:32 2007
@@ -90,14 +90,13 @@
     private String  pageModels       = new String();
     private boolean enableMultiLang = false;
     private boolean showAllLangs = true;
-    private String customStylesheetPath = null;
-    private String iconPath = null;
-    private String about = null;
-    
+    private String  customStylesheetPath = null;
+    private String  iconPath = null;
+    private String  about = null;
+    private String  creator = null;     
     
     // Associated objects
-    private User           creator = null; 
-    private List               permissions = new ArrayList();
+    private List           permissions = new ArrayList();
     private WeblogCategory bloggerCategory = null;
     private WeblogCategory defaultCategory = null;
     
@@ -108,7 +107,7 @@
     
     public Weblog(
             String handle,
-            User creator,
+            String creator,
             String name,
             String desc,
             String email,
@@ -269,19 +268,28 @@
     }
     
     /**
-     * Original creator of website
-     *
+     * Original creator of website.
      * @roller.wrapPojoMethod type="pojo"
-     * @ejb:persistent-field
-     * @hibernate.many-to-one column="userid" cascade="none" not-null="true"
      */
     public org.apache.roller.weblogger.pojos.User getCreator() {
+        try {
+            return WebloggerFactory.getWeblogger().getUserManager().getUserByUserName(creator);
+        } catch (Exception e) {
+            log.error("ERROR fetching user object for username: " + creator, e);
+        }
+        return null;
+    }
+    
+    /**
+     * Username of original creator of website.
+     * @roller.wrapPojoMethod type="pojo"
+     */
+    public String getCreatorUserName() {
         return creator;
     }
     
-    /** @ejb:persistent-field */
-    public void setCreator( org.apache.roller.weblogger.pojos.User ud ) {
-        creator = ud;
+    public void setCreatorUserName(String creatorUserName) {
+        creator = creatorUserName;
     }
     
     /**
@@ -581,31 +589,31 @@
      */
     public void setData(Weblog other) {
         
-        this.id = other.getId();
-        this.name = other.getName();
-        this.handle = other.getHandle();
-        this.description = other.getDescription();
-        this.creator = other.getCreator();
-        this.defaultPageId = other.getDefaultPageId();
-        this.weblogDayPageId = other.getWeblogDayPageId();
-        this.enableBloggerApi = other.getEnableBloggerApi();
-        this.bloggerCategory = other.getBloggerCategory();
-        this.defaultCategory = other.getDefaultCategory();
-        this.editorPage = other.getEditorPage();
-        this.blacklist = other.getBlacklist();
-        this.allowComments = other.getAllowComments();
-        this.emailComments = other.getEmailComments();
-        this.emailAddress = other.getEmailAddress();
-        this.emailFromAddress = other.getEmailFromAddress();
-        this.editorTheme = other.getEditorTheme();
-        this.locale = other.getLocale();
-        this.timeZone = other.getTimeZone();
-        this.defaultPlugins = other.getDefaultPlugins();
-        this.enabled = other.getEnabled();
-        this.dateCreated = other.getDateCreated();
-        this.entryDisplayCount = other.getEntryDisplayCount();
-        this.active = other.getActive();
-        this.lastModified = other.getLastModified();
+        this.setId(other.getId());
+        this.setName(other.getName());
+        this.setHandle(other.getHandle());
+        this.setDescription(other.getDescription());
+        this.setCreatorUserName(other.getCreatorUserName());
+        this.setDefaultPageId(other.getDefaultPageId());
+        this.setWeblogDayPageId(other.getWeblogDayPageId());
+        this.setEnableBloggerApi(other.getEnableBloggerApi());
+        this.setBloggerCategory(other.getBloggerCategory());
+        this.setDefaultCategory(other.getDefaultCategory());
+        this.setEditorPage(other.getEditorPage());
+        this.setBlacklist(other.getBlacklist());
+        this.setAllowComments(other.getAllowComments());
+        this.setEmailComments(other.getEmailComments());
+        this.setEmailAddress(other.getEmailAddress());
+        this.setEmailFromAddress(other.getEmailFromAddress());
+        this.setEditorTheme(other.getEditorTheme());
+        this.setLocale(other.getLocale());
+        this.setTimeZone(other.getTimeZone());
+        this.setDefaultPlugins(other.getDefaultPlugins());
+        this.setEnabled(other.getEnabled());
+        this.setDateCreated(other.getDateCreated());
+        this.setEntryDisplayCount(other.getEntryDisplayCount());
+        this.setActive(other.getActive());
+        this.setLastModified(other.getLastModified());
     }
     
     

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.orm.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.orm.xml?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.orm.xml
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/Weblog.orm.xml
Mon Oct  1 08:48:32 2007
@@ -173,6 +173,9 @@
 			<basic name="active">
 				<column name="isactive" insertable="true" updatable="true" unique="false"/>
 			</basic>
+			<basic name="creatorUserName">
+				<column name="creator" insertable="true" updatable="true" unique="false"/>
+			</basic>
 			<basic name="lastModified">
 				<column name="lastmodified" insertable="true" updatable="true" unique="false"/>
 				<temporal>TIMESTAMP</temporal>
@@ -189,9 +192,6 @@
 			<basic name="customStylesheetPath">
 				<column name="customstylesheet" insertable="true" updatable="true" unique="false"/>
 			</basic>
-			<many-to-one name="creator" target-entity="org.apache.roller.weblogger.pojos.User">
-				<join-column name="userid" insertable="true" updatable="true" nullable="false"/>
-			</many-to-one>
 			<many-to-one name="bloggerCategory" target-entity="org.apache.roller.weblogger.pojos.WeblogCategory">
 				<join-column name="bloggercatid" insertable="true" updatable="true"/>
 			</many-to-one>

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/core/CreateWeblog.java
Mon Oct  1 08:48:32 2007
@@ -113,7 +113,7 @@
             
             Weblog wd = new Weblog(
                     getBean().getHandle(),
-                    user,
+                    user.getUserName(),
                     getBean().getName(),
                     getBean().getDescription(),
                     getBean().getEmailAddress(),

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/adminprotocol/RollerWeblogHandler.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/adminprotocol/RollerWeblogHandler.java?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/adminprotocol/RollerWeblogHandler.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/webservices/adminprotocol/RollerWeblogHandler.java
Mon Oct  1 08:48:32 2007
@@ -171,7 +171,7 @@
                 User user = mgr.getUserByUserName(entry.getCreatingUser());
                 Weblog wd = new Weblog(
                         entry.getHandle(),
-                        user,
+                        user.getUserName(),
                         entry.getName(),
                         entry.getDescription(),
                         entry.getEmailAddress(),

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/sql/400-to-410-migration.vm
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/sql/400-to-410-migration.vm?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/sql/400-to-410-migration.vm (original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/sql/400-to-410-migration.vm Mon Oct
 1 08:48:32 2007
@@ -4,8 +4,9 @@
 DON'T RUN THIS, IT'S NOT A DATABASE CREATION SCRIPT!!!
 **#
 
--- actions: comma separated list of actions permitted by permission
--- objectid: for now this will always store weblogid
+-- We are replacing roller_user_permissions with this new table
+-- actions:    comma separated list of actions permitted by permission
+-- objectid:   for now this will always store weblogid
 -- objectType: for now this will always be 'Weblog'
 create table roller_permission (
    id              varchar(48) not null primary key,
@@ -17,8 +18,6 @@
    datecreated     timestamp not null
 );
 
-#dropNotNullFromColumn("userrole" "userid" "varchar(48)")
-
 insert into roller_permission (id,username,actions,objectid,objecttype,pending,datecreated)

    select w.id||u.username, u.username, 'edit_draft', w.handle, 'Weblog', 0, current_timestamp
       from rolleruser as u, website as w, roller_user_permissions as p
@@ -33,3 +32,9 @@
    select w.id||u.username, u.username, 'admin', w.handle, 'Weblog', 0, current_timestamp
       from rolleruser as u, website as w, roller_user_permissions as p
       where p.user_id = u.id and p.website_id = w.id and permission_mask = 3;
+
+-- User management can now be exernalized, so no more relations with user table
+#dropNotNullFromColumn("userrole" "userid" "varchar(48)")
+#addColumnNull("website" "creator" "varchar(255)")
+update website as w set creator = (select u.username from rolleruser as u where u.id = w.userid);
+

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/sql/createdb.vm
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/sql/createdb.vm?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/sql/createdb.vm (original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/sql/createdb.vm Mon Oct  1 08:48:32
2007
@@ -94,7 +94,7 @@
     name              varchar(255) not null,
     handle            varchar(255) not null,
     description       varchar(255) not null,
-    userid            varchar(48) not null,
+    creator           varchar(255),
     defaultpageid     varchar(48) default '',
     weblogdayid       varchar(48) not null,
     ignorewords       $db.TEXT_SQL_TYPE,

Modified: roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/TestUtils.java
Mon Oct  1 08:48:32 2007
@@ -178,7 +178,7 @@
         testWeblog.setLocale("en_US");
         testWeblog.setTimeZone("America/Los_Angeles");
         testWeblog.setDateCreated(new java.util.Date());
-        testWeblog.setCreator(creator);
+        testWeblog.setCreatorUserName(creator.getUserName());
         
         // add weblog
         WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();

Modified: roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogTest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogTest.java?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogTest.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/test/java/org/apache/roller/weblogger/business/WeblogTest.java
Mon Oct  1 08:48:32 2007
@@ -114,7 +114,7 @@
             testWeblog.setLocale("en_US");
             testWeblog.setTimeZone("America/Los_Angeles");
             testWeblog.setDateCreated(new java.util.Date());
-            testWeblog.setCreator(testUser);
+            testWeblog.setCreatorUserName(testUser.getUserName());
 
             // make sure test weblog does not exist
             weblog = mgr.getWeblogByHandle(testWeblog.getHandle());

Modified: roller/branches/roller_4.1_dev/metadata/database/macros.vm
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/metadata/database/macros.vm?rev=580997&r1=580996&r2=580997&view=diff
==============================================================================
Binary files /tmp/tmpqU4yEZ and /tmp/tmpRLFrND differ



Mime
View raw message