generateTemplates(GenerationO
templates.addAll(results);
}
- GenerationUnit generationUnit = GenerationUnit.forResource(work.getNodeGenerationUnits(), options.getContext().getNode());
-
+ GenerationUnit.forResource(work.getNodeGenerationUnits(), options.getContext().getNode());
for (GenerationUnit unit : work.getNodeGenerationUnits()) {
if(!unit.isTemplateGenerationDisabled()) {
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/globalfunction/entity/GlobalFunctionEntityTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/globalfunction/entity/GlobalFunctionEntityTest.java
index 2cb971435..d0f01c838 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/globalfunction/entity/GlobalFunctionEntityTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/globalfunction/entity/GlobalFunctionEntityTest.java
@@ -20,7 +20,6 @@
package ch.puzzle.itc.mobiliar.business.globalfunction.entity;
-import ch.puzzle.itc.mobiliar.business.globalfunction.entity.GlobalFunctionEntity;
import org.junit.Test;
import static org.junit.Assert.*;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/issues/Issue6111RelationIdentifierTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/issues/Issue6111RelationIdentifierTest.java
index ad36d6d0d..a9fa4cb9c 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/issues/Issue6111RelationIdentifierTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/issues/Issue6111RelationIdentifierTest.java
@@ -52,7 +52,6 @@ public class Issue6111RelationIdentifierTest extends TemplateProcessorBaseTest result = service.getAppServersWithApplications("app", null, release1);
-
+ service.getAppServersWithApplications("app", null, release1);
}
}
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServicePersistenceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServicePersistenceTest.java
index 84c272dea..b44aefdaa 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServicePersistenceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServicePersistenceTest.java
@@ -51,7 +51,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceFactory;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceTypeEntity;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition;
import ch.puzzle.itc.mobiliar.test.testrunner.PersistenceTestRunner;
@@ -95,7 +94,6 @@ public void before() {
* The propertyDescriptor for 'port' for resource Copy should not be the same as for Origin!
*
* @throws ResourceNotFoundException
- * @throws GeneralDBException
*/
@Test
public void test_propertyOverwrittenInContext() throws ForeignableOwnerViolationException, AMWException {
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServiceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServiceTest.java
index d8092b2ca..4ec0c5131 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServiceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/CopyResourceDomainServiceTest.java
@@ -34,7 +34,7 @@
import org.junit.Before;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
/**
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceGroupRepositoryTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceGroupRepositoryTest.java
index 9f056d340..4cf11ec32 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceGroupRepositoryTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceGroupRepositoryTest.java
@@ -27,7 +27,6 @@
import ch.puzzle.itc.mobiliar.business.usersettings.entity.FavoriteResourceEntity;
import ch.puzzle.itc.mobiliar.business.usersettings.entity.UserSettingsEntity;
import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceTypeNotFoundException;
import ch.puzzle.itc.mobiliar.common.util.ApplicationServerContainer;
@@ -114,7 +113,7 @@ private void init() {
}
@Test
- public void test_loadGroupsForType() throws GeneralDBException, ElementAlreadyExistsException,
+ public void test_loadGroupsForType() throws ElementAlreadyExistsException,
ResourceNotFoundException, ResourceTypeNotFoundException {
// given
init();
@@ -146,7 +145,7 @@ public void test_loadGroupsForType() throws GeneralDBException, ElementAlreadyEx
}
@Test
- public void test_loadGroupsForType_myAmw() throws GeneralDBException, ElementAlreadyExistsException, ResourceNotFoundException,
+ public void test_loadGroupsForType_myAmw() throws ElementAlreadyExistsException, ResourceNotFoundException,
ResourceTypeNotFoundException {
// given
init();
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceImportServiceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceImportServiceTest.java
index eae8a43cf..fa072ce84 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceImportServiceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/control/ResourceImportServiceTest.java
@@ -26,7 +26,6 @@
import ch.puzzle.itc.mobiliar.builders.ReleaseEntityBuilder;
import ch.puzzle.itc.mobiliar.common.util.ConfigKey;
-import ch.puzzle.itc.mobiliar.common.util.ConfigurationService;
import org.junit.Before;
import org.junit.Test;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/entity/ResourceEntityTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/entity/ResourceEntityTest.java
index ba4cc0d18..6f220d8cb 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/entity/ResourceEntityTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcegroup/entity/ResourceEntityTest.java
@@ -34,7 +34,7 @@
import ch.puzzle.itc.mobiliar.common.util.ApplicationServerContainer;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Matchers;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -74,7 +74,7 @@ public void testAddProvidedResourceRelation() {
@Test
public void testGetRelationById() {
// given
- Mockito.when(resourceEntity.getRelationById(Matchers.anyInt(), Matchers.anySet())).thenCallRealMethod();
+ Mockito.when(resourceEntity.getRelationById(ArgumentMatchers.anyInt(), ArgumentMatchers.anySet())).thenCallRealMethod();
final int slaveResourceId = 21;
@@ -96,7 +96,7 @@ public void testGetRelationById() {
@Test
public void testGetMasterRelation() {
// given
- Mockito.when(resourceEntity.getMasterRelation(Matchers.any(ResourceEntity.class), Matchers.anySet())).thenCallRealMethod();
+ Mockito.when(resourceEntity.getMasterRelation(ArgumentMatchers.any(ResourceEntity.class), ArgumentMatchers.anySet())).thenCallRealMethod();
final int slaveResourceId = 21;
final Set relations = new HashSet();
@@ -131,7 +131,7 @@ private ConsumedResourceRelationEntity createConsumedResourceRelation(final int
}
private ConsumedResourceRelationEntity prepareConsumedSlaveRelationTest() {
- Mockito.when(resourceEntity.getConsumedSlaveRelation(Matchers.any(ResourceEntity.class))).thenCallRealMethod();
+ Mockito.when(resourceEntity.getConsumedSlaveRelation(ArgumentMatchers.any(ResourceEntity.class))).thenCallRealMethod();
final ConsumedResourceRelationEntity consumedResourceRelationEntity = createConsumedResourceRelation(11, 12);
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/control/ResourceRelationServicePersistenceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/control/ResourceRelationServicePersistenceTest.java
index 49c744568..e30c4eb9b 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/control/ResourceRelationServicePersistenceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/control/ResourceRelationServicePersistenceTest.java
@@ -31,7 +31,6 @@
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ProvidedResourceRelationEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ResourceRelationTypeEntity;
import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.test.testrunner.PersistenceTestRunner;
import org.junit.Before;
@@ -190,7 +189,7 @@ public void test_getProvidedRelationsByMasterAndSlave() {
}
@Test
- public void test_doAddResourceRelationForAllReleases() throws GeneralDBException, ResourceNotFoundException, ElementAlreadyExistsException {
+ public void test_doAddResourceRelationForAllReleases() throws ResourceNotFoundException, ElementAlreadyExistsException {
// given
ResourceEntityBuilder resourceEntityBuilder = new ResourceEntityBuilder();
ResourceEntity master = resourceEntityBuilder.buildApplicationEntity("master", null, null, false);
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/entity/ConsumedResourceRelationEntityTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/entity/ConsumedResourceRelationEntityTest.java
index 013ebb211..da219432a 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/entity/ConsumedResourceRelationEntityTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/resourcerelation/entity/ConsumedResourceRelationEntityTest.java
@@ -22,7 +22,6 @@
import ch.puzzle.itc.mobiliar.builders.ResourceEntityBuilder;
import ch.puzzle.itc.mobiliar.builders.ResourceRelationEntityBuilder;
-import ch.puzzle.itc.mobiliar.builders.TargetPlatformEntityBuilder;
import ch.puzzle.itc.mobiliar.business.resourcegroup.control.CopyResourceDomainService;
import ch.puzzle.itc.mobiliar.business.resourcegroup.control.CopyResourceDomainServiceTestHelper;
import ch.puzzle.itc.mobiliar.business.resourcegroup.control.CopyUnit;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/security/boundary/PermissionBoundaryTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/security/boundary/PermissionBoundaryTest.java
index 9ca053ca9..04892f93a 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/security/boundary/PermissionBoundaryTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/security/boundary/PermissionBoundaryTest.java
@@ -465,7 +465,7 @@ public void shouldDelegatePermissionAndActionCheckToPermissionService() {
@Test(expected=IllegalArgumentException.class)
public void shouldThrowAnExceptionIfRequestedPermissionDoesNotExist() {
// given // when // then
- boolean result = permissionBoundary.hasPermissionForResourceType("NotAPermission", "CREATE", "APP");
+ permissionBoundary.hasPermissionForResourceType("NotAPermission", "CREATE", "APP");
}
@Test(expected=IllegalArgumentException.class)
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/control/ShakedownTestExecutionResultHandlerServiceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/control/ShakedownTestExecutionResultHandlerServiceTest.java
index 36583baf4..232dce0af 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/control/ShakedownTestExecutionResultHandlerServiceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/control/ShakedownTestExecutionResultHandlerServiceTest.java
@@ -31,8 +31,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import ch.puzzle.itc.mobiliar.business.shakedown.control.ShakedownTestExecutionResultHandlerService;
-import ch.puzzle.itc.mobiliar.business.shakedown.control.ShakedownTestService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/xmlmodel/STSTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/xmlmodel/STSTest.java
index 2c9445641..2ec9f1693 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/xmlmodel/STSTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/shakedown/xmlmodel/STSTest.java
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.List;
-import ch.puzzle.itc.mobiliar.business.shakedown.xmlmodel.STS;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftLinkRelationServiceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftLinkRelationServiceTest.java
index c26d70032..9865258fb 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftLinkRelationServiceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftLinkRelationServiceTest.java
@@ -46,9 +46,9 @@ public void init() {
public void shouldSetResourceIdInThreadLocal() {
// given
ResourceEntity resourceEntity = ResourceEntityBuilder.createResourceEntity("MyResource", 500);
- TypedQuery query = mock(TypedQuery.class);
+ TypedQuery query = mock(TypedQuery.class);
when(query.getResultList()).thenReturn(Collections.emptyList());
- when(query.setParameter(anyString(), anyObject())).thenReturn(query);
+ when(query.setParameter(anyString(), any())).thenReturn(query);
when(entityManager.createQuery(any(String.class), eq(SoftlinkRelationEntity.class))).thenReturn(query);
// when
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftlinkRelationServicePersistenceTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftlinkRelationServicePersistenceTest.java
index 8a1c704ee..8b76314c1 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftlinkRelationServicePersistenceTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/softlinkRelation/control/SoftlinkRelationServicePersistenceTest.java
@@ -47,9 +47,9 @@
import java.util.Date;
import java.util.logging.Logger;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.verify;
/**
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/BaseRepositoryTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/BaseRepositoryTest.java
index be9803bc9..08db7e062 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/BaseRepositoryTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/BaseRepositoryTest.java
@@ -31,7 +31,7 @@
import java.util.List;
-import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/SessionContextIntegrationTestProducer.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/SessionContextIntegrationTestProducer.java
index 4d1c0cfca..86850f7bd 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/SessionContextIntegrationTestProducer.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/SessionContextIntegrationTestProducer.java
@@ -20,10 +20,9 @@
package ch.puzzle.itc.mobiliar.business.utils;
-import org.mockito.Matchers;
+import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
-import javax.annotation.Resource;
import javax.ejb.SessionContext;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.Specializes;
@@ -41,7 +40,7 @@ public class SessionContextIntegrationTestProducer extends SessionContextProduce
public SessionContext createSessionContext(){
sessionContext = Mockito.mock(SessionContext.class);
- Mockito.when(sessionContext.isCallerInRole(Matchers.anyString())).thenReturn(true);
+ Mockito.when(sessionContext.isCallerInRole(ArgumentMatchers.anyString())).thenReturn(true);
return sessionContext;
}
}
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/ValidationHelperTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/ValidationHelperTest.java
index b9a9a1892..d42d292d5 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/ValidationHelperTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/ValidationHelperTest.java
@@ -22,6 +22,8 @@
import org.junit.Test;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+
import static org.junit.Assert.*;
public class ValidationHelperTest {
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/database/LiquibaseChangeSetTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/database/LiquibaseChangeSetTest.java
index ed1002bd5..1867a657d 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/database/LiquibaseChangeSetTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/business/utils/database/LiquibaseChangeSetTest.java
@@ -13,10 +13,7 @@
import org.junit.Test;
import java.io.File;
-import java.io.IOException;
-import java.net.URL;
import java.sql.DriverManager;
-import java.sql.SQLException;
import java.util.List;
import static junit.framework.TestCase.fail;
@@ -30,7 +27,7 @@ public class LiquibaseChangeSetTest {
@Test
- public void shouldLoadInitialDataSetInEmptyDatabase() throws LiquibaseException, SQLException, ClassNotFoundException {
+ public void shouldLoadInitialDataSetInEmptyDatabase() throws Exception {
// given
Class.forName("org.h2.Driver");
conn = DriverManager.getConnection("jdbc:h2:mem:testdata", "sa", "");
@@ -41,6 +38,7 @@ public void shouldLoadInitialDataSetInEmptyDatabase() throws LiquibaseException,
//when
liquibase.update(new Contexts(), new LabelExpression());
+ liquibase.close();
// then must not fail
if(conn !=null) {
conn.close();
@@ -48,7 +46,7 @@ public void shouldLoadInitialDataSetInEmptyDatabase() throws LiquibaseException,
}
@Test
- public void shouldNotHaveAnyOpenChangeSets() throws LiquibaseException, SQLException, ClassNotFoundException, IOException {
+ public void shouldNotHaveAnyOpenChangeSets() throws Exception {
// given
File testDB = EntityManagerProducerIntegrationTestImpl.copyIntegrationTestDB("amwFileDbIntegrationOpenChangeSets.mv.db");
conn = DriverManager.getConnection("jdbc:h2:file:" + testDB.getParent().toString() + "/amwFileDbIntegrationOpenChangeSets", "sa", "");
@@ -72,7 +70,8 @@ public void shouldNotHaveAnyOpenChangeSets() throws LiquibaseException, SQLExcep
fail("There are open Database Changesets on the local H2 Database, that can be applied without error, run AMW_db_scripts/update_h2_test_db.sh to apply them directly");
}
- if(conn !=null) {
+ liquibase.close();
+ if(conn != null) {
conn.close();
}
}
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/release/ReleaseTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/release/ReleaseTest.java
index 612f8a808..7b81dd940 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/release/ReleaseTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/release/ReleaseTest.java
@@ -30,7 +30,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.security.control.PermissionService;
import ch.puzzle.itc.mobiliar.business.utils.Identifiable;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.common.exception.TemplatePropertyException;
import ch.puzzle.itc.mobiliar.test.PersistingEntityBuilder;
@@ -92,7 +91,7 @@ public void before() {
}
@Test
- public void testPropertiesAndRevisions() throws TemplatePropertyException, ResourceNotFoundException, GeneralDBException {
+ public void testPropertiesAndRevisions() throws TemplatePropertyException, ResourceNotFoundException {
AMWTemplateExceptionHandler templateExceptionHandler = new AMWTemplateExceptionHandler();
List list = readProperties(templateExceptionHandler);
PropertyEntity property = list.get(0);
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/Entity/Color.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/Entity/Color.java
index b6d74859e..0f870b62d 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/Entity/Color.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/Entity/Color.java
@@ -20,8 +20,6 @@
package ch.puzzle.itc.mobiliar.test.Entity;
-import lombok.Getter;
-
import javax.persistence.*;
@Entity
@@ -37,6 +35,7 @@ public class Color {
@Version
private long v;
+ @SuppressWarnings("unused")
private Color() {
// used by JPA
}
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/EntityBuilder.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/EntityBuilder.java
index ca7a459ef..d8df6cafa 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/EntityBuilder.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/EntityBuilder.java
@@ -21,7 +21,6 @@
package ch.puzzle.itc.mobiliar.test;
import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwner;
-import ch.puzzle.itc.mobiliar.business.generator.control.GeneratorUtils;
import ch.puzzle.itc.mobiliar.business.environment.entity.ContextEntity;
import ch.puzzle.itc.mobiliar.business.environment.entity.ContextTypeEntity;
import ch.puzzle.itc.mobiliar.business.property.entity.PropertyDescriptorEntity;
diff --git a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/PersistingEntityBuilderTest.java b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/PersistingEntityBuilderTest.java
index 2b5a467f6..01f87eabb 100644
--- a/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/PersistingEntityBuilderTest.java
+++ b/AMW_business/src/test/java/ch/puzzle/itc/mobiliar/test/PersistingEntityBuilderTest.java
@@ -30,7 +30,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceGroupEntity;
import ch.puzzle.itc.mobiliar.business.security.control.PermissionService;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.TemplatePropertyException;
import ch.puzzle.itc.mobiliar.test.testrunner.PersistenceTestRunner;
import org.junit.Before;
@@ -76,7 +75,7 @@ public void before() {
}
@Test
- public void testAmw() throws GeneralDBException {
+ public void testAmw() {
builder = new PersistingEntityBuilder(entityManager).buildAmw();
assertEquals(16, builder.getResourceCount(ResourceEntity.class));
}
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/GeneralDBException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/GeneralDBException.java
deleted file mode 100644
index f3389035a..000000000
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/GeneralDBException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * AMW - Automated Middleware allows you to manage the configurations of
- * your Java EE applications on an unlimited number of different environments
- * with various versions, including the automated deployment of those apps.
- * Copyright (C) 2013-2016 by Puzzle ITC
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package ch.puzzle.itc.mobiliar.common.exception;
-
-import javax.ejb.ApplicationException;
-
-@ApplicationException(rollback=true)
-public class GeneralDBException extends Exception{
-
- // Diese Exception dient zum Markieren, falls ein command/Manipulation auf der DB fehlgeschlagen hat
-
- public static final String ERRORMESSAGE = "Something went wrong with the database access. Please contact your application administrator.";
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public GeneralDBException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public GeneralDBException(String message) {
- this(message, null);
- }
-
- public String getErrorMessage(){
- return ERRORMESSAGE;
- }
-
-}
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/NotFoundException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/NotFoundException.java
index 8966e96b1..a376c997c 100644
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/NotFoundException.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/NotFoundException.java
@@ -20,6 +20,9 @@
package ch.puzzle.itc.mobiliar.common.exception;
+/**
+ * General exception if an object isn't found in DB
+ */
public class NotFoundException extends AMWException {
private static final long serialVersionUID = 1L;
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PermissionNotFoundException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PermissionNotFoundException.java
index 608fc57bf..595120999 100644
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PermissionNotFoundException.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PermissionNotFoundException.java
@@ -20,7 +20,7 @@
package ch.puzzle.itc.mobiliar.common.exception;
-public class PermissionNotFoundException extends AMWException{
+public class PermissionNotFoundException extends NotFoundException{
private static final long serialVersionUID = 1L;
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PropertyTypeNotFoundException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PropertyTypeNotFoundException.java
index bd23ac48e..37581f4b5 100644
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PropertyTypeNotFoundException.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/PropertyTypeNotFoundException.java
@@ -20,7 +20,7 @@
package ch.puzzle.itc.mobiliar.common.exception;
-public class PropertyTypeNotFoundException extends AMWException{
+public class PropertyTypeNotFoundException extends NotFoundException{
private static final long serialVersionUID = 1L;
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceNotFoundException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceNotFoundException.java
index b79a5a307..9b6a546cd 100644
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceNotFoundException.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceNotFoundException.java
@@ -20,12 +20,10 @@
package ch.puzzle.itc.mobiliar.common.exception;
-public class ResourceNotFoundException extends AMWException {
- // Wird geworfen, falls ein Löschen einer Resource auf der DB nicht möglich ist (f.ex. zu löschendes Item nicht existiert etc)
-
- /**
- *
- */
+/**
+ * Exception that is thrown if a resource isn't found. For other types use the general NotFoundException
+ */
+public class ResourceNotFoundException extends NotFoundException {
private static final long serialVersionUID = 1L;
public ResourceNotFoundException(String message){
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceTypeNotFoundException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceTypeNotFoundException.java
index 155334676..60c3afda2 100644
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceTypeNotFoundException.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ResourceTypeNotFoundException.java
@@ -20,11 +20,8 @@
package ch.puzzle.itc.mobiliar.common.exception;
-public class ResourceTypeNotFoundException extends AMWException {
+public class ResourceTypeNotFoundException extends NotFoundException {
- /**
- *
- */
private static final long serialVersionUID = 1L;
public ResourceTypeNotFoundException(String message) {
diff --git a/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/utils/ValidationException.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ValidationException.java
similarity index 86%
rename from AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/utils/ValidationException.java
rename to AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ValidationException.java
index c33a66046..fe113572a 100644
--- a/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/utils/ValidationException.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/exception/ValidationException.java
@@ -18,12 +18,15 @@
* along with this program. If not, see .
*/
-package ch.puzzle.itc.mobiliar.business.utils;
+package ch.puzzle.itc.mobiliar.common.exception;
import lombok.Getter;
-public class ValidationException extends Exception {
+/**
+ * Thrown it validation of an object/resource fails (string validation, business logic validation, etc.).
+ */
+public class ValidationException extends AMWException {
/**
* Use the causing object to pass information of failure
diff --git a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/util/ConfigKey.java b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/util/ConfigKey.java
index 758b6b9fa..74862e9d4 100644
--- a/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/util/ConfigKey.java
+++ b/AMW_commons/src/main/java/ch/puzzle/itc/mobiliar/common/util/ConfigKey.java
@@ -12,7 +12,7 @@ public enum ConfigKey {
LOGS_PATH("amw.logsPath", "AMW_LOGSPATH", false),
/** Age of logs to be deleted in minutes */
- LOGS_CLEANUP_AGE("amw.logsLeanupAge", "AMW_LOGSLEANUPAGE", new Integer(7*24*60).toString(), false),
+ LOGS_CLEANUP_AGE("amw.logsLeanupAge", "AMW_LOGSLEANUPAGE", Integer.valueOf(7*24*60).toString(), false),
LOGS_CLEANUP_SCHEDULER_DISABLED("amw.logsCleanupSchedulerDisabled", "AMW_LOGSCLEANUPSCHEDULERDISABLED", "false", false),
/** Path where the generator writes the files */
GENERATOR_PATH("amw.generatorPath", "AMW_GENERATORPATH", false),
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRest.java
index edef2cdd6..828e654f6 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRest.java
@@ -12,8 +12,8 @@
import ch.puzzle.itc.mobiliar.business.security.control.PermissionService;
import ch.puzzle.itc.mobiliar.business.security.entity.Action;
import ch.puzzle.itc.mobiliar.business.security.entity.Permission;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import io.swagger.annotations.Api;
import javax.inject.Inject;
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/RESTApplication.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/RESTApplication.java
index 13e4a6b97..5299a032d 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/RESTApplication.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/RESTApplication.java
@@ -71,8 +71,8 @@ private void addRestResourceClasses(Set> resources) {
resources.add(NoResultExceptionMapper.class);
resources.add(NotAuthorizedExceptionMapper.class);
resources.add(ValidationExceptionMapper.class);
+ resources.add(NotFoundExceptionMapper.class);
resources.add(UncaughtExceptionMapper.class);
- resources.add(ResourceNotFoundExceptionMapper.class);
resources.add(ServerTupleCSVBodyWriter.class);
resources.add(HealthCheck.class);
resources.add(SettingsRest.class);
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/auditview/AuditViewRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/auditview/AuditViewRest.java
index d101f057b..88dc9f1ac 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/auditview/AuditViewRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/auditview/AuditViewRest.java
@@ -3,7 +3,6 @@
import ch.mobi.itc.mobiliar.rest.dtos.AuditViewEntryDTO;
import ch.puzzle.itc.mobiliar.business.auditview.boundary.AuditViewBoundary;
import ch.puzzle.itc.mobiliar.business.property.boundary.PropertyEditor;
-import ch.puzzle.itc.mobiliar.business.property.entity.ResourceEditProperty;
import ch.puzzle.itc.mobiliar.business.auditview.entity.AuditViewEntry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -60,12 +59,6 @@ public int compare(AuditViewEntryDTO o1, AuditViewEntryDTO o2) {
});
}
- private List removePropertyDescriptors(List propertiesForResourceIncludingDescriptors, List propertyDescriptors) {
- ArrayList properties = new ArrayList<>(propertiesForResourceIncludingDescriptors);
- properties.removeAll(propertyDescriptors);
- return properties;
- }
-
private List createDtosAndSortByTimestamp(List auditlogForResource) {
List dtos = new ArrayList<>(auditlogForResource.size());
for (AuditViewEntry auditViewEntry : auditlogForResource) {
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentsRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentsRest.java
index 0232a94c2..a63dde033 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentsRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentsRest.java
@@ -596,9 +596,6 @@ public Response updateNodeJobResult(
@ApiOperation(value = "Update the DeploymentDate of a Deployment - used by Angular")
public Response changeDeploymentDate(@ApiParam("deployment Id") @PathParam("id") Integer deploymentId, @ApiParam("New date") long date) {
Date newDate = new Date(date);
- if (newDate == null) {
- return Response.status(Response.Status.BAD_REQUEST).entity(new ExceptionDto("Invalid deployment date")).build();
- }
try {
deploymentBoundary.changeDeploymentDate(deploymentId, newDate);
} catch (RuntimeException e) {
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/TemplateDTO.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/TemplateDTO.java
index 9888f2fa4..a826ebda5 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/TemplateDTO.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/dtos/TemplateDTO.java
@@ -38,6 +38,7 @@
@NoArgsConstructor
public class TemplateDTO {
+ private Integer id;
private String relatedResourceIdentifier;
private String name;
private String targetPath;
@@ -45,12 +46,15 @@ public class TemplateDTO {
private String fileContent;
public TemplateDTO(TemplateDescriptorEntity template){
+ this.id = template.getId();
this.relatedResourceIdentifier = template.getRelatedResourceIdentifier();
this.name = template.getName();
this.targetPath = template.getTargetPath();
targetPlatforms = new HashSet<>();
- for (ResourceGroupEntity pf : template.getTargetPlatforms()) {
- targetPlatforms.add(pf.getName());
+ if (template.getTargetPlatforms() != null) {
+ for (ResourceGroupEntity pf : template.getTargetPlatforms()) {
+ targetPlatforms.add(pf.getName());
+ }
}
this.fileContent = template.getFileContent();
}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/EJBExceptionMapper.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/EJBExceptionMapper.java
index a4c1536e1..c980f38a2 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/EJBExceptionMapper.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/EJBExceptionMapper.java
@@ -40,6 +40,6 @@ public Response toResponse(EJBException exception) {
if (exceptionMapper != null) {
return exceptionMapper.toResponse(causedByException);
}
- return Response.serverError().entity(causedByException).build();
+ return Response.serverError().entity(exception).build();
}
}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ExceptionDto.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ExceptionDto.java
index 1e0327f5d..37457d728 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ExceptionDto.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ExceptionDto.java
@@ -29,7 +29,7 @@ public class ExceptionDto {
private String detail;
public ExceptionDto(String message) {
- this(message, "");
+ this(message, null);
}
public ExceptionDto(String message, String detail) {
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ResourceNotFoundExceptionMapper.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/NotFoundExceptionMapper.java
similarity index 83%
rename from AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ResourceNotFoundExceptionMapper.java
rename to AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/NotFoundExceptionMapper.java
index 95d9f5865..8a7bfba5a 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ResourceNotFoundExceptionMapper.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/NotFoundExceptionMapper.java
@@ -24,13 +24,13 @@
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
-import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.NotFoundException;
@Provider
-public class ResourceNotFoundExceptionMapper implements ExceptionMapper {
+public class NotFoundExceptionMapper implements ExceptionMapper {
@Override
- public Response toResponse(ResourceNotFoundException exception) {
+ public Response toResponse(NotFoundException exception) {
return Response.status(Response.Status.NOT_FOUND).entity(new ExceptionDto(exception)).build();
}
}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/UncaughtExceptionMapper.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/UncaughtExceptionMapper.java
index 8530d82d3..0c4b51642 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/UncaughtExceptionMapper.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/UncaughtExceptionMapper.java
@@ -1,33 +1,41 @@
-/*
- * AMW - Automated Middleware allows you to manage the configurations of
- * your Java EE applications on an unlimited number of different environments
- * with various versions, including the automated deployment of those apps.
- * Copyright (C) 2013-2016 by Puzzle ITC
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package ch.mobi.itc.mobiliar.rest.exceptions;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.ExceptionMapper;
-import javax.ws.rs.ext.Provider;
-
-@Provider
-public class UncaughtExceptionMapper implements ExceptionMapper {
- @Override
- public Response toResponse(Throwable exception) {
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ExceptionDto(exception)).build();
- }
-}
+/*
+ * AMW - Automated Middleware allows you to manage the configurations of
+ * your Java EE applications on an unlimited number of different environments
+ * with various versions, including the automated deployment of those apps.
+ * Copyright (C) 2013-2016 by Puzzle ITC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package ch.mobi.itc.mobiliar.rest.exceptions;
+
+import javax.inject.Inject;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+@Provider
+public class UncaughtExceptionMapper implements ExceptionMapper {
+ @Inject
+ private Logger log;
+
+ @Override
+ public Response toResponse(Throwable exception) {
+ log.log(Level.SEVERE, "Uncaught exception in rest call", exception);
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new ExceptionDto("Internal Server Error", "See log file for details")).build();
+ }
+}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ValidationExceptionMapper.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ValidationExceptionMapper.java
index 2dedcfda4..974be31b7 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ValidationExceptionMapper.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/exceptions/ValidationExceptionMapper.java
@@ -24,7 +24,7 @@
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
@Provider
public class ValidationExceptionMapper implements ExceptionMapper {
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/HostNamesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/HostNamesRest.java
index 9effebfc9..41d5b1ecc 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/HostNamesRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/HostNamesRest.java
@@ -41,7 +41,7 @@
import ch.puzzle.itc.mobiliar.business.property.boundary.PropertyEditor;
import ch.puzzle.itc.mobiliar.business.server.boundary.ServerView;
import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
@RequestScoped
@Path("/hostNames")
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRest.java
index cfb8f0ca3..d24f145b1 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRest.java
@@ -46,7 +46,7 @@
import ch.puzzle.itc.mobiliar.business.property.entity.ResourceEditProperty;
import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
@RequestScoped
@Path("/resources/{resourceGroupName}/{releaseName}/properties")
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRest.java
index 8d4a61934..338d508fc 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRest.java
@@ -42,8 +42,7 @@
import ch.puzzle.itc.mobiliar.business.property.entity.ResourceEditProperty;
import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.ResourceRelationLocator;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ConsumedResourceRelationEntity;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
-
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationTemplatesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationTemplatesRest.java
index c86d49798..f00c300bd 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationTemplatesRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationTemplatesRest.java
@@ -39,9 +39,9 @@
import ch.puzzle.itc.mobiliar.business.template.boundary.TemplateEditor;
import ch.puzzle.itc.mobiliar.business.template.control.TemplatesScreenDomainService;
import ch.puzzle.itc.mobiliar.business.template.entity.TemplateDescriptorEntity;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
+import ch.puzzle.itc.mobiliar.common.exception.NotFoundException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
/**
* Rest boundary for Resource-Relation-Templates
@@ -68,42 +68,55 @@ public class ResourceRelationTemplatesRest {
@GET
@ApiOperation(value = "Get one or all templates for a resource in a specific release")
- public List getResourceRelationTemplates( //
- @PathParam("resourceGroupName") String resourceGroupName,
- @PathParam("releaseName") String releaseName,
- @PathParam("relatedResourceGroupName") String relatedResourceGroupName,
- @PathParam("relatedReleaseName") String relatedReleaseName) throws ValidationException {
-
- return getResourceRelationTemplates(resourceGroupName, releaseName, relatedResourceGroupName, relatedReleaseName, "");
+ public List getResourceRelationTemplates(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName,
+ @PathParam("relatedResourceGroupName") String relatedResourceGroupName,
+ @PathParam("relatedReleaseName") String relatedReleaseName) throws ValidationException, ResourceNotFoundException {
+
+ List templates = getRelTemplates(resourceGroupName, releaseName,
+ relatedResourceGroupName, relatedReleaseName);
+ List templateDTOs = new ArrayList<>();
+ for (TemplateDescriptorEntity template : templates) {
+ TemplateDTO temp = new TemplateDTO(template);
+ templateDTOs.add(temp);
+ }
+ return templateDTOs;
}
@GET
@Path("/{templateName}")
@ApiOperation(value = "Get one or all templates for a resource in a specific release")
- public List getResourceRelationTemplates( //
- @PathParam("resourceGroupName") String resourceGroupName,
- @PathParam("releaseName") String releaseName,
- @PathParam("relatedResourceGroupName") String relatedResourceGroupName,
- @PathParam("relatedReleaseName") String relatedReleaseName,
- @PathParam("templateName") String templateName) throws ValidationException {
+ public TemplateDTO getResourceRelationTemplate(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName,
+ @PathParam("relatedResourceGroupName") String relatedResourceGroupName,
+ @PathParam("relatedReleaseName") String relatedReleaseName, @PathParam("templateName") String templateName)
+ throws ValidationException, NotFoundException {
+
+ List templates = getRelTemplates(resourceGroupName, releaseName,
+ relatedResourceGroupName, relatedReleaseName);
+
+ for (TemplateDescriptorEntity template : templates) {
+ if (templateName.equals(template.getName())) {
+ return new TemplateDTO(template);
+ }
+ }
+ throw new NotFoundException("Template not found");
+ }
+
+ private List getRelTemplates(String resourceGroupName, String releaseName,
+ String relatedResourceGroupName, String relatedReleaseName) throws ValidationException, ResourceNotFoundException {
List resRelList = resourceRelationLocator
.getResourceRelationList(resourceGroupName, releaseName, relatedResourceGroupName, relatedReleaseName);
List templates = new ArrayList<>();
for (ConsumedResourceRelationEntity resRel : resRelList) {
- try {
- List temp = templateService.getTemplatesForResourceRelation(resRel, false);
- for (TemplateDescriptorEntity t : temp) {
- t.setRelatedResourceIdentifier(resRel.getIdentifier());
- }
- templates.addAll(temp);
- } catch (ResourceNotFoundException | GeneralDBException e) {
- // ignore
+ List temp = templateService.getTemplatesForResourceRelation(resRel, false);
+ for (TemplateDescriptorEntity t : temp) {
+ t.setRelatedResourceIdentifier(resRel.getIdentifier());
}
+ templates.addAll(temp);
}
-
- return resourceTemplatesRest.getTemplateDTOs(templateName, templates);
+ return templates;
}
-
}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRest.java
index 433621473..f1c725b91 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRest.java
@@ -1,239 +1,239 @@
-/*
- * AMW - Automated Middleware allows you to manage the configurations of
- * your Java EE applications on an unlimited number of different environments
- * with various versions, including the automated deployment of those apps.
- * Copyright (C) 2013-2016 by Puzzle ITC
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package ch.mobi.itc.mobiliar.rest.resources;
-
-import ch.mobi.itc.mobiliar.rest.dtos.ResourceRelationDTO;
-import ch.mobi.itc.mobiliar.rest.dtos.TemplateDTO;
-import ch.mobi.itc.mobiliar.rest.exceptions.ExceptionDto;
-import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwner;
-import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwnerViolationException;
-import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
-import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.RelationEditor;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.ResourceRelationLocator;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.AbstractResourceRelationEntity;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ConsumedResourceRelationEntity;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ProvidedResourceRelationEntity;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
-import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
-import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import org.apache.commons.lang3.StringUtils;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Response;
-import java.util.*;
-
-import static javax.ws.rs.core.Response.Status.*;
-
-@RequestScoped
-@Path("/resources/{resourceGroupName}/{releaseName}/relations")
-@Api(value = "/resources/{resourceGroupName}/{releaseName}/relations", description = "Resource relations")
-public class ResourceRelationsRest {
-
- @PathParam("resourceGroupName")
- String resourceGroupName;
-
- @PathParam("releaseName")
- String releaseName;
-
- @Inject
- ResourceLocator resourceLocator;
-
- @Inject
- ResourceRelationLocator resourceRelationLocator;
-
- @Inject
- RelationEditor relationEditor;
-
- @Inject
- ResourceRelationTemplatesRest resourceRelationTemplatesRest;
-
- @GET
- @ApiOperation(value = "Get all relations of a resource in a specific release, optionally filtered by a slave resource type")
- public List getResourceRelations(@ApiParam(value = "A String representing the type of the slave Resource")
- @QueryParam("type") String resourceType) throws ValidationException {
- return getResourceRelations(resourceGroupName, releaseName, resourceType);
- }
-
- List getResourceRelations(String resourceGroupName, String releaseName, String resourceType) throws ValidationException {
- ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithAllRelations(resourceGroupName, releaseName);
- List resourceRelations = new ArrayList<>();
- for (ConsumedResourceRelationEntity relation : resource.getConsumedMasterRelations()) {
- ResourceRelationDTO resRel = createResourceRelationDTO(resourceGroupName, releaseName, resourceType, relation);
- if (resRel != null) {
- resourceRelations.add(resRel);
- }
- }
- for (ProvidedResourceRelationEntity relation : resource.getProvidedMasterRelations()) {
- ResourceRelationDTO resRel = createResourceRelationDTO(resourceGroupName, releaseName, resourceType, relation);
- if (resRel != null) {
- resourceRelations.add(resRel);
- }
- }
- return resourceRelations;
- }
-
- private ResourceRelationDTO createResourceRelationDTO(String resourceGroupName, String releaseName, String resourceType, AbstractResourceRelationEntity relation) throws ValidationException {
- if (resourceType != null && !relation.getResourceRelationType().getResourceTypeB().getName().equals(resourceType)) {
- return null;
- }
- ResourceRelationDTO resRel = new ResourceRelationDTO(relation);
- List templates = resourceRelationTemplatesRest.getResourceRelationTemplates(resourceGroupName, releaseName,
- relation.getSlaveResource().getName(), relation.getSlaveResource().getRelease().getName(), "");
- addTemplates(resRel, templates);
- return resRel;
- }
-
- @Path("/{relatedResourceGroupName}")
- @GET
- @ApiOperation(value = "Get all related releases of the given resource")
- public List getRelatedResourcesForGroup(
- @PathParam("relatedResourceGroupName") String relatedResourceGroupName) throws ValidationException {
- List relations =
- resourceRelationLocator.getRelatedResourcesForGroup(resourceGroupName, releaseName, relatedResourceGroupName);
- List resourceRelations = new ArrayList<>();
- for (ConsumedResourceRelationEntity relation : relations) {
- ResourceRelationDTO resRel = new ResourceRelationDTO(relation);
- List templates = resourceRelationTemplatesRest.getResourceRelationTemplates(resourceGroupName, releaseName,
- relatedResourceGroupName, relation.getSlaveResource().getRelease().getName(), "");
- addTemplates(resRel, templates);
- resourceRelations.add(resRel);
- }
- return resourceRelations;
- }
-
- // List of ResourceRelationDTO
- @Path("/{relatedResourceGroupName}/{relatedReleaseName}")
- @GET
- @ApiOperation(value = "Get the list of relations between the two resource releases")
- public List getResourceRelation(@PathParam("relatedResourceGroupName") String relatedResourceGroupName,
- @PathParam("relatedReleaseName") String relatedReleaseName) throws ValidationException {
- List list = new ArrayList<>();
- for (ConsumedResourceRelationEntity dto : resourceRelationLocator.getResourceRelationList(resourceGroupName, releaseName,
- relatedResourceGroupName, relatedReleaseName)) {
- ResourceRelationDTO resRel = new ResourceRelationDTO(dto);
- List templates = resourceRelationTemplatesRest.getResourceRelationTemplates(resourceGroupName, releaseName,
- relatedResourceGroupName, relatedReleaseName, "");
- addTemplates(resRel, templates);
- list.add(resRel);
- }
- return list;
- }
-
- /**
- * Creates a new ResourceRelation
- *
- * @param slaveGroupName A String representing the name of an existing ResourceGroup which will be added as slave resource of the new ResourceRelation
- * @param relationType A String representing the type of the Relation to be added
- */
- @Path("/{slaveResourceGroupName}")
- @POST
- @ApiOperation(value = "Add a consumed or provided Relation")
- public Response addRelation(@PathParam("slaveResourceGroupName") String slaveGroupName,
- @ApiParam(value = "A String representing the type of the Relation", required = true)
- @QueryParam("type") String relationType) {
- if (StringUtils.isEmpty(slaveGroupName)) {
- return Response.status(BAD_REQUEST).entity(new ExceptionDto("Slave resource group name must not be empty")).build();
- } else if (!relationEditor.isValidResourceRelationType(relationType)) {
- return Response.status(BAD_REQUEST).entity(new ExceptionDto("Type must either be 'consumed' or 'provided'")).build();
- }
- boolean isProvidedRelation = RelationEditor.ResourceRelationType.valueOf(relationType.toUpperCase()).equals(RelationEditor.ResourceRelationType.PROVIDED);
- try {
- relationEditor.addResourceRelationForSpecificRelease(resourceGroupName, slaveGroupName,
- isProvidedRelation, null, relationType, releaseName, ForeignableOwner.getSystemOwner());
- } catch (ResourceNotFoundException | ElementAlreadyExistsException | ValidationException e) {
- return Response.status(BAD_REQUEST).entity(new ExceptionDto(e.getMessage())).build();
- }
- return Response.status(CREATED).build();
- }
-
- /**
- * Removes a new ResourceRelation
- *
- * @param relationName A String representing the identifier of a Relation or the name of the related Resource to be removed
- * @param relationType A String representing the type of the Relation to be removed
- */
- @Path("/{relationName}")
- @DELETE
- @ApiOperation(value = "Remove a consumed or provided Relation from a specific Release", notes = "RelationName may be the identifier of a Relation or the name of the related Resource")
- public Response removeRelation(@PathParam("relationName") String relationName,
- @ApiParam(value = "A String representing the type of the Relation", required = true)
- @QueryParam("type") String relationType) throws ValidationException {
- if (StringUtils.isEmpty(relationName)) {
- return Response.status(BAD_REQUEST).entity(new ExceptionDto("Relation name must not be empty")).build();
- } else if (!relationEditor.isValidResourceRelationType(relationType)) {
- return Response.status(BAD_REQUEST).entity(new ExceptionDto("Type must either be 'consumed' or 'provided'")).build();
- }
- RelationEditor.ResourceRelationType resourceRelationType = RelationEditor.ResourceRelationType.valueOf(relationType.toUpperCase());
-
- Set extends AbstractResourceRelationEntity> relations = getRelations(resourceGroupName, releaseName, resourceRelationType);
-
- try {
- if (relationEditor.removeMatchingRelation(relations, relationName)) {
- return Response.status(Response.Status.OK).build();
- } else {
- return Response.status(NOT_FOUND).entity(new ExceptionDto("No matching relation found")).build();
- }
-
- } catch (ForeignableOwnerViolationException fe) {
- return Response.status(UNAUTHORIZED).entity(new ExceptionDto(fe.getMessage())).build();
- } catch (ResourceNotFoundException | ElementAlreadyExistsException e) {
- return Response.status(NOT_FOUND).entity(new ExceptionDto(e.getMessage())).build();
- }
- }
-
- private Set extends AbstractResourceRelationEntity> getRelations(String resourceGroupName, String releaseName, RelationEditor.ResourceRelationType resourceRelationType) throws ValidationException {
- Set extends AbstractResourceRelationEntity> relations = new HashSet<>();
- if (resourceRelationType.equals(RelationEditor.ResourceRelationType.CONSUMED)) {
- ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithConsumedRelations(resourceGroupName, releaseName);
- relations = resource.getConsumedMasterRelations();
- } else if (resourceRelationType.equals(RelationEditor.ResourceRelationType.PROVIDED)) {
- ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithProvidedRelations(resourceGroupName, releaseName);
- relations = resource.getProvidedMasterRelations();
- }
- return relations;
- }
-
- private void addTemplates(ResourceRelationDTO resRel, List templates) {
- List templatesToAdd = new ArrayList<>();
- for (TemplateDTO temp : templates) {
- String tempName;
- if (temp.getRelatedResourceIdentifier() == null) {
- //eg standardJob
- tempName = resRel.getRelatedResourceName();
- } else {
- //eg standardJob_1
- tempName = resRel.getRelatedResourceName() + "_" + temp.getRelatedResourceIdentifier();
- }
- if (tempName.equals(resRel.getRelationName())) {
- templatesToAdd.add(temp);
- }
- }
- resRel.setTemplates(new ArrayList());
- resRel.getTemplates().addAll(templatesToAdd);
- }
-
-}
+/*
+ * AMW - Automated Middleware allows you to manage the configurations of
+ * your Java EE applications on an unlimited number of different environments
+ * with various versions, including the automated deployment of those apps.
+ * Copyright (C) 2013-2016 by Puzzle ITC
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package ch.mobi.itc.mobiliar.rest.resources;
+
+import ch.mobi.itc.mobiliar.rest.dtos.ResourceRelationDTO;
+import ch.mobi.itc.mobiliar.rest.dtos.TemplateDTO;
+import ch.mobi.itc.mobiliar.rest.exceptions.ExceptionDto;
+import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwner;
+import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwnerViolationException;
+import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
+import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
+import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.RelationEditor;
+import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.ResourceRelationLocator;
+import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.AbstractResourceRelationEntity;
+import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ConsumedResourceRelationEntity;
+import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ProvidedResourceRelationEntity;
+import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
+import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.util.*;
+
+import static javax.ws.rs.core.Response.Status.*;
+
+@RequestScoped
+@Path("/resources/{resourceGroupName}/{releaseName}/relations")
+@Api(value = "/resources/{resourceGroupName}/{releaseName}/relations", description = "Resource relations")
+public class ResourceRelationsRest {
+
+ @PathParam("resourceGroupName")
+ String resourceGroupName;
+
+ @PathParam("releaseName")
+ String releaseName;
+
+ @Inject
+ ResourceLocator resourceLocator;
+
+ @Inject
+ ResourceRelationLocator resourceRelationLocator;
+
+ @Inject
+ RelationEditor relationEditor;
+
+ @Inject
+ ResourceRelationTemplatesRest resourceRelationTemplatesRest;
+
+ @GET
+ @ApiOperation(value = "Get all relations of a resource in a specific release, optionally filtered by a slave resource type")
+ public List getResourceRelations(@ApiParam(value = "A String representing the type of the slave Resource")
+ @QueryParam("type") String resourceType) throws ValidationException, ResourceNotFoundException {
+ return getResourceRelations(resourceGroupName, releaseName, resourceType);
+ }
+
+ List getResourceRelations(String resourceGroupName, String releaseName, String resourceType) throws ValidationException, ResourceNotFoundException {
+ ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithAllRelations(resourceGroupName, releaseName);
+ List resourceRelations = new ArrayList<>();
+ for (ConsumedResourceRelationEntity relation : resource.getConsumedMasterRelations()) {
+ ResourceRelationDTO resRel = createResourceRelationDTO(resourceGroupName, releaseName, resourceType, relation);
+ if (resRel != null) {
+ resourceRelations.add(resRel);
+ }
+ }
+ for (ProvidedResourceRelationEntity relation : resource.getProvidedMasterRelations()) {
+ ResourceRelationDTO resRel = createResourceRelationDTO(resourceGroupName, releaseName, resourceType, relation);
+ if (resRel != null) {
+ resourceRelations.add(resRel);
+ }
+ }
+ return resourceRelations;
+ }
+
+ private ResourceRelationDTO createResourceRelationDTO(String resourceGroupName, String releaseName, String resourceType, AbstractResourceRelationEntity relation) throws ValidationException, ResourceNotFoundException {
+ if (resourceType != null && !relation.getResourceRelationType().getResourceTypeB().getName().equals(resourceType)) {
+ return null;
+ }
+ ResourceRelationDTO resRel = new ResourceRelationDTO(relation);
+ List templates = resourceRelationTemplatesRest.getResourceRelationTemplates(resourceGroupName, releaseName,
+ relation.getSlaveResource().getName(), relation.getSlaveResource().getRelease().getName());
+ addTemplates(resRel, templates);
+ return resRel;
+ }
+
+ @Path("/{relatedResourceGroupName}")
+ @GET
+ @ApiOperation(value = "Get all related releases of the given resource")
+ public List getRelatedResourcesForGroup(
+ @PathParam("relatedResourceGroupName") String relatedResourceGroupName) throws ValidationException, ResourceNotFoundException {
+ List relations =
+ resourceRelationLocator.getRelatedResourcesForGroup(resourceGroupName, releaseName, relatedResourceGroupName);
+ List resourceRelations = new ArrayList<>();
+ for (ConsumedResourceRelationEntity relation : relations) {
+ ResourceRelationDTO resRel = new ResourceRelationDTO(relation);
+ List templates = resourceRelationTemplatesRest.getResourceRelationTemplates(resourceGroupName, releaseName,
+ relatedResourceGroupName, relation.getSlaveResource().getRelease().getName());
+ addTemplates(resRel, templates);
+ resourceRelations.add(resRel);
+ }
+ return resourceRelations;
+ }
+
+ // List of ResourceRelationDTO
+ @Path("/{relatedResourceGroupName}/{relatedReleaseName}")
+ @GET
+ @ApiOperation(value = "Get the list of relations between the two resource releases")
+ public List getResourceRelation(@PathParam("relatedResourceGroupName") String relatedResourceGroupName,
+ @PathParam("relatedReleaseName") String relatedReleaseName) throws ValidationException, ResourceNotFoundException {
+ List list = new ArrayList<>();
+ for (ConsumedResourceRelationEntity dto : resourceRelationLocator.getResourceRelationList(resourceGroupName, releaseName,
+ relatedResourceGroupName, relatedReleaseName)) {
+ ResourceRelationDTO resRel = new ResourceRelationDTO(dto);
+ List templates = resourceRelationTemplatesRest.getResourceRelationTemplates(resourceGroupName, releaseName,
+ relatedResourceGroupName, relatedReleaseName);
+ addTemplates(resRel, templates);
+ list.add(resRel);
+ }
+ return list;
+ }
+
+ /**
+ * Creates a new ResourceRelation
+ *
+ * @param slaveGroupName A String representing the name of an existing ResourceGroup which will be added as slave resource of the new ResourceRelation
+ * @param relationType A String representing the type of the Relation to be added
+ */
+ @Path("/{slaveResourceGroupName}")
+ @POST
+ @ApiOperation(value = "Add a consumed or provided Relation")
+ public Response addRelation(@PathParam("slaveResourceGroupName") String slaveGroupName,
+ @ApiParam(value = "A String representing the type of the Relation", required = true)
+ @QueryParam("type") String relationType) {
+ if (StringUtils.isEmpty(slaveGroupName)) {
+ return Response.status(BAD_REQUEST).entity(new ExceptionDto("Slave resource group name must not be empty")).build();
+ } else if (!relationEditor.isValidResourceRelationType(relationType)) {
+ return Response.status(BAD_REQUEST).entity(new ExceptionDto("Type must either be 'consumed' or 'provided'")).build();
+ }
+ boolean isProvidedRelation = RelationEditor.ResourceRelationType.valueOf(relationType.toUpperCase()).equals(RelationEditor.ResourceRelationType.PROVIDED);
+ try {
+ relationEditor.addResourceRelationForSpecificRelease(resourceGroupName, slaveGroupName,
+ isProvidedRelation, null, relationType, releaseName, ForeignableOwner.getSystemOwner());
+ } catch (ResourceNotFoundException | ElementAlreadyExistsException | ValidationException e) {
+ return Response.status(BAD_REQUEST).entity(new ExceptionDto(e.getMessage())).build();
+ }
+ return Response.status(CREATED).build();
+ }
+
+ /**
+ * Removes a new ResourceRelation
+ *
+ * @param relationName A String representing the identifier of a Relation or the name of the related Resource to be removed
+ * @param relationType A String representing the type of the Relation to be removed
+ */
+ @Path("/{relationName}")
+ @DELETE
+ @ApiOperation(value = "Remove a consumed or provided Relation from a specific Release", notes = "RelationName may be the identifier of a Relation or the name of the related Resource")
+ public Response removeRelation(@PathParam("relationName") String relationName,
+ @ApiParam(value = "A String representing the type of the Relation", required = true)
+ @QueryParam("type") String relationType) throws ValidationException {
+ if (StringUtils.isEmpty(relationName)) {
+ return Response.status(BAD_REQUEST).entity(new ExceptionDto("Relation name must not be empty")).build();
+ } else if (!relationEditor.isValidResourceRelationType(relationType)) {
+ return Response.status(BAD_REQUEST).entity(new ExceptionDto("Type must either be 'consumed' or 'provided'")).build();
+ }
+ RelationEditor.ResourceRelationType resourceRelationType = RelationEditor.ResourceRelationType.valueOf(relationType.toUpperCase());
+
+ Set extends AbstractResourceRelationEntity> relations = getRelations(resourceGroupName, releaseName, resourceRelationType);
+
+ try {
+ if (relationEditor.removeMatchingRelation(relations, relationName)) {
+ return Response.status(Response.Status.OK).build();
+ } else {
+ return Response.status(NOT_FOUND).entity(new ExceptionDto("No matching relation found")).build();
+ }
+
+ } catch (ForeignableOwnerViolationException fe) {
+ return Response.status(UNAUTHORIZED).entity(new ExceptionDto(fe.getMessage())).build();
+ } catch (ResourceNotFoundException | ElementAlreadyExistsException e) {
+ return Response.status(NOT_FOUND).entity(new ExceptionDto(e.getMessage())).build();
+ }
+ }
+
+ private Set extends AbstractResourceRelationEntity> getRelations(String resourceGroupName, String releaseName, RelationEditor.ResourceRelationType resourceRelationType) throws ValidationException {
+ Set extends AbstractResourceRelationEntity> relations = new HashSet<>();
+ if (resourceRelationType.equals(RelationEditor.ResourceRelationType.CONSUMED)) {
+ ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithConsumedRelations(resourceGroupName, releaseName);
+ relations = resource.getConsumedMasterRelations();
+ } else if (resourceRelationType.equals(RelationEditor.ResourceRelationType.PROVIDED)) {
+ ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithProvidedRelations(resourceGroupName, releaseName);
+ relations = resource.getProvidedMasterRelations();
+ }
+ return relations;
+ }
+
+ private void addTemplates(ResourceRelationDTO resRel, List templates) {
+ List templatesToAdd = new ArrayList<>();
+ for (TemplateDTO temp : templates) {
+ String tempName;
+ if (temp.getRelatedResourceIdentifier() == null) {
+ //eg standardJob
+ tempName = resRel.getRelatedResourceName();
+ } else {
+ //eg standardJob_1
+ tempName = resRel.getRelatedResourceName() + "_" + temp.getRelatedResourceIdentifier();
+ }
+ if (tempName.equals(resRel.getRelationName())) {
+ templatesToAdd.add(temp);
+ }
+ }
+ resRel.setTemplates(new ArrayList());
+ resRel.getTemplates().addAll(templatesToAdd);
+ }
+
+}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRest.java
index 9db36b63e..e115dacb1 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRest.java
@@ -21,25 +21,31 @@
package ch.mobi.itc.mobiliar.rest.resources;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
+import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import javax.ws.rs.core.Response;
import ch.mobi.itc.mobiliar.rest.dtos.TemplateDTO;
-import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
-import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.ResourceRelationLocator;
+import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceGroupLocator;
+import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceGroupEntity;
import ch.puzzle.itc.mobiliar.business.template.boundary.TemplateEditor;
import ch.puzzle.itc.mobiliar.business.template.control.TemplatesScreenDomainService;
import ch.puzzle.itc.mobiliar.business.template.entity.TemplateDescriptorEntity;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.NotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.TemplateNotDeletableException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
/**
* Rest boundary for Resource-Templates
@@ -47,62 +53,116 @@
@RequestScoped
@Path("/resources/{resourceGroupName}/{releaseName}/templates")
@Api(value = "/resources/{resourceGroupName}/{releaseName}/templates", description = "Resource templates")
-public class ResourceTemplatesRest {
+public class ResourceTemplatesRest {;
@Inject
- ResourceLocator resourceLocator;
+ ResourceGroupLocator resourceGroupLocator;
@Inject
- ResourceRelationLocator resourceRelationLocator;
+ TemplatesScreenDomainService templateService;
@Inject
TemplateEditor templateEditor;
- @Inject
- TemplatesScreenDomainService templateService;
-
@GET
- @ApiOperation(value = "Get one or all templates for a resource in a specific release")
- public List getResourceTemplates( //
- @PathParam("resourceGroupName") String resourceGroupName,
- @PathParam("releaseName") String releaseName) throws ValidationException {
- return getResourceTemplates(resourceGroupName, releaseName, "");
+ @ApiOperation(value = "Get all templates for a resource in a specific release")
+ public List getResourceTemplates(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName) throws ValidationException {
+ List templateDTOs = new ArrayList<>();
+ List templates = templateService.getGlobalTemplateDescriptorsForResource(resourceGroupName, releaseName, false);
+
+ for (TemplateDescriptorEntity template : templates) {
+ TemplateDTO temp = new TemplateDTO(template);
+ templateDTOs.add(temp);
+ }
+ return templateDTOs;
}
@GET
@Path("/{templateName}")
- @ApiOperation(value = "Get one or all templates for a resource in a specific release")
- public List getResourceTemplates( //
- @PathParam("resourceGroupName") String resourceGroupName,
- @PathParam("releaseName") String releaseName,
- @PathParam("templateName") String templateName) throws ValidationException {
+ @ApiOperation(value = "Get a template for a resource in a specific release")
+ public TemplateDTO getResourceTemplate(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName,
+ @PathParam("templateName") String templateName) throws ValidationException, NotFoundException {
+ TemplateDescriptorEntity template = getTemplate(resourceGroupName, releaseName, templateName);
+ if (template == null) {
+ throw new NotFoundException("Template not found");
+ }
+ return new TemplateDTO(template);
+ }
+
+ @DELETE
+ @Path("/{templateName}")
+ @ApiOperation(value = "Delete a template for a resource in a specific release")
+ public Response deleteResourceTemplate(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName,
+ @PathParam("templateName") String templateName) throws ValidationException, AMWException {
+ try {
+ templateEditor.removeTemplate(resourceGroupName, releaseName, templateName, false);
+ } catch (TemplateNotDeletableException e) {
+ return Response.status(Response.Status.BAD_REQUEST).build();
+ }
+ return Response.status(Response.Status.OK).build();
+ }
- ResourceEntity resource = resourceLocator.getResourceByNameAndReleaseWithConsumedRelations(resourceGroupName,
- releaseName);
+ @POST
+ @ApiOperation(value = "Create a template for a resource in a specific release")
+ public Response createResourceTemplates(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName,
+ TemplateDTO templateDTO) throws ValidationException, AMWException {
+ // make sure id isn't set or save will try to update the template
+ templateDTO.setId(null);
+ TemplateDescriptorEntity template = toTemplateDescriptorEntity(templateDTO, null);
+
+ templateEditor.saveTemplateForResource(template, resourceGroupName, releaseName, false);
+ return Response.ok(new TemplateDTO(template)).build();
+ }
- List templates = templateService.getGlobalTemplateDescriptorsForResource(resource,
- false);
+ @PUT
+ @Path("/{templateName}")
+ @ApiOperation(value = "Update a template for a resource in a specific release")
+ public Response updateResourceTemplates(@PathParam("resourceGroupName") String resourceGroupName,
+ @PathParam("releaseName") String releaseName,
+ @PathParam("templateName") String templateName,
+ TemplateDTO templateDTO) throws ValidationException, AMWException {
+ TemplateDescriptorEntity template = getTemplate(resourceGroupName, releaseName, templateName);
+ if (template == null) {
+ throw new NotFoundException("Template not found");
+ }
+ template = toTemplateDescriptorEntity(templateDTO, template);
- return getTemplateDTOs(templateName, templates);
+ templateEditor.saveTemplateForResource(template, resourceGroupName, releaseName, false);
+ return Response.ok(new TemplateDTO(template)).build();
}
- public List getTemplateDTOs(String templateName, List templates) {
- List result = new ArrayList<>();
- if ("".equals(templateName)) {
- // all templates, but without file content
- for (TemplateDescriptorEntity template : templates) {
- TemplateDTO temp = new TemplateDTO(template);
- temp.setFileContent("");
- result.add(temp);
+ private TemplateDescriptorEntity getTemplate(String resourceGroupName, String releaseName, String templateName) throws ValidationException {
+ List templates = templateService.getGlobalTemplateDescriptorsForResource(resourceGroupName, releaseName, false);
+ for (TemplateDescriptorEntity template : templates) {
+ if (templateName.equals(template.getName())) {
+ return template;
}
- } else {
- for (TemplateDescriptorEntity template : templates) {
- if (templateName.equals(template.getName())) {
- TemplateDTO temp = new TemplateDTO(template);
- result.add(temp);
- }
+ }
+ return null;
+ }
+
+ private TemplateDescriptorEntity toTemplateDescriptorEntity(TemplateDTO templateDTO, TemplateDescriptorEntity template) {
+ if (template == null) {
+ template = new TemplateDescriptorEntity();
+ }
+ template.setId(templateDTO.getId());
+ template.setTesting(false);
+ template.setFileContent(templateDTO.getFileContent());
+ template.setName(templateDTO.getName());
+ template.setTargetPath(templateDTO.getTargetPath());
+ HashSet targetPlatforms = new HashSet<>();
+ if (templateDTO.getTargetPlatforms() != null) {
+ for(String platform : templateDTO.getTargetPlatforms()) {
+ ResourceGroupEntity platformEntity = resourceGroupLocator.getResourceGroupByName(platform);
+ targetPlatforms.add(platformEntity);
}
}
- return result;
+ template.setTargetPlatforms(targetPlatforms);
+
+ return template;
}
}
diff --git a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRest.java b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRest.java
index 7359c86f9..3488c1cc0 100644
--- a/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRest.java
+++ b/AMW_rest/src/main/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRest.java
@@ -46,10 +46,10 @@
import ch.puzzle.itc.mobiliar.business.security.boundary.PermissionBoundary;
import ch.puzzle.itc.mobiliar.business.server.boundary.ServerView;
import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@@ -188,11 +188,11 @@ public ResourceGroupDTO getResourceGroup(@PathParam("resourceGroupName") String
public ResourceDTO getResource(@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("releaseName") String releaseName,
@QueryParam("env") @DefaultValue("Global") String environment,
- @QueryParam("type") String resourceType) throws ValidationException {
+ @QueryParam("type") String resourceType) throws ValidationException, ResourceNotFoundException {
ResourceEntity resourceByRelease = resourceLocator.getResourceByGroupNameAndRelease(resourceGroupName, releaseName);
return new ResourceDTO(resourceByRelease, resourceRelations.getResourceRelations(resourceGroupName,
releaseName, resourceType), resourceProperties.getResourceProperties(resourceGroupName, releaseName,
- environment), resourceTemplatesRest.getResourceTemplates(resourceGroupName, releaseName, ""));
+ environment), resourceTemplatesRest.getResourceTemplates(resourceGroupName, releaseName));
}
@Path("/{resourceGroupName}/lte/{releaseName}")
@@ -201,11 +201,11 @@ public ResourceDTO getResource(@PathParam("resourceGroupName") String resourceGr
public ResourceDTO getExactOrClosestPastRelease(@PathParam("resourceGroupName") String resourceGroupName,
@PathParam("releaseName") String releaseName,
@QueryParam("env") @DefaultValue("Global") String environment,
- @QueryParam("type") String resourceType) throws ValidationException {
+ @QueryParam("type") String resourceType) throws ValidationException, ResourceNotFoundException {
ReleaseEntity release = resourceLocator.getExactOrClosestPastReleaseByGroupNameAndRelease(resourceGroupName, releaseName);
return new ResourceDTO(release, resourceRelations.getResourceRelations(resourceGroupName,
release.getName(), resourceType), resourceProperties.getResourceProperties(resourceGroupName, release.getName(),
- environment), resourceTemplatesRest.getResourceTemplates(resourceGroupName, release.getName(), ""));
+ environment), resourceTemplatesRest.getResourceTemplates(resourceGroupName, release.getName()));
}
@Path("/resourceGroups")
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRestTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRestTest.java
index 3620c0f41..26362c810 100644
--- a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRestTest.java
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/Analyze/TestGenerationRestTest.java
@@ -13,8 +13,9 @@
import ch.puzzle.itc.mobiliar.business.security.control.PermissionService;
import ch.puzzle.itc.mobiliar.business.security.entity.Action;
import ch.puzzle.itc.mobiliar.business.security.entity.Permission;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatchers;
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentTest.java
index dce97e83a..95d10cafd 100644
--- a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentTest.java
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/deployments/DeploymentTest.java
@@ -182,7 +182,6 @@ public void configure() {
Mockito.any(DefaultResourceTypeDefinition.class),
Mockito.any(ReleaseEntity.class))).thenAnswer(new Answer>() {
@Override public Set answer(InvocationOnMock invocation) {
- ResourceEntity appServer = (ResourceEntity)invocation.getArguments()[0];
HashSet set = new HashSet<>();
for(Application a : applicationServer.getAMWApplications()){
final String name = a.getName();
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRestTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRestTest.java
index 659c4125b..54098c08f 100644
--- a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRestTest.java
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcePropertiesRestTest.java
@@ -1,7 +1,8 @@
package ch.mobi.itc.mobiliar.rest.resources;
import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRestTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRestTest.java
index 2610bc6b3..54d0134b6 100644
--- a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRestTest.java
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationPropertiesRestTest.java
@@ -26,7 +26,8 @@
import javax.ws.rs.core.Response;
import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.ResourceRelationLocator;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRestTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRestTest.java
index 539011370..37a46a91b 100644
--- a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRestTest.java
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceRelationsRestTest.java
@@ -24,8 +24,9 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.boundary.RelationEditor;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRestTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRestTest.java
new file mode 100644
index 000000000..dad9c4e4c
--- /dev/null
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourceTemplatesRestTest.java
@@ -0,0 +1,81 @@
+package ch.mobi.itc.mobiliar.rest.resources;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+
+import javax.ws.rs.core.Response;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import ch.mobi.itc.mobiliar.rest.dtos.TemplateDTO;
+import ch.puzzle.itc.mobiliar.business.resourcegroup.boundary.ResourceLocator;
+import ch.puzzle.itc.mobiliar.business.template.boundary.TemplateEditor;
+import ch.puzzle.itc.mobiliar.business.template.control.TemplatesScreenDomainService;
+import ch.puzzle.itc.mobiliar.business.template.entity.TemplateDescriptorEntity;
+import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.NotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
+
+public class ResourceTemplatesRestTest {
+
+ @InjectMocks
+ private ResourceTemplatesRest resourceTemplatesRest;
+
+ @Mock
+ private ResourceLocator resourceLocator;
+
+ @Mock
+ private TemplateEditor templateEditor;
+
+ @Mock
+ private TemplatesScreenDomainService templateService;
+
+ @Before
+ public void configure() {
+ MockitoAnnotations.openMocks(this);
+ }
+
+ @Test
+ public void idShouldBeResetOnCreateResourceTemplates() throws AMWException {
+ TemplateDTO templateDTO = new TemplateDTO();
+ templateDTO.setId(123);
+ templateDTO.setName("test");
+
+ Response response = resourceTemplatesRest.createResourceTemplates("resourceGroupName", "releaseName", templateDTO);
+
+ TemplateDTO result = (TemplateDTO) response.getEntity();
+ assertNull(result.getId());
+ assertEquals("test", result.getName());
+ }
+
+ @Test(expected = NotFoundException.class)
+ public void shouldRaisNotFoundExceptionOnGetResourceTemplate() throws ValidationException, NotFoundException {
+ resourceTemplatesRest.getResourceTemplate("resourceGroupName", "releaseName", "templateName");
+ }
+
+ @Test
+ public void shouldReturnCorrectTemplateOnOnGetResourceTemplate() throws ValidationException, NotFoundException {
+ ArrayList templates = new ArrayList<>();
+ TemplateDescriptorEntity template = new TemplateDescriptorEntity();
+ template.setName("template1");
+ templates.add(template);
+ template = new TemplateDescriptorEntity();
+ template.setName("template2");
+ templates.add(template);
+
+ when(templateService.getGlobalTemplateDescriptorsForResource(eq("resourceGroupName"), eq("releaseName"), eq(false))).thenReturn(templates);
+
+ TemplateDTO templateDTO = resourceTemplatesRest.getResourceTemplate("resourceGroupName", "releaseName", "template2");
+
+ assertEquals("template2", templateDTO.getName());
+ }
+
+}
diff --git a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRestTest.java b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRestTest.java
index ac476d7a1..2deaa5894 100644
--- a/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRestTest.java
+++ b/AMW_rest/src/test/java/ch/mobi/itc/mobiliar/rest/resources/ResourcesRestTest.java
@@ -41,9 +41,10 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
+import ch.puzzle.itc.mobiliar.common.exception.NotFoundException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceTypeNotFoundException;
-import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import org.junit.Assert;
import org.junit.Before;
@@ -59,7 +60,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceTypeEntity;
import ch.puzzle.itc.mobiliar.business.server.boundary.ServerView;
import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import javax.ws.rs.core.Response;
@@ -340,7 +340,7 @@ public void shouldReturnBadRequestIfReleaseCreationFailed() throws AMWException,
}
@Test
- public void shouldInvokeResourcesWithRightArgumentsOnGetClosestPastRelease() throws ValidationException {
+ public void shouldInvokeResourcesWithRightArgumentsOnGetClosestPastRelease() throws ValidationException, NotFoundException {
// given
String resourceGroupName = "TEST";
String releaseName = "RL-17.10";
@@ -356,7 +356,7 @@ public void shouldInvokeResourcesWithRightArgumentsOnGetClosestPastRelease() thr
// then
verify(resourceRelationsMock).getResourceRelations(resourceGroupName, closestRelease.getName(), resourceTypeName);
verify(resourcePropertiesMock).getResourceProperties(resourceGroupName, closestRelease.getName(), env);
- verify(resourceTemplatesRestMock).getResourceTemplates(resourceGroupName, closestRelease.getName(), "");
+ verify(resourceTemplatesRestMock).getResourceTemplates(resourceGroupName, closestRelease.getName());
}
@Test
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/Selected.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/Selected.java
index 65ce45d11..91cc8c34b 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/Selected.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/Selected.java
@@ -27,7 +27,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.enterprise.inject.Stereotype;
import javax.inject.Qualifier;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/applist/ApplistView.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/applist/ApplistView.java
index 5bd42893a..e72f50276 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/applist/ApplistView.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/applist/ApplistView.java
@@ -47,7 +47,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceWithRelations;
import ch.puzzle.itc.mobiliar.business.security.entity.Permission;
import ch.puzzle.itc.mobiliar.common.exception.NotAuthorizedException;
-import ch.puzzle.itc.mobiliar.common.exception.ResourceNotDeletableException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition;
import ch.puzzle.itc.mobiliar.presentation.ViewBackingBean;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/common/ResourceTypeDataProvider.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/common/ResourceTypeDataProvider.java
index 4a4125a7d..70c3a5e95 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/common/ResourceTypeDataProvider.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/common/ResourceTypeDataProvider.java
@@ -41,7 +41,6 @@
import ch.puzzle.itc.mobiliar.common.exception.ResourceTypeNotFoundException;
import ch.puzzle.itc.mobiliar.common.util.NameChecker;
import ch.puzzle.itc.mobiliar.presentation.util.GlobalMessageAppender;
-import ch.puzzle.itc.mobiliar.presentation.util.UserSettings;
@SessionScoped
@Named
@@ -52,9 +51,6 @@ public class ResourceTypeDataProvider implements Serializable {
@Inject
private ResourceTypeDomainService domainService;
- @Inject
- private UserSettings userSettings;
-
@Inject
protected Logger log;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/copyResource/CopyResourceDataProvider.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/copyResource/CopyResourceDataProvider.java
index 57db8e8f4..b09f7ef01 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/copyResource/CopyResourceDataProvider.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/copyResource/CopyResourceDataProvider.java
@@ -34,10 +34,8 @@
import ch.puzzle.itc.mobiliar.business.security.boundary.PermissionBoundary;
import ch.puzzle.itc.mobiliar.business.utils.Identifiable;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.ResourceNotFoundException;
import ch.puzzle.itc.mobiliar.presentation.common.ResourceTypeDataProvider;
-import ch.puzzle.itc.mobiliar.presentation.propertyEdit.PropertyEditDataProvider;
import ch.puzzle.itc.mobiliar.presentation.resourcesedit.EditResourceView;
import ch.puzzle.itc.mobiliar.presentation.util.GlobalMessageAppender;
import lombok.Getter;
@@ -65,9 +63,6 @@ public class CopyResourceDataProvider implements Serializable {
@Inject
private CopyResource copyResource;
- @Inject
- private PropertyEditDataProvider propertyEditDataProvider;
-
@Inject
private MaiaAmwFederationServicePredecessorHandler maiaAmwFederationServicePredecessorHandler;
@@ -89,7 +84,7 @@ public class CopyResourceDataProvider implements Serializable {
@Getter
boolean loadList;
- public void enableLoadList() throws GeneralDBException {
+ public void enableLoadList() {
if(!loadList) {
loadList = true;
refreshResourceList();
@@ -111,8 +106,6 @@ public List getResourcesForSelectedResourceType() {
/**
* load resources for the selected type
- *
- * @throws GeneralDBException
*/
private void refreshResourceList() {
resourceGroupMap = new HashMap<>();
@@ -163,8 +156,8 @@ public void copyFromPredecessorResource(Integer selectedGroup) {
* @param resourceToOverwrite
* @param copyFromResourceId
* @return true if copy was successful, false otherwise
- * @throws GeneralDBException
* @throws ResourceNotFoundException
+ * @throws AMWException
*/
private boolean copyFromResourceAction(ResourceEntity resourceToOverwrite, Integer copyFromResourceId)
throws AMWException, ForeignableOwnerViolationException {
@@ -195,8 +188,6 @@ private boolean copyFromResourceAction(ResourceEntity resourceToOverwrite, Integ
* @param resourceToOverwrite
* @param predecessor
* @return true if copy was successful, false otherwise
- * @throws GeneralDBException
- * @throws ResourceNotFoundException
*/
private boolean copyFromPredecessorResourceAction(ResourceEntity resourceToOverwrite, ResourceGroup predecessor) {
if (resourceToOverwrite == null) {
@@ -229,7 +220,6 @@ else if (predecessor == null) {
* @param resourceTypeId
* @param excludedList
* @return
- * @throws GeneralDBException
*/
public List loadResourcesForSelectedType(Integer resourceTypeId,
List excludedList) {
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/dependencies/DependenciesController.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/dependencies/DependenciesController.java
index 932b0a3b8..e5ed71ae5 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/dependencies/DependenciesController.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/dependencies/DependenciesController.java
@@ -22,7 +22,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@@ -35,12 +34,9 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ApplicationServer;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.control.ResourceRelationService;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.AbstractResourceRelationEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ConsumedResourceRelationEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ProvidedResourceRelationEntity;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.presentation.resourceDependencies.DependencyModel;
-import ch.puzzle.itc.mobiliar.presentation.util.GlobalMessageAppender;
/**
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/CreateDeploymentController.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/CreateDeploymentController.java
index 68aef1c07..67d204f3f 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/CreateDeploymentController.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/CreateDeploymentController.java
@@ -182,7 +182,7 @@ executionDate, stateDate, deployParams, stringToIntegerList(contextIds),
public List loadNewestDeploymentsPerAppserver(String... ids) {
List deployments = new ArrayList<>();
- List idsAsString = (ids != null || ids.length > 0) ? Arrays.asList(ids) : new ArrayList();
+ List idsAsString = ids != null ? Arrays.asList(ids) : new ArrayList();
for (String idString : idsAsString) {
deployments.add(deploymentBoundary.getDeploymentById(Integer.valueOf(idString)));
}
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/Domain.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/Domain.java
index 2a397329a..dec2e3840 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/Domain.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploy/Domain.java
@@ -21,7 +21,6 @@
package ch.puzzle.itc.mobiliar.presentation.deploy;
import lombok.Getter;
-import lombok.Setter;
import javax.enterprise.event.Event;
import java.util.ArrayList;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploymentparameter/DeploymentParameterView.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploymentparameter/DeploymentParameterView.java
index 77d5ca5c9..52463ff44 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploymentparameter/DeploymentParameterView.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/deploymentparameter/DeploymentParameterView.java
@@ -24,7 +24,7 @@
import ch.puzzle.itc.mobiliar.business.deploymentparameter.entity.Key;
import ch.puzzle.itc.mobiliar.business.security.boundary.PermissionBoundary;
import ch.puzzle.itc.mobiliar.business.security.entity.Permission;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import ch.puzzle.itc.mobiliar.presentation.util.GlobalMessageAppender;
import lombok.Getter;
import lombok.Setter;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/foreignable/ForeignableOwnerTooltipCompositeBackingBean.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/foreignable/ForeignableOwnerTooltipCompositeBackingBean.java
index 0e6e5ff17..0dee5b08c 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/foreignable/ForeignableOwnerTooltipCompositeBackingBean.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/foreignable/ForeignableOwnerTooltipCompositeBackingBean.java
@@ -24,7 +24,6 @@
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
-import ch.puzzle.itc.mobiliar.business.foreignable.entity.Foreignable;
import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwner;
@Named
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunction.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunction.java
index 10a1950b6..0d46540c8 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunction.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunction.java
@@ -32,6 +32,7 @@
import ch.puzzle.itc.mobiliar.business.security.entity.Action;
import ch.puzzle.itc.mobiliar.common.exception.NotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import lombok.Getter;
import lombok.Setter;
import ch.puzzle.itc.mobiliar.business.environment.entity.ContextEntity;
@@ -42,7 +43,6 @@
import ch.puzzle.itc.mobiliar.business.security.boundary.PermissionBoundary;
import ch.puzzle.itc.mobiliar.business.security.entity.Permission;
import ch.puzzle.itc.mobiliar.business.utils.Identifiable;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.presentation.CompositeBackingBean;
import ch.puzzle.itc.mobiliar.presentation.common.context.SessionContext;
import ch.puzzle.itc.mobiliar.presentation.resourceRelation.events.ChangeSelectedRelationEvent;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunctionView.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunctionView.java
index a3531b911..42dbbb1e4 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunctionView.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/functionEdit/EditFunctionView.java
@@ -35,8 +35,8 @@
import ch.puzzle.itc.mobiliar.business.function.boundary.FunctionsBoundary;
import ch.puzzle.itc.mobiliar.business.function.entity.AmwFunctionEntity;
import ch.puzzle.itc.mobiliar.business.security.boundary.PermissionBoundary;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import ch.puzzle.itc.mobiliar.presentation.ViewBackingBean;
import ch.puzzle.itc.mobiliar.presentation.util.GlobalMessageAppender;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditController.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditController.java
index 1487d8592..ab63e071c 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditController.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditController.java
@@ -21,7 +21,6 @@
package ch.puzzle.itc.mobiliar.presentation.propertyEdit;
import ch.puzzle.itc.mobiliar.business.foreignable.entity.ForeignableOwnerViolationException;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
import ch.puzzle.itc.mobiliar.common.util.NameChecker;
import ch.puzzle.itc.mobiliar.presentation.resourceRelation.ResourceRelationModel;
@@ -69,7 +68,7 @@ public void save() {
GlobalMessageAppender.addErrorMessage(errorMessage);
log.log(Level.SEVERE, errorMessage, e);
}
- catch (AMWException | ValidationException e) {
+ catch (AMWException e) {
GlobalMessageAppender.addErrorMessage(e.getMessage());
log.log(Level.SEVERE, e.getMessage(), e);
}
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditDataProvider.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditDataProvider.java
index 428e3c86e..efb829666 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditDataProvider.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertyEdit/PropertyEditDataProvider.java
@@ -37,9 +37,8 @@
import ch.puzzle.itc.mobiliar.business.security.entity.Action;
import ch.puzzle.itc.mobiliar.business.security.entity.Permission;
import ch.puzzle.itc.mobiliar.business.softlinkRelation.boundary.SoftlinkRelationBoundary;
-import ch.puzzle.itc.mobiliar.business.softlinkRelation.entity.SoftlinkRelationEntity;
-import ch.puzzle.itc.mobiliar.business.utils.ValidationException;
import ch.puzzle.itc.mobiliar.common.exception.AMWException;
+import ch.puzzle.itc.mobiliar.common.exception.ValidationException;
import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition;
import ch.puzzle.itc.mobiliar.presentation.CompositeBackingBean;
import ch.puzzle.itc.mobiliar.presentation.Selected;
@@ -332,10 +331,6 @@ private void preventDuplicateIdentifiers() throws AMWException {
}
}
- private String getSoftlinkIdIfResource() {
- return isCurrentFocusOnResource() ? ((ResourceEntity) resourceOrResourceType).getSoftlinkId() : null;
- }
-
private String getNameOfResourceOrResourceType() {
return resourceOrResourceType != null ? resourceOrResourceType.getName() : null;
}
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertytype/PropertyTypeController.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertytype/PropertyTypeController.java
index 0674de931..20361d5df 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertytype/PropertyTypeController.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/propertytype/PropertyTypeController.java
@@ -34,7 +34,6 @@
import ch.puzzle.itc.mobiliar.business.property.control.PropertyTypeService;
import ch.puzzle.itc.mobiliar.business.property.entity.PropertyTypeEntity;
import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.NotAuthorizedException;
import ch.puzzle.itc.mobiliar.common.exception.PropertyTypeNotDeletableException;
import ch.puzzle.itc.mobiliar.common.exception.PropertyTypeNotFoundException;
@@ -133,9 +132,6 @@ public boolean doSave(Integer prtTypeId, String prtTypeName, String prtTypeValid
GlobalMessageAppender.addErrorMessage("The property type has not been found.");
} catch (RenameException e) {
GlobalMessageAppender.addErrorMessage("Was not able to rename the property type.");
- } catch (GeneralDBException e) {
- String message = "Could not rename property type.";
- GlobalMessageAppender.addErrorMessage(e.getErrorMessage() + " " + message);
} catch (ElementAlreadyExistsException e) {
GlobalMessageAppender.addErrorMessage("Was not able to save the property type.");
}
@@ -175,8 +171,6 @@ public boolean doCreateByPropertyType(String prtTypeName, String prtTypeValidati
}
} catch (ElementAlreadyExistsException e) {
GlobalMessageAppender.addErrorMessage("Property type already exists.");
- } catch (GeneralDBException e) {
- GlobalMessageAppender.addErrorMessage(e.getErrorMessage() + " Could not create the new property type.");
}
return isSuccessful;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/release/ReleaseMgmtScreenService.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/release/ReleaseMgmtScreenService.java
index 945743616..cb63a2609 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/release/ReleaseMgmtScreenService.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/release/ReleaseMgmtScreenService.java
@@ -35,11 +35,9 @@
import ch.puzzle.itc.mobiliar.business.deploy.boundary.DeploymentBoundary;
import ch.puzzle.itc.mobiliar.business.releasing.boundary.ReleaseLocator;
import ch.puzzle.itc.mobiliar.business.releasing.control.ReleaseMgmtService;
-import ch.puzzle.itc.mobiliar.business.deploy.entity.DeploymentEntity;
import ch.puzzle.itc.mobiliar.business.releasing.entity.ReleaseEntity;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceTypeEntity;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.presentation.components.impl.PaginationComp;
import ch.puzzle.itc.mobiliar.presentation.util.GlobalMessageAppender;
@@ -118,7 +116,6 @@ public boolean isDefaultRelease(ReleaseEntity release){
private ReleaseEntity currentRelease;
private SortedMap> resourcesForCurrentRelease;
- private List deploymentsForCurrentRelease;
public void remove(){
releaseLocator.delete(currentRelease);
@@ -159,8 +156,6 @@ public void loadResourcesAndDeploymentsForRelease(Integer releaseId) {
}
resourcesForCurrentRelease.get(r.getResourceType()).add(r);
}
- deploymentsForCurrentRelease = deploymentBoundary
- .getDeploymentsForRelease(releaseId);
}
public boolean hasResourcesForCurrentRelease() {
@@ -190,21 +185,15 @@ public List getResForCurrentReleaseByType(Integer typeId) {
* Stores the release with the corresponding service method. Please call during edit- or create-form submission.
*/
public boolean save() {
- try {
- if (currentRelease.getId() == null) {
- releaseMgmtService.create(currentRelease);
- } else {
- releaseMgmtService.update(currentRelease);
- }
- GlobalMessageAppender.addSuccessMessage("Release " + currentRelease.getName()
- + " successfully saved.");
- reload();
- return true;
- } catch (GeneralDBException e) {
- String message = "The selected resource can not be found.";
- GlobalMessageAppender.addErrorMessage(message);
- return false;
+ if (currentRelease.getId() == null) {
+ releaseMgmtService.create(currentRelease);
+ } else {
+ releaseMgmtService.update(currentRelease);
}
+ GlobalMessageAppender.addSuccessMessage("Release " + currentRelease.getName()
+ + " successfully saved.");
+ reload();
+ return true;
}
@Override
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/DependencyModel.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/DependencyModel.java
index 09297c796..2d6c7de87 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/DependencyModel.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/DependencyModel.java
@@ -22,9 +22,7 @@
import java.io.Serializable;
-import lombok.Setter;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.AbstractResourceRelationEntity;
-import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
/**
* UI model for displaying resource dependencies
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/events/SelectedResourceEvent.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/events/SelectedResourceEvent.java
index 5cc374b58..9a0a3260b 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/events/SelectedResourceEvent.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceDependencies/events/SelectedResourceEvent.java
@@ -23,7 +23,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import lombok.AllArgsConstructor;
import lombok.Getter;
-import lombok.Setter;
/**
* This is an event container for notification of observers that another resource has been selected on the gui. If no resource has been selected, the corresponding relation field is null.
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceRelations/ResourceRelations.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceRelations/ResourceRelations.java
index 10bdd025c..ce5f3ee4b 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceRelations/ResourceRelations.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourceRelations/ResourceRelations.java
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
@@ -34,7 +33,6 @@
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ApplicationServer;
import ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.control.ResourceRelationService;
-import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.AbstractResourceRelationEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ConsumedResourceRelationEntity;
import ch.puzzle.itc.mobiliar.business.resourcerelation.entity.ProvidedResourceRelationEntity;
import ch.puzzle.itc.mobiliar.business.softlinkRelation.boundary.DisplaySoftlinkDependencies;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourcesedit/events/SelectedRelationId.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourcesedit/events/SelectedRelationId.java
index 0302df571..cd3c2fcc2 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourcesedit/events/SelectedRelationId.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/resourcesedit/events/SelectedRelationId.java
@@ -27,9 +27,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import javax.enterprise.inject.Stereotype;
-import javax.faces.bean.ViewScoped;
-import javax.inject.Named;
import javax.inject.Qualifier;
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/server/ServerListView.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/server/ServerListView.java
index 9b07dfc65..107733dfe 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/server/ServerListView.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/server/ServerListView.java
@@ -34,7 +34,6 @@
import ch.puzzle.itc.mobiliar.business.server.boundary.ServerView;
import ch.puzzle.itc.mobiliar.business.server.entity.ServerTuple;
import ch.puzzle.itc.mobiliar.business.utils.JpaWildcardConverter;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.util.ConfigurationService;
import ch.puzzle.itc.mobiliar.common.util.DefaultResourceTypeDefinition;
import ch.puzzle.itc.mobiliar.common.util.ConfigKey;
@@ -83,7 +82,7 @@ public class ServerListView implements Serializable {
private boolean resourceReadPermission;
// called by preRenderView event
- public void init() throws GeneralDBException {
+ public void init() {
//cache permissions in view
this.appServerReadPermission = securityDataProvider.hasPermissionForResourceType("RESOURCE", "READ", "APPLICATIONSERVER");
this.resourceReadPermission = securityDataProvider.hasPermission("RESOURCE", "READ");
@@ -101,7 +100,7 @@ public String getFILTER_TOOLTIP() {
return FILTER_TOOLTIP;
}
- public void loadRuntimes() throws GeneralDBException {
+ public void loadRuntimes() {
runtimes = commonServcie.getRuntimeResourceGroups();
}
diff --git a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/shakedownstp/ShakedownStpDataProvider.java b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/shakedownstp/ShakedownStpDataProvider.java
index c967a01a1..f2607044d 100644
--- a/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/shakedownstp/ShakedownStpDataProvider.java
+++ b/AMW_web/src/main/java/ch/puzzle/itc/mobiliar/presentation/shakedownstp/ShakedownStpDataProvider.java
@@ -33,9 +33,9 @@
import ch.puzzle.itc.mobiliar.business.shakedown.control.ShakedownStpService;
import ch.puzzle.itc.mobiliar.business.shakedown.entity.ShakedownStpEntity;
import ch.puzzle.itc.mobiliar.common.exception.ElementAlreadyExistsException;
-import ch.puzzle.itc.mobiliar.common.exception.GeneralDBException;
import ch.puzzle.itc.mobiliar.common.exception.NotAuthorizedException;
import ch.puzzle.itc.mobiliar.common.exception.StpNotFoundException;
+import ch.puzzle.itc.mobiliar.common.exception.TemplateNotDeletableException;
import ch.puzzle.itc.mobiliar.common.util.ConfigurationService;
import ch.puzzle.itc.mobiliar.common.util.ConfigKey;
import ch.puzzle.itc.mobiliar.presentation.CompositeBackingBean;
@@ -155,7 +155,7 @@ public List getStp() {
return stp;
}
- public void deleteSTP() {
+ public void deleteSTP() throws TemplateNotDeletableException {
deleteSTP(currentSTPSelected().getId());
loadStps();
}
@@ -313,7 +313,7 @@ private boolean createNewSTP(String newSTPName, String newSTPVersion, List