cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/acl-item-cidrs to 00704ee
Date Wed, 19 Feb 2014 14:39:17 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/acl-item-cidrs [created] 00704ee68


network acl item cidrs

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/00704ee6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/00704ee6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/00704ee6

Branch: refs/heads/acl-item-cidrs
Commit: 00704ee68c69e3e4ac1461a0ad8ac23b9f547fd1
Parents: 24309f6
Author: Daan Hoogland <daan@onecht.net>
Authored: Wed Feb 19 15:39:12 2014 +0100
Committer: Daan Hoogland <daan@onecht.net>
Committed: Wed Feb 19 15:39:12 2014 +0100

----------------------------------------------------------------------
 .../network/vpc/NetworkACLItemCidrsDao.java     | 39 ++++++++
 .../network/vpc/NetworkACLItemCidrsVO.java      | 78 ++++++++++++++++
 .../cloud/network/vpc/NetworkACLItemDao.java    |  2 +
 .../vpc/dao/NetworkACLItemCidrsDaoImpl.java     | 94 ++++++++++++++++++++
 .../network/vpc/dao/NetworkACLItemDaoImpl.java  | 35 ++++++++
 5 files changed, 248 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00704ee6/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsDao.java b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsDao.java
new file mode 100644
index 0000000..5e49368
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsDao.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.network.vpc;
+
+import java.util.List;
+
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDao;
+
+/**
+ * @author daan
+ *
+ */
+public interface NetworkACLItemCidrsDao extends GenericDao<NetworkACLItemCidrsVO, Long>
{
+
+    void persist(long networkACLItemId, List<String> cidrs);
+
+    List<String> getCidrs(long networkACLItemId);
+
+    @DB
+    List<NetworkACLItemCidrsVO> listByNetworkACLItemId(long networkACLItemId);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00704ee6/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsVO.java b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsVO.java
new file mode 100644
index 0000000..6acf845
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemCidrsVO.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.network.vpc;
+
+import javax.persistence.Column;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+/**
+ * @author daan
+ *
+ */
+public class NetworkACLItemCidrsVO implements InternalIdentity {
+    private static final long serialVersionUID = 7805284475485494754L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "network_acl_item_id")
+    private long networkACLItemId;
+
+    @Column(name = "cidr")
+    private String cidrList;
+
+    public NetworkACLItemCidrsVO() {
+    }
+
+    public NetworkACLItemCidrsVO(long networkAclItemId, String cidrList) {
+        this.networkACLItemId = networkAclItemId;
+        this.cidrList = cidrList;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cloudstack.api.InternalIdentity#getId()
+     */
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    public long getNetworkACLItemId() {
+        return networkACLItemId;
+    }
+
+    public String getCidr() {
+        return cidrList;
+    }
+
+    public String getCidrList() {
+        return cidrList;
+    }
+
+    public void setCidrList(String cidrList) {
+        this.cidrList = cidrList;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00704ee6/engine/schema/src/com/cloud/network/vpc/NetworkACLItemDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemDao.java b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemDao.java
index e278485..9ab6365 100644
--- a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemDao.java
+++ b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemDao.java
@@ -34,4 +34,6 @@ public interface NetworkACLItemDao extends GenericDao<NetworkACLItemVO,
Long> {
     int getMaxNumberByACL(long aclId);
 
     NetworkACLItemVO findByAclAndNumber(long aclId, int number);
+
+    void loadCidrs(NetworkACLItemVO item);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00704ee6/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemCidrsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemCidrsDaoImpl.java b/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemCidrsDaoImpl.java
new file mode 100644
index 0000000..23c1fa7
--- /dev/null
+++ b/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemCidrsDaoImpl.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.network.vpc.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.vpc.NetworkACLItemCidrsDao;
+import com.cloud.network.vpc.NetworkACLItemCidrsVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.TransactionLegacy;
+
+/**
+ * @author daan
+ *
+ */
+@Component
+@Local(value = NetworkACLItemCidrsDao.class)
+public class NetworkACLItemCidrsDaoImpl extends GenericDaoBase<NetworkACLItemCidrsVO,
Long> implements NetworkACLItemCidrsDao {
+    private static final Logger s_logger = Logger.getLogger(NetworkACLItemCidrsDaoImpl.class);
+    protected final SearchBuilder<NetworkACLItemCidrsVO> cidrsSearch;
+
+    protected NetworkACLItemCidrsDaoImpl() {
+        cidrsSearch = createSearchBuilder();
+        cidrsSearch.and("networkAclItemId", cidrsSearch.entity().getNetworkACLItemId(), SearchCriteria.Op.EQ);
+        cidrsSearch.done();
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.network.dao.NetworkAclItemCidrsDao#persist(long, java.util.List)
+     */
+    @Override
+    public void persist(long networkACLItemId, List<String> cidrs) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+
+        txn.start();
+        for (String cidr : cidrs) {
+            NetworkACLItemCidrsVO vo = new NetworkACLItemCidrsVO(networkACLItemId, cidr);
+            persist(vo);
+        }
+        txn.commit();
+    }
+
+    /* (non-Javadoc)
+     * @see com.cloud.network.dao.NetworkAclItemCidrsDao#getCidrs(long)
+     */
+    @Override
+    public List<String> getCidrs(long networkACLItemId) {
+        SearchCriteria<NetworkACLItemCidrsVO> sc = cidrsSearch.create();
+        sc.setParameters("firewallRuleId", networkACLItemId);
+
+        List<NetworkACLItemCidrsVO> results = search(sc, null);
+        List<String> cidrs = new ArrayList<String>(results.size());
+        for (NetworkACLItemCidrsVO result : results) {
+            cidrs.add(result.getCidr());
+        }
+
+        return cidrs;
+    }
+
+    @Override
+    public List<NetworkACLItemCidrsVO> listByNetworkACLItemId(long networkACLItemId)
{
+        SearchCriteria<NetworkACLItemCidrsVO> sc = cidrsSearch.create();
+        sc.setParameters("firewallRuleId", networkACLItemId);
+
+        List<NetworkACLItemCidrsVO> results = search(sc, null);
+
+        return results;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/00704ee6/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java b/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
index 31ff6f2..b581d3e 100644
--- a/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/vpc/dao/NetworkACLItemDaoImpl.java
@@ -19,10 +19,13 @@ package com.cloud.network.vpc.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.network.vpc.NetworkACLItem.State;
+import com.cloud.network.vpc.NetworkACLItemCidrsDao;
 import com.cloud.network.vpc.NetworkACLItemDao;
 import com.cloud.network.vpc.NetworkACLItemVO;
 import com.cloud.utils.db.DB;
@@ -31,17 +34,22 @@ import com.cloud.utils.db.GenericSearchBuilder;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.TransactionLegacy;
 
 @Component
 @Local(value = NetworkACLItemDao.class)
 @DB()
 public class NetworkACLItemDaoImpl extends GenericDaoBase<NetworkACLItemVO, Long> implements
NetworkACLItemDao {
+    private static final Logger s_logger = Logger.getLogger(NetworkACLItemDaoImpl.class);
 
     protected final SearchBuilder<NetworkACLItemVO> AllFieldsSearch;
     protected final SearchBuilder<NetworkACLItemVO> NotRevokedSearch;
     protected final SearchBuilder<NetworkACLItemVO> ReleaseSearch;
     protected final GenericSearchBuilder<NetworkACLItemVO, Integer> MaxNumberSearch;
 
+    @Inject
+    protected NetworkACLItemCidrsDao _networkACLItemCidrsDao;
+
     protected NetworkACLItemDaoImpl() {
         super();
 
@@ -115,4 +123,31 @@ public class NetworkACLItemDaoImpl extends GenericDaoBase<NetworkACLItemVO,
Long
         sc.setParameters("number", number);
         return findOneBy(sc);
     }
+
+    @Override
+    @DB
+    public NetworkACLItemVO persist(NetworkACLItemVO networkAclItem) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        txn.start();
+
+        NetworkACLItemVO dbNetworkACLItem = super.persist(networkAclItem);
+        saveCidrs(networkAclItem, networkAclItem.getSourceCidrList());
+        loadCidrs(dbNetworkACLItem);
+
+        txn.commit();
+        return dbNetworkACLItem;
+    }
+
+    public void saveCidrs(NetworkACLItemVO networkACLItem, List<String> cidrList) {
+        if (cidrList == null) {
+            return;
+        }
+        _networkACLItemCidrsDao.persist(networkACLItem.getId(), cidrList);
+    }
+
+    @Override
+    public void loadCidrs(NetworkACLItemVO item) {
+        List<String> cidrs = _networkACLItemCidrsDao.getCidrs(item.getId());
+        item.setSourceCidrList(cidrs);
+    }
 }


Mime
View raw message