From 212e4dad5d7d818ba36ddfc398dbdc6743703120 Mon Sep 17 00:00:00 2001 From: Joern Muehlencord Date: Wed, 5 Jun 2019 14:32:12 +0200 Subject: [PATCH] splitted database from account --- account-ui/pom.xml | 1 + account/pom.xml | 30 ++--- .../account/boundary/AccountProducer.java | 12 +- .../account/boundary/ApiKeyService.java | 2 +- .../config/boundary/ConfigService.java | 2 +- .../instance/boundary/StartupBean.java | 2 +- db/pom.xml | 52 ++++++++ .../shared/db}/AbstractController.java | 26 ++-- .../db}/AbstractEnddateableController.java | 34 +++-- .../muehlencord/shared/db}/ApplicationPU.java | 72 +++++----- ...ApplicationTransactionJoinInterceptor.java | 92 ++++++------- .../shared/db}/ControllerException.java | 124 +++++++++--------- .../muehlencord/shared/db}/EndDateable.java | 2 +- .../de/muehlencord/shared/db}/Updateable.java | 58 ++++---- .../shared/jeeutil/restexfw/APIException.java | 4 + pom.xml | 20 ++- sharepoint/api/pom.xml | 2 +- sharepoint/pom.xml | 1 - shiro-faces/pom.xml | 76 +++++------ .../muehlencord/shared/util/StringUtil.java | 39 +++--- 20 files changed, 361 insertions(+), 290 deletions(-) create mode 100644 db/pom.xml rename {account/src/main/java/de/muehlencord/shared/account/business => db/src/main/java/de/muehlencord/shared/db}/AbstractController.java (93%) rename {account/src/main/java/de/muehlencord/shared/account/business => db/src/main/java/de/muehlencord/shared/db}/AbstractEnddateableController.java (80%) rename {account/src/main/java/de/muehlencord/shared/account/util => db/src/main/java/de/muehlencord/shared/db}/ApplicationPU.java (94%) rename {account/src/main/java/de/muehlencord/shared/account/util => db/src/main/java/de/muehlencord/shared/db}/ApplicationTransactionJoinInterceptor.java (94%) rename {account/src/main/java/de/muehlencord/shared/account/business => db/src/main/java/de/muehlencord/shared/db}/ControllerException.java (94%) rename {account/src/main/java/de/muehlencord/shared/account/util => db/src/main/java/de/muehlencord/shared/db}/EndDateable.java (95%) rename {account/src/main/java/de/muehlencord/shared/account/util => db/src/main/java/de/muehlencord/shared/db}/Updateable.java (91%) diff --git a/account-ui/pom.xml b/account-ui/pom.xml index 9402dae..a0c4c76 100644 --- a/account-ui/pom.xml +++ b/account-ui/pom.xml @@ -62,6 +62,7 @@ de.muehlencord.shared shared-account + ejb de.muehlencord.shared diff --git a/account/pom.xml b/account/pom.xml index f912806..0a73d7a 100644 --- a/account/pom.xml +++ b/account/pom.xml @@ -14,13 +14,22 @@ shared-account - - UTF-8 - 10 - 10 - - + + ${project.groupId} + shared-db + ejb + + + ${project.groupId} + shared-account-dao + + + ${project.groupId} + shared-util + jar + + org.apache.commons commons-lang3 @@ -43,10 +52,6 @@ ${project.groupId} shared-jeeutil jar - - - ${project.groupId} - shared-account-dao junit @@ -68,11 +73,6 @@ jcl-over-slf4j test - - de.muehlencord.shared - shared-util - jar - com.google.code.gson gson diff --git a/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/AccountProducer.java b/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/AccountProducer.java index a3a3bf8..04b433c 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/AccountProducer.java +++ b/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/AccountProducer.java @@ -71,13 +71,21 @@ public class AccountProducer implements Serializable { public Account getAccount() { String accountName; if (account == null) { - Subject subject = SecurityUtils.getSubject(); + Subject subject = null; + try { + subject = SecurityUtils.getSubject(); + } catch (Exception ex) { + if (LOGGER.isTraceEnabled()) { + LOGGER.error(ex.getMessage()); + LOGGER.error("Detailed stacktrace", new Object[]{ex}); + } + } if (subject == null) { return null; } if ((subject.isAuthenticated() == false) && (subject.isRemembered() == false)) { - return null; + return null; } else { accountName = subject.getPrincipal().toString(); } diff --git a/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/ApiKeyService.java b/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/ApiKeyService.java index 8210736..0dbe487 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/ApiKeyService.java +++ b/account/src/main/java/de/muehlencord/shared/account/business/account/boundary/ApiKeyService.java @@ -15,7 +15,6 @@ */ package de.muehlencord.shared.account.business.account.boundary; -import de.muehlencord.shared.account.business.ControllerException; import de.muehlencord.shared.account.business.account.control.AccountControl; import de.muehlencord.shared.account.business.account.entity.AccountEntity; import de.muehlencord.shared.account.business.account.entity.ApiKeyEntity; @@ -24,6 +23,7 @@ import de.muehlencord.shared.account.business.config.boundary.ConfigService; import de.muehlencord.shared.account.business.config.entity.ConfigException; import de.muehlencord.shared.account.dao.ApiKeyObject; import de.muehlencord.shared.account.util.AccountPU; +import de.muehlencord.shared.db.ControllerException; import de.muehlencord.shared.jeeutil.jwt.JWTDecoder; import de.muehlencord.shared.jeeutil.jwt.JWTEncoder; import de.muehlencord.shared.jeeutil.jwt.JWTException; diff --git a/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java b/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java index 9831b72..2549cb3 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java +++ b/account/src/main/java/de/muehlencord/shared/account/business/config/boundary/ConfigService.java @@ -15,7 +15,7 @@ */ package de.muehlencord.shared.account.business.config.boundary; -import de.muehlencord.shared.account.business.ControllerException; +import de.muehlencord.shared.db.ControllerException; import de.muehlencord.shared.account.business.account.entity.Account; import de.muehlencord.shared.account.business.account.entity.AccountEntity; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; diff --git a/account/src/main/java/de/muehlencord/shared/account/business/instance/boundary/StartupBean.java b/account/src/main/java/de/muehlencord/shared/account/business/instance/boundary/StartupBean.java index de4eced..e3bcc41 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/instance/boundary/StartupBean.java +++ b/account/src/main/java/de/muehlencord/shared/account/business/instance/boundary/StartupBean.java @@ -15,7 +15,7 @@ */ package de.muehlencord.shared.account.business.instance.boundary; -import de.muehlencord.shared.account.business.ControllerException; +import de.muehlencord.shared.db.ControllerException; import de.muehlencord.shared.account.business.application.entity.ApplicationEntity; import de.muehlencord.shared.account.business.config.boundary.ConfigService; import de.muehlencord.shared.account.business.config.entity.ConfigException; diff --git a/db/pom.xml b/db/pom.xml new file mode 100644 index 0000000..abf9a62 --- /dev/null +++ b/db/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + de.muehlencord.shared + shared-db + ejb + + + shared + de.muehlencord + 1.2-SNAPSHOT + + + shared-db + + + org.apache.commons + commons-lang3 + jar + + + ${project.groupId} + shared-util + + + org.slf4j + slf4j-api + + + javax + javaee-web-api + provided + + + + + + + + org.apache.maven.plugins + maven-ejb-plugin + + 3.1 + + **/persistence.xml + + + + + + \ No newline at end of file diff --git a/account/src/main/java/de/muehlencord/shared/account/business/AbstractController.java b/db/src/main/java/de/muehlencord/shared/db/AbstractController.java similarity index 93% rename from account/src/main/java/de/muehlencord/shared/account/business/AbstractController.java rename to db/src/main/java/de/muehlencord/shared/db/AbstractController.java index 5897c94..da513f0 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/AbstractController.java +++ b/db/src/main/java/de/muehlencord/shared/db/AbstractController.java @@ -13,11 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.muehlencord.shared.account.business; +package de.muehlencord.shared.db; -import de.muehlencord.shared.account.business.account.entity.Account; -import de.muehlencord.shared.account.util.ApplicationPU; -import de.muehlencord.shared.account.util.Updateable; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -41,7 +38,7 @@ import javax.persistence.metamodel.IdentifiableType; import javax.persistence.metamodel.Metamodel; import javax.persistence.metamodel.SingularAttribute; import javax.transaction.Transactional; -import org.apache.shiro.util.StringUtils; +import org.apache.commons.lang3.StringUtils; /** * @@ -54,9 +51,6 @@ public abstract class AbstractController { @ApplicationPU protected EntityManager em; - @Inject - protected Account account; - private final Class entityClass; public AbstractController(Class clazz) { @@ -187,12 +181,12 @@ public abstract class AbstractController { return path; } - public void applyUpdateableChanges(Updateable updateable, boolean onCreate) throws ControllerException { + public void applyUpdateableChanges(Updateable updateable, boolean onCreate, String updatedBy) throws ControllerException { if (onCreate) { - updateable.setCreatedBy(account.getUsername()); + updateable.setCreatedBy(updatedBy); updateable.setCreatedOn(new Date()); } - updateable.setLastUpdatedBy(account.getUsername()); + updateable.setLastUpdatedBy(updatedBy); updateable.setLastUpdatedOn(new Date()); } @@ -203,10 +197,10 @@ public abstract class AbstractController { @TransactionAttribute(TransactionAttributeType.REQUIRED) @Transactional @Lock(LockType.WRITE) - public T create(T entity) throws ControllerException { + public T create(T entity, String createdBy) throws ControllerException { if (Updateable.class.isAssignableFrom(entity.getClass())) { Updateable updateable = (Updateable) entity; - applyUpdateableChanges(updateable, true); + applyUpdateableChanges(updateable, true, createdBy); } em.persist(entity); return entity; @@ -215,10 +209,10 @@ public abstract class AbstractController { @TransactionAttribute(TransactionAttributeType.REQUIRED) @Transactional @Lock(LockType.WRITE) - public T update(T entity) throws ControllerException { + public T update(T entity, String updatedBy) throws ControllerException { if (Updateable.class.isAssignableFrom(entity.getClass())) { Updateable updateable = (Updateable) entity; - applyUpdateableChanges(updateable, false); + applyUpdateableChanges(updateable, false, updatedBy); } return em.merge(entity); } @@ -226,7 +220,7 @@ public abstract class AbstractController { @TransactionAttribute(TransactionAttributeType.REQUIRED) @Transactional @Lock(LockType.WRITE) - public void delete(T entity) throws ControllerException { + public void delete(T entity, String deletedBy) throws ControllerException { em.remove(attach(entity)); } diff --git a/account/src/main/java/de/muehlencord/shared/account/business/AbstractEnddateableController.java b/db/src/main/java/de/muehlencord/shared/db/AbstractEnddateableController.java similarity index 80% rename from account/src/main/java/de/muehlencord/shared/account/business/AbstractEnddateableController.java rename to db/src/main/java/de/muehlencord/shared/db/AbstractEnddateableController.java index 8e0935e..031678d 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/AbstractEnddateableController.java +++ b/db/src/main/java/de/muehlencord/shared/db/AbstractEnddateableController.java @@ -13,10 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.muehlencord.shared.account.business; +package de.muehlencord.shared.db; -import de.muehlencord.shared.account.util.EndDateable; -import de.muehlencord.shared.account.util.Updateable; import de.muehlencord.shared.util.DateUtil; import java.util.ArrayList; import java.util.Date; @@ -51,34 +49,34 @@ public abstract class AbstractEnddateableController> ex @Transactional @Lock(LockType.WRITE) @Override - public void delete(T entity) throws ControllerException { + public void delete(T entity, String deletedBy) throws ControllerException { T entityToUpdate = attach(entity); if (Updateable.class.isAssignableFrom(entityToUpdate.getClass())) { Updateable updateable = (Updateable) entityToUpdate; - applyUpdateableChanges(updateable, false); + applyUpdateableChanges(updateable, false, deletedBy); } entityToUpdate.setValidTo(DateUtil.getCurrentTimeInUTC()); em.merge(entityToUpdate); } - + @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) @Transactional - @Lock(LockType.WRITE) - public T create(T entity) throws ControllerException { - entity.setValidFrom(DateUtil.getCurrentTimeInUTC()); - return super.create(entity); + @Lock(LockType.WRITE) + public T create(T entity, String createdBy) throws ControllerException { + entity.setValidFrom(DateUtil.getCurrentTimeInUTC()); + return super.create(entity, createdBy); } - + @TransactionAttribute(TransactionAttributeType.REQUIRED) @Transactional @Lock(LockType.WRITE) @Override - public T update(T entity) throws ControllerException { - T newEntity = entity.cloneEndDateable(); - delete(entity); - return create (newEntity); - } + public T update(T entity, String createdBy) throws ControllerException { + T newEntity = entity.cloneEndDateable(); + delete(entity, createdBy); + return create(newEntity, createdBy); + } @Lock(LockType.READ) @Override @@ -89,10 +87,10 @@ public abstract class AbstractEnddateableController> ex final Root root = criteria.from(endDateableClass); Predicate alreadyValid = cb.lessThanOrEqualTo(root.get("validFrom"), now); - + Predicate validToNotSet = cb.isNull(root.get("validTo")); Predicate isBeforeValidTo = cb.greaterThanOrEqualTo(root.get("validTo"), now); - Predicate stillValid = cb.or (isBeforeValidTo, validToNotSet); + Predicate stillValid = cb.or(isBeforeValidTo, validToNotSet); Predicate isValid = cb.and(alreadyValid, stillValid); criteria.where(isValid); diff --git a/account/src/main/java/de/muehlencord/shared/account/util/ApplicationPU.java b/db/src/main/java/de/muehlencord/shared/db/ApplicationPU.java similarity index 94% rename from account/src/main/java/de/muehlencord/shared/account/util/ApplicationPU.java rename to db/src/main/java/de/muehlencord/shared/db/ApplicationPU.java index b320495..0622d28 100644 --- a/account/src/main/java/de/muehlencord/shared/account/util/ApplicationPU.java +++ b/db/src/main/java/de/muehlencord/shared/db/ApplicationPU.java @@ -1,36 +1,36 @@ -/* - * Copyright 2018 joern.muehlencord. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.muehlencord.shared.account.util; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.ElementType.TYPE; -import java.lang.annotation.Retention; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import java.lang.annotation.Target; -import javax.inject.Qualifier; - -/** - * - * @author Joern Muehlencord - */ -@Qualifier -@Retention(RUNTIME) -@Target({METHOD, FIELD, PARAMETER, TYPE}) -public @interface ApplicationPU { - -} +/* + * Copyright 2018 joern.muehlencord. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.muehlencord.shared.db; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.ElementType.TYPE; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Target; +import javax.inject.Qualifier; + +/** + * + * @author Joern Muehlencord + */ +@Qualifier +@Retention(RUNTIME) +@Target({METHOD, FIELD, PARAMETER, TYPE}) +public @interface ApplicationPU { + +} diff --git a/account/src/main/java/de/muehlencord/shared/account/util/ApplicationTransactionJoinInterceptor.java b/db/src/main/java/de/muehlencord/shared/db/ApplicationTransactionJoinInterceptor.java similarity index 94% rename from account/src/main/java/de/muehlencord/shared/account/util/ApplicationTransactionJoinInterceptor.java rename to db/src/main/java/de/muehlencord/shared/db/ApplicationTransactionJoinInterceptor.java index e958ee5..c61fe62 100644 --- a/account/src/main/java/de/muehlencord/shared/account/util/ApplicationTransactionJoinInterceptor.java +++ b/db/src/main/java/de/muehlencord/shared/db/ApplicationTransactionJoinInterceptor.java @@ -1,46 +1,46 @@ -package de.muehlencord.shared.account.util; - -import javax.annotation.Priority; -import javax.inject.Inject; -import javax.interceptor.AroundInvoke; -import javax.interceptor.Interceptor; -import javax.interceptor.InvocationContext; -import javax.persistence.EntityManager; -import javax.transaction.Transactional; -import static javax.transaction.Transactional.TxType.REQUIRED; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Joern Muehlencord - */ -@Transactional(value = REQUIRED) -@Interceptor -@Priority(value = ApplicationTransactionJoinInterceptor.PRIORITY) -public class ApplicationTransactionJoinInterceptor { - - private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTransactionJoinInterceptor.class); - - // attach behind the interceptor of the container - public static final int PRIORITY = Interceptor.Priority.PLATFORM_BEFORE + 250; - - @Inject - @ApplicationPU - private EntityManager em; - - @AroundInvoke - public Object joinTransaction(InvocationContext context) throws Exception { - if (em == null) { - return context.proceed(); - } else { - if (em.isJoinedToTransaction()) { - LOGGER.trace("transaction already joined"); - } else { - LOGGER.trace("joining transaction"); - em.joinTransaction(); - } - } - return context.proceed(); - } -} +package de.muehlencord.shared.db; + +import javax.annotation.Priority; +import javax.inject.Inject; +import javax.interceptor.AroundInvoke; +import javax.interceptor.Interceptor; +import javax.interceptor.InvocationContext; +import javax.persistence.EntityManager; +import javax.transaction.Transactional; +import static javax.transaction.Transactional.TxType.REQUIRED; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Joern Muehlencord + */ +@Transactional(value = REQUIRED) +@Interceptor +@Priority(value = ApplicationTransactionJoinInterceptor.PRIORITY) +public class ApplicationTransactionJoinInterceptor { + + private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTransactionJoinInterceptor.class); + + // attach behind the interceptor of the container + public static final int PRIORITY = Interceptor.Priority.PLATFORM_BEFORE + 250; + + @Inject + @ApplicationPU + private EntityManager em; + + @AroundInvoke + public Object joinTransaction(InvocationContext context) throws Exception { + if (em == null) { + return context.proceed(); + } else { + if (em.isJoinedToTransaction()) { + LOGGER.trace("transaction already joined"); + } else { + LOGGER.trace("joining transaction"); + em.joinTransaction(); + } + } + return context.proceed(); + } +} diff --git a/account/src/main/java/de/muehlencord/shared/account/business/ControllerException.java b/db/src/main/java/de/muehlencord/shared/db/ControllerException.java similarity index 94% rename from account/src/main/java/de/muehlencord/shared/account/business/ControllerException.java rename to db/src/main/java/de/muehlencord/shared/db/ControllerException.java index efcaf40..a0d022f 100644 --- a/account/src/main/java/de/muehlencord/shared/account/business/ControllerException.java +++ b/db/src/main/java/de/muehlencord/shared/db/ControllerException.java @@ -1,62 +1,62 @@ -/* - * Copyright 2019 joern.muehlencord. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package de.muehlencord.shared.account.business; - -import javax.ejb.ApplicationException; - -/** - * - * @author joern.muehlencord - */ -@ApplicationException(rollback=true) -public class ControllerException extends Exception { - - private static final long serialVersionUID = 5190280225284514859L; - public static final int CAUSE_ALREADY_EXISTS = 1; - public static final int CAUSE_NOT_FOUND = 2; - public static final int CAUSE_CANNOT_PERSIST = 3; - public static final int CAUSE_TOO_MANY_ROWS = 4; - public static final int CAUSE_CANNOT_DELETE = 5; - - private final int causeCode; - - /** - * Creates a new instance of ControllerException without detail - * message. - * - * @param cause the reason code - * @param message an explanation - */ - public ControllerException(int cause, String message) { - super(message); - this.causeCode = cause; - } - - /** - * - * @param causeCode - * @param message - * @param cause - */ - public ControllerException(int causeCode, String message, Throwable cause) { - super(message, cause); - this.causeCode = causeCode; - } - - public int getCauseCode() { - return causeCode; - } -} +/* + * Copyright 2019 joern.muehlencord. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.muehlencord.shared.db; + +import javax.ejb.ApplicationException; + +/** + * + * @author joern.muehlencord + */ +@ApplicationException(rollback=true) +public class ControllerException extends Exception { + + private static final long serialVersionUID = 5190280225284514859L; + public static final int CAUSE_ALREADY_EXISTS = 1; + public static final int CAUSE_NOT_FOUND = 2; + public static final int CAUSE_CANNOT_PERSIST = 3; + public static final int CAUSE_TOO_MANY_ROWS = 4; + public static final int CAUSE_CANNOT_DELETE = 5; + + private final int causeCode; + + /** + * Creates a new instance of ControllerException without detail + * message. + * + * @param cause the reason code + * @param message an explanation + */ + public ControllerException(int cause, String message) { + super(message); + this.causeCode = cause; + } + + /** + * + * @param causeCode + * @param message + * @param cause + */ + public ControllerException(int causeCode, String message, Throwable cause) { + super(message, cause); + this.causeCode = causeCode; + } + + public int getCauseCode() { + return causeCode; + } +} diff --git a/account/src/main/java/de/muehlencord/shared/account/util/EndDateable.java b/db/src/main/java/de/muehlencord/shared/db/EndDateable.java similarity index 95% rename from account/src/main/java/de/muehlencord/shared/account/util/EndDateable.java rename to db/src/main/java/de/muehlencord/shared/db/EndDateable.java index 5bc9579..1c43a7c 100644 --- a/account/src/main/java/de/muehlencord/shared/account/util/EndDateable.java +++ b/db/src/main/java/de/muehlencord/shared/db/EndDateable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package de.muehlencord.shared.account.util; +package de.muehlencord.shared.db; import java.util.Date; diff --git a/account/src/main/java/de/muehlencord/shared/account/util/Updateable.java b/db/src/main/java/de/muehlencord/shared/db/Updateable.java similarity index 91% rename from account/src/main/java/de/muehlencord/shared/account/util/Updateable.java rename to db/src/main/java/de/muehlencord/shared/db/Updateable.java index dda107f..b320fcf 100644 --- a/account/src/main/java/de/muehlencord/shared/account/util/Updateable.java +++ b/db/src/main/java/de/muehlencord/shared/db/Updateable.java @@ -1,29 +1,29 @@ -package de.muehlencord.shared.account.util; - -import java.util.Date; - -/** - * This interface is used for Entities which provide createdOn / createdBy - * lastUpatedBy / lastUpdatedOn fields. The AbstractController uses this interface - * to automatically update the fields on creation / update. - * - * @author Joern Muehlencord - */ -public interface Updateable { - - void setCreatedBy(String createdBy); - - String getCreatedBy(); - - void setCreatedOn(Date createdOn); - - Date getCreatedOn(); - - void setLastUpdatedBy(String lastUpdatedBy); - - String getLastUpdatedBy(); - - void setLastUpdatedOn(Date lastUpdatedOn); - - Date getLastUpdatedOn(); -} +package de.muehlencord.shared.db; + +import java.util.Date; + +/** + * This interface is used for Entities which provide createdOn / createdBy + * lastUpatedBy / lastUpdatedOn fields. The AbstractController uses this interface + * to automatically update the fields on creation / update. + * + * @author Joern Muehlencord + */ +public interface Updateable { + + void setCreatedBy(String createdBy); + + String getCreatedBy(); + + void setCreatedOn(Date createdOn); + + Date getCreatedOn(); + + void setLastUpdatedBy(String lastUpdatedBy); + + String getLastUpdatedBy(); + + void setLastUpdatedOn(Date lastUpdatedOn); + + Date getLastUpdatedOn(); +} diff --git a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java index f38f544..3e2ff88 100644 --- a/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java +++ b/jeeutil/src/main/java/de/muehlencord/shared/jeeutil/restexfw/APIException.java @@ -44,6 +44,10 @@ public class APIException extends RuntimeException { public APIException(APIError apiError, Locale locale, String rootCause) { httpResponse = createHttpResponse(new APIErrorResponse(apiError, locale, rootCause)); } + + public APIException(APIError apiError, String locale, String rootCause) { + httpResponse = createHttpResponse(new APIErrorResponse(apiError, new Locale(locale), rootCause)); + } public APIException(Exception exception, Locale locale) { httpResponse = createHttpResponse(new APIErrorResponse(exception, locale)); diff --git a/pom.xml b/pom.xml index 91170ae..6d5ef30 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ poi-util account-ui account-dao + db @@ -34,7 +35,19 @@ - + + + de.muehlencord.shared + shared-db + 1.2-SNAPSHOT + ejb + + + de.muehlencord.shared + shared-account + 1.2-SNAPSHOT + ejb + de.muehlencord.shared shared-account-dao @@ -45,11 +58,6 @@ shared-shiro-faces 1.2-SNAPSHOT - - de.muehlencord.shared - shared-account - 1.2-SNAPSHOT - de.muehlencord.shared shared-util diff --git a/sharepoint/api/pom.xml b/sharepoint/api/pom.xml index 470d778..e70979b 100644 --- a/sharepoint/api/pom.xml +++ b/sharepoint/api/pom.xml @@ -6,7 +6,7 @@ de.muehlencord.shared shared-sharepoint - 1.1-SNAPSHOT + 1.2-SNAPSHOT de.muehlencord.shared.sharepoint diff --git a/sharepoint/pom.xml b/sharepoint/pom.xml index c62e71e..70a0bef 100644 --- a/sharepoint/pom.xml +++ b/sharepoint/pom.xml @@ -4,7 +4,6 @@ de.muehlencord shared - 1.1-SNAPSHOT de.muehlencord.shared shared-sharepoint diff --git a/shiro-faces/pom.xml b/shiro-faces/pom.xml index 6ded040..8acc81b 100644 --- a/shiro-faces/pom.xml +++ b/shiro-faces/pom.xml @@ -1,39 +1,39 @@ - - - 4.0.0 - de.muehlencord.shared - shared-shiro-faces - jar - shared-shiro-faces - - - de.muehlencord - shared - 1.2-SNAPSHOT - - - - - - org.apache.shiro - shiro-web - provided - - - com.sun.faces - jsf-api - provided - - - javax.el - javax.el-api - provided - - - javax - javaee-api - provided - - - + + + 4.0.0 + de.muehlencord.shared + shared-shiro-faces + jar + + + de.muehlencord + shared + 1.2-SNAPSHOT + + + shared-shiro-faces + + + + org.apache.shiro + shiro-web + provided + + + com.sun.faces + jsf-api + provided + + + javax.el + javax.el-api + provided + + + javax + javaee-api + provided + + + \ No newline at end of file diff --git a/util/src/main/java/de/muehlencord/shared/util/StringUtil.java b/util/src/main/java/de/muehlencord/shared/util/StringUtil.java index efbb814..46897a1 100644 --- a/util/src/main/java/de/muehlencord/shared/util/StringUtil.java +++ b/util/src/main/java/de/muehlencord/shared/util/StringUtil.java @@ -2,6 +2,8 @@ package de.muehlencord.shared.util; import java.io.UnsupportedEncodingException; import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +13,9 @@ import org.slf4j.LoggerFactory; */ public abstract class StringUtil { - /** the logging object */ + /** + * the logging object + */ private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class); /** @@ -27,7 +31,7 @@ public abstract class StringUtil { byte[] b = input.getBytes("UTF-8"); return new String(b, "ISO-8859-1"); } catch (UnsupportedEncodingException ex) { - LOGGER.debug (ex.toString(), ex); + LOGGER.debug(ex.toString(), ex); throw new StringEncodingException("Cannot convert string from UTF-8 to ISO-8859-1. Reason: " + ex.getMessage(), ex); } } @@ -40,13 +44,13 @@ public abstract class StringUtil { */ public static String getStackTraceString(Throwable ex) { StringBuilder sb = new StringBuilder(); - sb.append (ex.toString()); - sb.append ("\n"); - + sb.append(ex.toString()); + sb.append("\n"); + StackTraceElement[] stack = ex.getStackTrace(); for (StackTraceElement currentElement : stack) { - sb.append (currentElement.toString()); - sb.append ("\n"); + sb.append(currentElement.toString()); + sb.append("\n"); } return sb.toString(); } @@ -56,7 +60,7 @@ public abstract class StringUtil { * * * - + * * * @param length the needed length for this field * @param s the field to extend with blanks @@ -68,42 +72,45 @@ public abstract class StringUtil { } StringBuilder sb = new StringBuilder(); - sb.append (s); + sb.append(s); while (sb.toString().length() < length) { - sb.append (" "); + sb.append(" "); } return sb.toString(); } /** * returns the string located between the two given keywords + * * @param content the string to get the value from * @param keyWord1 the starting keyword * @param keyWord2 the end keywod * @return the string between keyword1 and keyword2 - * @throws ParseException if the value cannot be determined - e.g. if one of the keywords is not found + * @throws ParseException if the value cannot be determined - e.g. if one of + * the keywords is not found */ public static String getValueBetweenKeywords(String content, String keyWord1, String keyWord2) throws ParseException { int pos1 = content.indexOf(keyWord1); if (pos1 == -1) { - throw new ParseException("Keyword1=" + keyWord1 + " not found in content string",0); + throw new ParseException("Keyword1=" + keyWord1 + " not found in content string", 0); } int pos2 = content.indexOf(keyWord2, pos1); if (pos2 == -1) { - throw new ParseException("Keyword2=" + keyWord2 + " not found in content string",0); + throw new ParseException("Keyword2=" + keyWord2 + " not found in content string", 0); } - String returnValue = content.substring(pos1+keyWord1.length(), pos2); + String returnValue = content.substring(pos1 + keyWord1.length(), pos2); returnValue = returnValue.trim(); return returnValue; } /** * returns true, if given string is either null or a blank string + * * @param s the string to check * @return true, if s is either null or s.equals("") */ public static boolean isEmpty(String s) { - return (s == null) || (s.equals ("")); + return (s == null) || (s.equals("")); + } } -}