engine: StoragePool.getStatus/setStatus

Renamed StoragePool's getstatus() and setstatus(StoragePoolStatus) to
getStatus() and setStatus(StoragePoolStatus), respectively, as per the
proper Java naming conventions.

Change-Id: I88b301d8246f00564ab913cda08c6615da41272a
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Introducing VdcActionUtilsTest

Introducing a new test suite for VdcActionUtils before refactoring.

Change-Id: I87bd69a56814ee6613b4b8fb522e97aaf1aef6fe
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdcActionUtils: apply code formatter

Applied the project's code formatter in order to facilitate easier
editing of this class.

Change-Id: I08d4654699f7ebf554a6e987eab1d81cefb53d70
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdcActionUtils: Replace FQCNs with imports

Imported relevant classes to make the code more readable.

Change-Id: Iaf3c9a0137dbefff18fc13b05ffdb6b1acd3f83b
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdcActionUtils: Use EnumSets

Since all the objects handled by the Sets in this class are Enums, the
usage of HashSets was removed and replaced by EnumSets, which ensure
better performance.

Change-Id: I5c39153389c2f0c6988f136ea6c0b6d70c975854
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdcActionUtils: declare variables as Maps

Declared variables as Maps instead of HashMaps, as per proper
abstraction guidelines.

Change-Id: I8e73672a57cad5c051ec875eef22e2d5f846eab5
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdcActionUtils: Unwrap else blocks

Unwrapped redundant else blocks in order to make the class more
readable.

Change-Id: I475e1c4a99ba004bc3ebe2182a7351a0d28dcbda
Signed-off-by: Allon Mureinik <amureini@redhat.com>
engine: VdcActionUtils: method names

Rename methods to start with lower case letters, as per proper Java
convention.

Change-Id: I73dd561cffc4438d8a7014d54a42709cb30ac51e
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdcActionUtils: Remove null check

Removed a redundant null check from VdcActionUtils.getStatusProperty.

getStatusProperty is a private method, only called from canExecute.
Before applying getStatusProperty to a, a.getClass() is called, meaning
that a is clearly not null, and therefore this check is redundant.

Change-Id: I07bc2eeabe676bad8175010100e24bfd9fc05d31
Signed-off-by: Allon Mureinik <amureini@redhat.com>
engine: VdcActionUtils: Remove reflection

Improved VdcActionUtils performance and readability by removing the
logic implemented by reflection and instead depend on proper Java
interfaces.

This patch includes:
1. A new interface, BusinessEntityWithStatus<?, ?> which could be
   applied to any BusinessEntity<?> which has a notion of a status.
2. Applying the BusinessEntityWithStatus interface to VM, VmTemplate,
   VDS and StorageDoamin, which are used by VdcActionUtils.
3. Applying the BusinessEntityWithStatus interface to StoragePool,
   which is not used by VdcActionUtils, as a negative test case.
4. Updating the test case accordingly.

Benefits of this approach:
1. Less programmer errors - some of the validations are done in compile
   time instead of runtime (i.e., you cannot pass any object to
   VdcActionUtils.canExecute, only classes that implement
   BusinessEntityWithStatus.
2. Better performance - no usage of reflection, which is known to have
   a performance penalty.
3. The code is more straight forward, and easier to understand.

Change-Id: I4b1c3857e1237bef9fc1af96e96043677b2debd4
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: VdsDynamic: [get|set]status->[get|set]Status

Renamed getstatus() and setstatus(VdsStatus) to getStatus() and
setStatus(VdsStatus) in the VdsDynamic class, as per the proper Java
convention.

Change-Id: Ifeb38f61fca9f5d92b168dd2e864e780ea46f762
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: StoragePoolIsoMap: rename status methods

Ranamed getstatus() and setstatus(StorageDomainStatus) to
getStatus() and setStatus(StorageDomainStatus) in the
StoragePoolIsoMap class, as per the proper Java convention.

Change-Id: I01e37d7c6bcf6f7e55ed6ea5d43c0eb333f46c3a
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: Apply BusinessEntityWithStatus

Applied the newly introduced BusinessEntityWithStatus to all the
relevant BusinessEntities, for clearness.

Change-Id: Ie53c03ab3b8be286ac7cbe9fcd8619923dc4350d
Signed-off-by: Allon Mureinik <amureini@redhat.com>
core: simpler syntax for snapshotEntityStatus

Added the
CompensationContext#snapshotEntityStatus(BusinessEntityWithStatus)
method and used it wherever possible.

Rationale and benefits:
1. Most of the time (i.e., all the calls except one), when taking a
   snapshot of an entity's status, you use the status property of the
   entity, which makes for an annoying call:
   getCompensationContext().snapshotEntityStatus(e, e.getStatus());
   The proposed syntax is more straight-forward and simpler to
   understand:
   getCompensationContext().snapshotEntityStatus(e);

2. There is no type safety in the original syntax, whereas the new
   syntax offers some minimal sanity validation (e.g., when taking
   a snapshot of a VM's status, you know the status is represented
   by the VMStatus enum).

Change-Id: Ib074a96e93f1c68637306b670b70983f26042514
Signed-off-by: Allon Mureinik <amureini@redhat.com>