Allon Mureinik has uploaded a new change for review.

Change subject: core, ui: Generic way to check double names
......................................................................

core, ui: Generic way to check double names

This patch suggests a generic way to check whether an entity being
created is attempting to use a "used" name.

Currently, it includes an inelegant implementation for creating new Vm
Templates. If this approach is approved, following patches can remove
all the type-specific checks (both queries and AsyncDataProvider
methods) and unify them to a single call that receives the name and type
as parameters.

This patch includes:
1. A interface, NameableReadDao, which provides getByName(String) and
   existsWithSameName(String) methods.
2. A generic implementation of that DAO,
   DefaultGenericNameableDaoDbFacade.
3. A generic query, IsEntityWithSameNameExistsQuery, its parameter class
   and corresponding constant in VdcQueryType.
4. Converting VmTemplateDao to extend DefaultGenericNameableDaoDbFacade,
   and adding tests for the new functionality, as a usage example of the
   DAO changes.
5. Changing AsyncDataProvider.IsTemplateNameUnique(AsyncQuery, String)
   to use the new query, as a usage example.
6. Removing IsVmTemplateWithSameNameExistsQuery, its parameter class and
   its corresponding constant in VdcQueryType, as they are no longer in
   use.

Change-Id: I621c963110c8979b461b04502b3aab2455faf5b6
Signed-off-by: Allon Mureinik <[email protected]>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsEntityWithSameNameExistsQuery.java
D 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsVmTemlateWithSameNameExistQuery.java
A 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsEntityWithSameNameExistsParameters.java
D 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsVmTemlateWithSameNameExistParameters.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
A 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericNameableDaoDbFacade.java
A 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/NameableReadDao.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAO.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmTemplateDAOTest.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
13 files changed, 249 insertions(+), 44 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/13338/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsEntityWithSameNameExistsQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsEntityWithSameNameExistsQuery.java
new file mode 100644
index 0000000..2c901ea
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsEntityWithSameNameExistsQuery.java
@@ -0,0 +1,16 @@
+package org.ovirt.engine.core.bll;
+
+import 
org.ovirt.engine.core.common.queries.IsEntityWithSameNameExistsParameters;
+
+public class IsEntityWithSameNameExistsQuery<P extends 
IsEntityWithSameNameExistsParameters>
+        extends QueriesCommandBase<P> {
+    public IsEntityWithSameNameExistsQuery(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void executeQueryCommand() {
+        getQueryReturnValue().setReturnValue(
+                
getDbFacade().getDaoForNameable(getParameters().getType()).existsWithName(getParameters().getName()));
+    }
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsVmTemlateWithSameNameExistQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsVmTemlateWithSameNameExistQuery.java
deleted file mode 100644
index b48b074..0000000
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsVmTemlateWithSameNameExistQuery.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.ovirt.engine.core.bll;
-
-import org.ovirt.engine.core.common.queries.*;
-
-public class IsVmTemlateWithSameNameExistQuery<P extends 
IsVmTemlateWithSameNameExistParameters>
-        extends QueriesCommandBase<P> {
-    public IsVmTemlateWithSameNameExistQuery(P parameters) {
-        super(parameters);
-    }
-
-    @Override
-    protected void executeQueryCommand() {
-        getQueryReturnValue().setReturnValue(
-                
VmTemplateCommand.isVmTemlateWithSameNameExist(getParameters().getName()));
-    }
-}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsEntityWithSameNameExistsParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsEntityWithSameNameExistsParameters.java
new file mode 100644
index 0000000..262df26
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsEntityWithSameNameExistsParameters.java
@@ -0,0 +1,26 @@
+package org.ovirt.engine.core.common.queries;
+
+import org.ovirt.engine.core.common.VdcObjectType;
+
+public class IsEntityWithSameNameExistsParameters extends 
VdcQueryParametersBase {
+    private static final long serialVersionUID = -6382046704879479790L;
+
+    public IsEntityWithSameNameExistsParameters() {
+    }
+
+    public IsEntityWithSameNameExistsParameters(String name, VdcObjectType 
type) {
+        this.name = name;
+        this.type = type;
+    }
+
+    private String name;
+    private VdcObjectType type;
+
+    public String getName() {
+        return name;
+    }
+
+    public VdcObjectType getType() {
+        return type;
+    }
+}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsVmTemlateWithSameNameExistParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsVmTemlateWithSameNameExistParameters.java
deleted file mode 100644
index 5ecf9f1..0000000
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/IsVmTemlateWithSameNameExistParameters.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.ovirt.engine.core.common.queries;
-
-public class IsVmTemlateWithSameNameExistParameters extends 
VdcQueryParametersBase {
-    private static final long serialVersionUID = -6485460471694366238L;
-
-    public IsVmTemlateWithSameNameExistParameters(String name) {
-        _name = name;
-    }
-
-    private String _name;
-
-    public String getName() {
-        return _name;
-    }
-
-    public IsVmTemlateWithSameNameExistParameters() {
-    }
-}
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
index 9be9281..7908576 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java
@@ -74,8 +74,10 @@
     // Certificate
     GetCACertificate(VdcQueryAuthType.User),
 
+    // Generic entities queries
+    IsEntityWithSameNameExists(VdcQueryAuthType.User),
+
     // VM Templates queries
-    IsVmTemlateWithSameNameExist(VdcQueryAuthType.User),
     GetVmTemplate(VdcQueryAuthType.User),
     GetAllVmTemplates(VdcQueryAuthType.User),
     GetVmsByVmTemplateGuid,
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
index 936a39c..c93b1fb 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/DbFacade.java
@@ -4,6 +4,7 @@
 import java.sql.SQLException;
 import java.sql.Types;
 import java.util.ArrayList;
+import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -63,6 +64,7 @@
 import org.ovirt.engine.core.dao.JobDao;
 import org.ovirt.engine.core.dao.JobSubjectEntityDao;
 import org.ovirt.engine.core.dao.LunDAO;
+import org.ovirt.engine.core.dao.NameableReadDao;
 import org.ovirt.engine.core.dao.PermissionDAO;
 import org.ovirt.engine.core.dao.QuotaDAO;
 import org.ovirt.engine.core.dao.RepoFileMetaDataDAO;
@@ -150,6 +152,21 @@
         }
     };
 
