incubator-lokahi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tob...@apache.org
Subject svn commit: r467724 - in /incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api: pool/HostingPoolModel.java project/Project.java project/ProjectModel.java server/HardwareModel.java
Date Wed, 25 Oct 2006 18:27:31 GMT
Author: toback
Date: Wed Oct 25 11:27:30 2006
New Revision: 467724

URL: http://svn.apache.org/viewvc?view=rev&rev=467724
Log:
HostingPoolModel.java, ProjectModel.java, HardwareModel.java: Fixed bug with updating or deleting
an object with a id of 1.

Project.java:  Fixed a bug where calling Project.update(p) would revert the collection of
virtualhosts and contexts to what is in the database.

Modified:
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/pool/HostingPoolModel.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/Project.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/ProjectModel.java
    incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/pool/HostingPoolModel.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/pool/HostingPoolModel.java?view=diff&rev=467724&r1=467723&r2=467724
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/pool/HostingPoolModel.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/pool/HostingPoolModel.java
Wed Oct 25 11:27:30 2006
@@ -92,7 +92,7 @@
   public void updateHostingPool(User u, HostingPool i, Function f) throws AuthorizationException,
TMCIllegalArgumentException, SQLException, IOException {
     this.jpInit(f, u, i.getName());
     if (u.isAllowed(f) && "UpdateHostingPool".equals(f.getCommand())) {
-      if (i.getPk() > 1 && i.getName() != null && !"".equals(i.getName()))
{
+      if (i.getPk() >= 1 && i.getName() != null && !"".equals(i.getName()))
{
         HostingPool.update(i);
       } else {
         throw new TMCIllegalArgumentException("Hosting Pool can not be null");

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/Project.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/Project.java?view=diff&rev=467724&r1=467723&r2=467724
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/Project.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/Project.java
Wed Oct 25 11:27:30 2006
@@ -6,9 +6,9 @@
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
-* 
+*
 *   http://www.apache.org/licenses/LICENSE-2.0
-* 
+*
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -116,18 +116,23 @@
 
   public Collection<VirtualHost> getVirtualHosts() {
     if (this.virtualHosts == null) {
-      this.virtualHosts = new TMCSet<VirtualHost>();
-      try {
-        this.virtualHosts.addAll(VirtualHost.getVirtualHosts(this.getPk()));
-      } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
-      }
+      this.virtualHosts = this.getVirtualHostsFromDB();
     }
     return this.virtualHosts;
   }
 
+  private Collection<VirtualHost> getVirtualHostsFromDB() {
+    Collection<VirtualHost> c = new TMCSet<VirtualHost>();
+    try {
+      c.addAll(VirtualHost.getVirtualHosts(this.getPk()));
+    } catch (SQLException e) {
+      if (logger.isInfoEnabled()) {
+        logger.info("Exception: " + e.getMessage());
+      }
+    }
+    return c;
+  }
+
   public boolean addVirtualHost(VirtualHost vh) {
     Collection<VirtualHost> c = new TMCSet<VirtualHost>();
     c.add(vh);
@@ -177,18 +182,23 @@
 
   public Collection<TomcatContext> getTomcatContexts() {
     if (this.tomcatContexts == null) {
-      this.tomcatContexts = new TMCSet<TomcatContext>();
-      try {
-        this.tomcatContexts.addAll(TomcatContext.getTomcatContexts(this.getPk()));
-      } catch (SQLException e) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Exception: " + e.getMessage());
-        }
-      }
+      this.tomcatContexts = this.getTomcatContextsFromDB();
     }
     return tomcatContexts;
   }
 
+  private Collection<TomcatContext> getTomcatContextsFromDB() {
+    Collection<TomcatContext> ret = new TMCSet<TomcatContext>();
+    try {
+      ret.addAll(TomcatContext.getTomcatContexts(this.getPk()));
+    } catch (SQLException e) {
+      if (logger.isInfoEnabled()) {
+        logger.info("Exception: " + e.getMessage());
+      }
+    }
+    return ret;
+  }
+
   public void removeTomcatContext(TomcatContext tc) {
     Collection<TomcatContext> tcs = this.getTomcatContexts();
     if (tcs != null && tcs.contains(tc)) {
@@ -377,10 +387,8 @@
   private static void updateGroups(Project p) throws SQLException {
     Collection<TomcatContext> newContexts = p.getTomcatContextsNoDB();
     Collection<VirtualHost> newVhosts = p.getVirtualHostsNoDB();
-    p.setTomcatContexts(null);
-    p.setVirtualHosts(null);
-    Collection<TomcatContext> oldContexts = p.getTomcatContexts();
-    Collection<VirtualHost> oldVhosts = p.getVirtualHosts();
+    Collection<TomcatContext> oldContexts = p.getTomcatContextsFromDB();
+    Collection<VirtualHost> oldVhosts = p.getVirtualHostsFromDB();
     diffCollections(p, oldContexts, newContexts, "context");
     diffCollections(p, oldVhosts, newVhosts, "vhost");
 

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/ProjectModel.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/ProjectModel.java?view=diff&rev=467724&r1=467723&r2=467724
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/ProjectModel.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/project/ProjectModel.java
Wed Oct 25 11:27:30 2006
@@ -83,7 +83,7 @@
   public void updateProject(User u, Project i, Function f) throws AuthorizationException,
TMCIllegalArgumentException, SQLException, IOException {
     this.jpInit(f, u, i.getName());
     if (u.isAllowed(f) && "UpdateProject".equals(f.getCommand())) {
-      if (i.getPk() > 1 && i.getName() != null && !"".equals(i.getName()))
{
+      if (i.getPk() >= 1 && i.getName() != null && !"".equals(i.getName()))
{
         Project.update(i);
       } else {
         throw new TMCIllegalArgumentException("Project can not be null");

Modified: incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java
URL: http://svn.apache.org/viewvc/incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java?view=diff&rev=467724&r1=467723&r2=467724
==============================================================================
--- incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java
(original)
+++ incubator/lokahi/lokahi/trunk/src/java/org/apache/lokahi/core/api/server/HardwareModel.java
Wed Oct 25 11:27:30 2006
@@ -88,7 +88,7 @@
   public void updateHardware(User u, Hardware h, Function f) throws AuthorizationException,
TMCIllegalArgumentException, SQLException, IOException {
     this.jpInit(f, u, h.getName());
     if (u.isAllowed(f)) {
-      if (h.getPk() > 1 && h.getServerName() != null && !"".equals(h.getServerName()))
{
+      if (h.getPk() >= 1 && h.getServerName() != null && !"".equals(h.getServerName()))
{
         Hardware.update(h);
       } else {
         throw new TMCIllegalArgumentException("Hardware can not be null");



Mime
View raw message