+    @SuppressWarnings("serial")
+    private final static Map<VdcObjectType, Class<?>> mapTypeToDao =
+            new EnumMap<VdcObjectType, Class<?>>(VdcObjectType.class)
+    {
+        {
+            put(VdcObjectType.VM, VmDAO.class);
+            put(VdcObjectType.VmTemplate, VmTemplateDAO.class);
+            put(VdcObjectType.VdsGroups, VdsGroupDAO.class);
+            put(VdcObjectType.Storage, StorageDomainDAO.class);
+            put(VdcObjectType.StoragePool, StoragePoolDAO.class);
+            put(VdcObjectType.User, DbUserDAO.class);
+            put(VdcObjectType.Network, NetworkDao.class);
+        }
+    };
+
     private JdbcTemplate jdbcTemplate;
 
     private DbEngineDialect dbEngineDialect;
@@ -185,6 +202,22 @@
         return getDao(daoType);
     }
 
+    /**
+     * Return the correct NameableDAO for the given {@link Nameable} class.
+     *
+     * @param <T>
+     *            The Type of DAO which is returned.
+     * @param className
+     *            The class of the entity.
+     * @return The DAO for the entity.
+     * @throws ClassNotFoundException
+     */
+    public <T extends NameableReadDao<?>> T getDaoForNameable(VdcObjectType 
type) {
+        @SuppressWarnings("unchecked")
+        Class<T> daoType = (Class<T>) mapTypeToDao.get(type);
+        return getDao(daoType);
+    }
+
     protected <T extends DAO> T getDao(Class<T> daoType) {
         T dao = DaoFactory.get(daoType);
         if (dao instanceof BaseDAODbFacade) {
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericNameableDaoDbFacade.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericNameableDaoDbFacade.java
new file mode 100644
index 0000000..9d3e8ae
--- /dev/null
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/DefaultGenericNameableDaoDbFacade.java
@@ -0,0 +1,75 @@
+package org.ovirt.engine.core.dao;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+
+import org.ovirt.engine.core.common.businessentities.BusinessEntity;
+import org.ovirt.engine.core.common.businessentities.Nameable;
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
+
+/**
+ * Implementation for {@link DefaultGenericDaoDbFacade} that adds operations 
by name.
+ *
+ * @param <T>
+ *            The type of entity.
+ * @param <ID>
+ *            The type of the entity's id.
+ */
+public abstract class DefaultGenericNameableDaoDbFacade<T extends 
BusinessEntity<ID> & Nameable, ID extends Serializable>
+        extends DefaultGenericDaoDbFacade<T, ID> implements NameableReadDao<T> 
{
+
+    private static final String DEFAULT_GET_BY_NAME_PROCEDURE_FORMAT = 
"Get{0}By{0}Name";
+
+    /**
+     * This is the name of the stored procedure used for {@link 
NameableReadDao#get(String))}.
+     */
+    private String procedureNameForGetByName;
+
+    /**
+     * Initialize default procedure names with the given entity name.<br>
+     * The default procedure names are determined by the following formats:
+     * <ul>
+     * <li>For {@link NameableReadDao#get(String)}:
+     * {@link 
DefaultGenericNameableDaoDbFacade#DEFAULT_GET_BY_NAME_PROCEDURE_FORMAT}</li>
+     * </ul>
+     *
+     * If you wish to use a procedure name different than the default one, 
please set it accordingly.
+     *
+     * @param entityStoredProcedureName
+     *            The name to use in the default procedure names templates.
+     */
+    public DefaultGenericNameableDaoDbFacade(String entityStoredProcedureName) 
{
+        super(entityStoredProcedureName);
+        
setProcedureNameForGetByName(MessageFormat.format(DEFAULT_GET_BY_NAME_PROCEDURE_FORMAT,
+                entityStoredProcedureName));
+    }
+
+    protected final String getProcedureNameForGetByName() {
+        return procedureNameForGetByName;
+    }
+
+    protected void setProcedureNameForGetByName(String 
procedureNameForGetByName) {
+        this.procedureNameForGetByName = procedureNameForGetByName;
+    }
+
+    @Override
+    public T getByName(String name) {
+        return getCallsHandler().executeRead(getProcedureNameForGetByName(),
+                createEntityRowMapper(),
+                createNameParameterMapper(name));
+    }
+
+    @Override
+    public boolean existsWithName(String name) {
+        return getByName(name) != null;
+    }
+
+    /**
+     * Create a parameter mapper to map the entity name to the name in the 
procedure parameters.
+     *
+     * @param name
+     *            The entity to map id for.
+     * @return The mapper for the id from the entity.
+     */
+    protected abstract MapSqlParameterSource createNameParameterMapper(String 
name);
+}
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/NameableReadDao.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/NameableReadDao.java
new file mode 100644
index 0000000..dd5c898
--- /dev/null
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/NameableReadDao.java
@@ -0,0 +1,33 @@
+package org.ovirt.engine.core.dao;
+
+import org.ovirt.engine.core.common.businessentities.Nameable;
+
+/**
+ * Data Access Object interface used for reading entities by name from a 
source of data. Extending types should provide
+ * more entity-specific methods for retrieving the entity in more complex 
situations (i.e. by a field of the entity).
+ *
+ * @param <T>
+ *            The type of the entity.
+ * @param <ID>
+ *            The type of the entity's id.
+ */
+public interface NameableReadDao<T extends Nameable> extends DAO {
+
+    /**
+     * Retrieves the entity with the given name.
+     *
+     * @param name
+     *            The name to look by (can't be <code>null</code>).
+     * @return The entity instance, or <code>null</code> if not found.
+     */
+    public T getByName(String name);
+
+    /**
+     * Checks if an entity of the given name exists
+     *
+     * @param name
+     *            The name to look by (can't be <code>null</code>).
+     * @return <code>true</code> if the entity exists, <
+     */
+    public boolean existsWithName(String name);
+}
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAO.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAO.java
index 98333ee..d5b1671 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAO.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAO.java
@@ -11,7 +11,8 @@
 /**
  * <code>VmTemplateDAO</code> defines a type for performing CRUD operations on 
instances of {@link VmTemplate}.
  */
-public interface VmTemplateDAO extends GenericDao<VmTemplate, Guid>, 
StatusAwareDao<Guid, VmTemplateStatus>, SearchDAO<VmTemplate> {
+public interface VmTemplateDAO
+        extends GenericDao<VmTemplate, Guid>, NameableReadDao<VmTemplate>, 
StatusAwareDao<Guid, VmTemplateStatus>, SearchDAO<VmTemplate> {
 
     /**
     * Retrieves the template with the given id with optional filtering.
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
index 2f45d6d..aeaaf44 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
@@ -24,11 +24,12 @@
 /**
  * <code>VmTemplateDAODbFacadeImpl</code> provides a concrete implementation 
of {@link VmTemplateDAO}.
  */
-public class VmTemplateDAODbFacadeImpl extends 
DefaultGenericDaoDbFacade<VmTemplate, Guid> implements VmTemplateDAO {
+public class VmTemplateDAODbFacadeImpl extends 
DefaultGenericNameableDaoDbFacade<VmTemplate, Guid> implements VmTemplateDAO {
 
     public VmTemplateDAODbFacadeImpl() {
         super("VmTemplate");
         setProcedureNameForRemove("DeleteVmTemplates");
+        setProcedureNameForGetByName("GetVmTemplateByVmtName");
     }
 
     @Override
@@ -46,7 +47,7 @@
 
     @Override
     public VmTemplate getByName(String name, Guid userID, boolean isFiltered) {
-        return getCallsHandler().executeRead("GetVmTemplateByVmtName",
+        return getCallsHandler().executeRead(getProcedureNameForGetByName(),
                 VMTemplateRowMapper.instance,
                 getCustomMapSqlParameterSource()
                         .addValue("vmt_name", name).addValue("user_id", 
userID).addValue("is_filtered", isFiltered));
@@ -274,4 +275,10 @@
     protected ParameterizedRowMapper<VmTemplate> createEntityRowMapper() {
         return VMTemplateRowMapper.instance;
     }
+
+    @Override
+    protected MapSqlParameterSource createNameParameterMapper(String name) {
+        return getCustomMapSqlParameterSource()
+                .addValue("vmt_name", name).addValue("user_id", 
null).addValue("is_filtered", false);
+    }
 }
diff --git 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmTemplateDAOTest.java
 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmTemplateDAOTest.java
index 7a62876..6f10121 100644
--- 
a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmTemplateDAOTest.java
+++ 
b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmTemplateDAOTest.java
@@ -22,6 +22,7 @@
     private static final int NUMBER_OF_TEMPLATES = 3;
     private static final int NUMBER_OF_TEMPLATES_FOR_PRIVELEGED_USER = 1;
     private static final Guid EXISTING_TEMPLATE_ID = new 
Guid("1b85420c-b84c-4f29-997e-0eb674b40b79");
+    private static final String EXISTING_TEMPLATE_NAME = "existingTemplate";
     private static final Guid DELETABLE_TEMPLATE_ID = new 
Guid("1b85420c-b84c-4f29-997e-0eb674b40b80");
     private static final Guid STORAGE_DOMAIN_ID = new 
Guid("72e3a666-89e1-4005-a7ca-f7548004a9ab");
     private static final Guid VDS_GROUP_ID = new 
Guid("b399944a-81ab-4ec5-8266-e19ba7c3c9d1");
@@ -280,6 +281,50 @@
     }
 
     /**
+     * Asserts that the right template is returned with no filtering
+     */
+    @Test
+    public void testGetByName() {
+        VmTemplate result = dao.getByName(EXISTING_TEMPLATE_NAME);
+        assertGetResult(result);
+    }
+
+    /**
+     * Asserts that the a template that should exist does exist
+     */
+    @Test
+    public void testExistsWithName() {
+        assertTrue("Template should exist", 
dao.existsWithName(EXISTING_TEMPLATE_NAME));
+    }
+
+    /**
+     * Asserts that the right template is returned for a privileged user with 
filtering enabled
+     */
+    @Test
+    public void testGetByNameWithPermissionsForPriviligedUser() {
+        VmTemplate result = dao.getByName(EXISTING_TEMPLATE_NAME, 
PRIVILEGED_USER_ID, true);
+        assertGetResult(result);
+    }
+
+    /**
+     * Asserts that no result is returned for a non privileged user with 
filtering enabled
+     */
+    @Test
+    public void testGetByNameWithPermissionsForUnpriviligedUser() {
+        VmTemplate result = dao.getByName(EXISTING_TEMPLATE_NAME, 
UNPRIVILEGED_USER_ID, true);
+        assertNull(result);
+    }
+
+    /**
+     * Asserts that the right template is returned for a non privileged user 
with filtering disabled
+     */
+    @Test
+    public void testGetByNameWithPermissionsDisabledForUnpriviligedUser() {
+        VmTemplate result = dao.getByName(EXISTING_TEMPLATE_NAME, 
UNPRIVILEGED_USER_ID, false);
+        assertGetResult(result);
+    }
+
+    /**
      * Asserts that the correct template is returned for the given network id
      */
     @Test
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 3f858bc..c3c8550 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -1075,7 +1075,7 @@
         <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b79</value>
             <value>TEMPLATE</value>
-            <value>1</value>
+            <value>existingTemplate</value>
             <value>512</value>
             <value>00000000-0000-0000-0000-000000000000</value>
             <value>1</value>
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index 101fdc4..9d3bf5a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -12,14 +12,15 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.EventNotificationEntity;
 import org.ovirt.engine.core.common.VdcEventNotificationUtils;
+import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.DbUser;
 import org.ovirt.engine.core.common.businessentities.Disk;
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.DiskInterface;
-import org.ovirt.engine.core.common.businessentities.ImageType;
 import org.ovirt.engine.core.common.businessentities.IVdcQueryable;
+import org.ovirt.engine.core.common.businessentities.ImageType;
 import org.ovirt.engine.core.common.businessentities.LUNs;
 import org.ovirt.engine.core.common.businessentities.Quota;
 import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum;
@@ -59,7 +60,6 @@
 import org.ovirt.engine.core.common.queries.GetAllAttachableDisks;
 import org.ovirt.engine.core.common.queries.GetAllDisksByVmIdParameters;
 import 
org.ovirt.engine.core.common.queries.GetAllFromExportDomainQueryParameters;
-import 
org.ovirt.engine.core.common.queries.GetImagesListByStoragePoolIdParameters;
 import org.ovirt.engine.core.common.queries.GetAllServerCpuListParameters;
 import org.ovirt.engine.core.common.queries.GetAllVdsByStoragePoolParameters;
 import org.ovirt.engine.core.common.queries.GetAllVmSnapshotsByVmIdParameters;
@@ -69,6 +69,7 @@
 import org.ovirt.engine.core.common.queries.GetDomainListParameters;
 import 
org.ovirt.engine.core.common.queries.GetEntitiesWithPermittedActionParameters;
 import 
org.ovirt.engine.core.common.queries.GetExistingStorageDomainListParameters;
+import 
org.ovirt.engine.core.common.queries.GetImagesListByStoragePoolIdParameters;
 import org.ovirt.engine.core.common.queries.GetLunsByVgIdParameters;
 import 
org.ovirt.engine.core.common.queries.GetPermittedStorageDomainsByStoragePoolIdParameters;
 import 
org.ovirt.engine.core.common.queries.GetStorageDomainsByConnectionParameters;
@@ -89,8 +90,8 @@
 import 
org.ovirt.engine.core.common.queries.GetVmsRunningOnOrMigratingToVdsParameters;
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.InterfaceAndIdQueryParameters;
+import 
org.ovirt.engine.core.common.queries.IsEntityWithSameNameExistsParameters;
 import 
org.ovirt.engine.core.common.queries.IsVmPoolWithSameNameExistsParameters;
-import 
org.ovirt.engine.core.common.queries.IsVmTemlateWithSameNameExistParameters;
 import org.ovirt.engine.core.common.queries.IsVmWithSameNameExistParameters;
 import 
org.ovirt.engine.core.common.queries.MultilevelAdministrationByAdElementIdParameters;
 import 
org.ovirt.engine.core.common.queries.MultilevelAdministrationByRoleIdParameters;
@@ -1240,8 +1241,8 @@
                 return source != null ? !((Boolean) source).booleanValue() : 
false;
             }
         };
-        Frontend.RunQuery(VdcQueryType.IsVmTemlateWithSameNameExist,
-                new IsVmTemlateWithSameNameExistParameters(name),
+        Frontend.RunQuery(VdcQueryType.IsEntityWithSameNameExists,
+                new IsEntityWithSameNameExistsParameters(name, 
VdcObjectType.VmTemplate),
                 aQuery);
     }
 


--
To view, visit http://gerrit.ovirt.org/13338
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I621c963110c8979b461b04502b3aab2455faf5b6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to