splitted database from account
This commit is contained in:
@ -62,6 +62,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
<artifactId>shared-account</artifactId>
|
<artifactId>shared-account</artifactId>
|
||||||
|
<type>ejb</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
|
|||||||
@ -14,13 +14,22 @@
|
|||||||
|
|
||||||
<name>shared-account</name>
|
<name>shared-account</name>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.source>10</maven.compiler.source>
|
|
||||||
<maven.compiler.target>10</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>shared-db</artifactId>
|
||||||
|
<type>ejb</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>shared-account-dao</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>shared-util</artifactId>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
@ -43,10 +52,6 @@
|
|||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>shared-jeeutil</artifactId>
|
<artifactId>shared-jeeutil</artifactId>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>shared-account-dao</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
@ -68,11 +73,6 @@
|
|||||||
<artifactId>jcl-over-slf4j</artifactId>
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
|
||||||
<artifactId>shared-util</artifactId>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
|
|||||||
@ -71,13 +71,21 @@ public class AccountProducer implements Serializable {
|
|||||||
public Account getAccount() {
|
public Account getAccount() {
|
||||||
String accountName;
|
String accountName;
|
||||||
if (account == null) {
|
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) {
|
if (subject == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((subject.isAuthenticated() == false) && (subject.isRemembered() == false)) {
|
if ((subject.isAuthenticated() == false) && (subject.isRemembered() == false)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
accountName = subject.getPrincipal().toString();
|
accountName = subject.getPrincipal().toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.business.account.boundary;
|
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.control.AccountControl;
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
import de.muehlencord.shared.account.business.account.entity.ApiKeyEntity;
|
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.business.config.entity.ConfigException;
|
||||||
import de.muehlencord.shared.account.dao.ApiKeyObject;
|
import de.muehlencord.shared.account.dao.ApiKeyObject;
|
||||||
import de.muehlencord.shared.account.util.AccountPU;
|
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.JWTDecoder;
|
||||||
import de.muehlencord.shared.jeeutil.jwt.JWTEncoder;
|
import de.muehlencord.shared.jeeutil.jwt.JWTEncoder;
|
||||||
import de.muehlencord.shared.jeeutil.jwt.JWTException;
|
import de.muehlencord.shared.jeeutil.jwt.JWTException;
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.business.config.boundary;
|
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.Account;
|
||||||
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
import de.muehlencord.shared.account.business.account.entity.AccountEntity;
|
||||||
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
import de.muehlencord.shared.account.business.application.entity.ApplicationEntity;
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.business.instance.boundary;
|
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.application.entity.ApplicationEntity;
|
||||||
import de.muehlencord.shared.account.business.config.boundary.ConfigService;
|
import de.muehlencord.shared.account.business.config.boundary.ConfigService;
|
||||||
import de.muehlencord.shared.account.business.config.entity.ConfigException;
|
import de.muehlencord.shared.account.business.config.entity.ConfigException;
|
||||||
|
|||||||
52
db/pom.xml
Normal file
52
db/pom.xml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
|
<artifactId>shared-db</artifactId>
|
||||||
|
<packaging>ejb</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>shared</artifactId>
|
||||||
|
<groupId>de.muehlencord</groupId>
|
||||||
|
<version>1.2-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<name>shared-db</name>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>shared-util</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax</groupId>
|
||||||
|
<artifactId>javaee-web-api</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- create EJB version 3.1 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-ejb-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<ejbVersion>3.1</ejbVersion>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/persistence.xml</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -13,11 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* 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.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -41,7 +38,7 @@ import javax.persistence.metamodel.IdentifiableType;
|
|||||||
import javax.persistence.metamodel.Metamodel;
|
import javax.persistence.metamodel.Metamodel;
|
||||||
import javax.persistence.metamodel.SingularAttribute;
|
import javax.persistence.metamodel.SingularAttribute;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import org.apache.shiro.util.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -54,9 +51,6 @@ public abstract class AbstractController<T> {
|
|||||||
@ApplicationPU
|
@ApplicationPU
|
||||||
protected EntityManager em;
|
protected EntityManager em;
|
||||||
|
|
||||||
@Inject
|
|
||||||
protected Account account;
|
|
||||||
|
|
||||||
private final Class<T> entityClass;
|
private final Class<T> entityClass;
|
||||||
|
|
||||||
public AbstractController(Class<T> clazz) {
|
public AbstractController(Class<T> clazz) {
|
||||||
@ -187,12 +181,12 @@ public abstract class AbstractController<T> {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyUpdateableChanges(Updateable updateable, boolean onCreate) throws ControllerException {
|
public void applyUpdateableChanges(Updateable updateable, boolean onCreate, String updatedBy) throws ControllerException {
|
||||||
if (onCreate) {
|
if (onCreate) {
|
||||||
updateable.setCreatedBy(account.getUsername());
|
updateable.setCreatedBy(updatedBy);
|
||||||
updateable.setCreatedOn(new Date());
|
updateable.setCreatedOn(new Date());
|
||||||
}
|
}
|
||||||
updateable.setLastUpdatedBy(account.getUsername());
|
updateable.setLastUpdatedBy(updatedBy);
|
||||||
updateable.setLastUpdatedOn(new Date());
|
updateable.setLastUpdatedOn(new Date());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,10 +197,10 @@ public abstract class AbstractController<T> {
|
|||||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@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())) {
|
if (Updateable.class.isAssignableFrom(entity.getClass())) {
|
||||||
Updateable updateable = (Updateable) entity;
|
Updateable updateable = (Updateable) entity;
|
||||||
applyUpdateableChanges(updateable, true);
|
applyUpdateableChanges(updateable, true, createdBy);
|
||||||
}
|
}
|
||||||
em.persist(entity);
|
em.persist(entity);
|
||||||
return entity;
|
return entity;
|
||||||
@ -215,10 +209,10 @@ public abstract class AbstractController<T> {
|
|||||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@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())) {
|
if (Updateable.class.isAssignableFrom(entity.getClass())) {
|
||||||
Updateable updateable = (Updateable) entity;
|
Updateable updateable = (Updateable) entity;
|
||||||
applyUpdateableChanges(updateable, false);
|
applyUpdateableChanges(updateable, false, updatedBy);
|
||||||
}
|
}
|
||||||
return em.merge(entity);
|
return em.merge(entity);
|
||||||
}
|
}
|
||||||
@ -226,7 +220,7 @@ public abstract class AbstractController<T> {
|
|||||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public void delete(T entity) throws ControllerException {
|
public void delete(T entity, String deletedBy) throws ControllerException {
|
||||||
em.remove(attach(entity));
|
em.remove(attach(entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,10 +13,8 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* 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 de.muehlencord.shared.util.DateUtil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -51,34 +49,34 @@ public abstract class AbstractEnddateableController<T extends EndDateable<T>> ex
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
@Override
|
@Override
|
||||||
public void delete(T entity) throws ControllerException {
|
public void delete(T entity, String deletedBy) throws ControllerException {
|
||||||
T entityToUpdate = attach(entity);
|
T entityToUpdate = attach(entity);
|
||||||
if (Updateable.class.isAssignableFrom(entityToUpdate.getClass())) {
|
if (Updateable.class.isAssignableFrom(entityToUpdate.getClass())) {
|
||||||
Updateable updateable = (Updateable) entityToUpdate;
|
Updateable updateable = (Updateable) entityToUpdate;
|
||||||
applyUpdateableChanges(updateable, false);
|
applyUpdateableChanges(updateable, false, deletedBy);
|
||||||
}
|
}
|
||||||
entityToUpdate.setValidTo(DateUtil.getCurrentTimeInUTC());
|
entityToUpdate.setValidTo(DateUtil.getCurrentTimeInUTC());
|
||||||
em.merge(entityToUpdate);
|
em.merge(entityToUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
public T create(T entity) throws ControllerException {
|
public T create(T entity, String createdBy) throws ControllerException {
|
||||||
entity.setValidFrom(DateUtil.getCurrentTimeInUTC());
|
entity.setValidFrom(DateUtil.getCurrentTimeInUTC());
|
||||||
return super.create(entity);
|
return super.create(entity, createdBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||||
@Transactional
|
@Transactional
|
||||||
@Lock(LockType.WRITE)
|
@Lock(LockType.WRITE)
|
||||||
@Override
|
@Override
|
||||||
public T update(T entity) throws ControllerException {
|
public T update(T entity, String createdBy) throws ControllerException {
|
||||||
T newEntity = entity.cloneEndDateable();
|
T newEntity = entity.cloneEndDateable();
|
||||||
delete(entity);
|
delete(entity, createdBy);
|
||||||
return create (newEntity);
|
return create(newEntity, createdBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Lock(LockType.READ)
|
@Lock(LockType.READ)
|
||||||
@Override
|
@Override
|
||||||
@ -89,10 +87,10 @@ public abstract class AbstractEnddateableController<T extends EndDateable<T>> ex
|
|||||||
final Root<T> root = criteria.from(endDateableClass);
|
final Root<T> root = criteria.from(endDateableClass);
|
||||||
|
|
||||||
Predicate alreadyValid = cb.lessThanOrEqualTo(root.get("validFrom"), now);
|
Predicate alreadyValid = cb.lessThanOrEqualTo(root.get("validFrom"), now);
|
||||||
|
|
||||||
Predicate validToNotSet = cb.isNull(root.get("validTo"));
|
Predicate validToNotSet = cb.isNull(root.get("validTo"));
|
||||||
Predicate isBeforeValidTo = cb.greaterThanOrEqualTo(root.get("validTo"), now);
|
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);
|
Predicate isValid = cb.and(alreadyValid, stillValid);
|
||||||
criteria.where(isValid);
|
criteria.where(isValid);
|
||||||
|
|
||||||
@ -1,36 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 joern.muehlencord.
|
* Copyright 2018 joern.muehlencord.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.util;
|
package de.muehlencord.shared.db;
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
import static java.lang.annotation.ElementType.FIELD;
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
import static java.lang.annotation.ElementType.METHOD;
|
||||||
import static java.lang.annotation.ElementType.PARAMETER;
|
import static java.lang.annotation.ElementType.PARAMETER;
|
||||||
import static java.lang.annotation.ElementType.TYPE;
|
import static java.lang.annotation.ElementType.TYPE;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import javax.inject.Qualifier;
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Joern Muehlencord <joern at muehlencord.de>
|
* @author Joern Muehlencord <joern at muehlencord.de>
|
||||||
*/
|
*/
|
||||||
@Qualifier
|
@Qualifier
|
||||||
@Retention(RUNTIME)
|
@Retention(RUNTIME)
|
||||||
@Target({METHOD, FIELD, PARAMETER, TYPE})
|
@Target({METHOD, FIELD, PARAMETER, TYPE})
|
||||||
public @interface ApplicationPU {
|
public @interface ApplicationPU {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,46 +1,46 @@
|
|||||||
package de.muehlencord.shared.account.util;
|
package de.muehlencord.shared.db;
|
||||||
|
|
||||||
import javax.annotation.Priority;
|
import javax.annotation.Priority;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.interceptor.AroundInvoke;
|
import javax.interceptor.AroundInvoke;
|
||||||
import javax.interceptor.Interceptor;
|
import javax.interceptor.Interceptor;
|
||||||
import javax.interceptor.InvocationContext;
|
import javax.interceptor.InvocationContext;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import static javax.transaction.Transactional.TxType.REQUIRED;
|
import static javax.transaction.Transactional.TxType.REQUIRED;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Joern Muehlencord <joern at muehlencord.de>
|
* @author Joern Muehlencord <joern at muehlencord.de>
|
||||||
*/
|
*/
|
||||||
@Transactional(value = REQUIRED)
|
@Transactional(value = REQUIRED)
|
||||||
@Interceptor
|
@Interceptor
|
||||||
@Priority(value = ApplicationTransactionJoinInterceptor.PRIORITY)
|
@Priority(value = ApplicationTransactionJoinInterceptor.PRIORITY)
|
||||||
public class ApplicationTransactionJoinInterceptor {
|
public class ApplicationTransactionJoinInterceptor {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTransactionJoinInterceptor.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTransactionJoinInterceptor.class);
|
||||||
|
|
||||||
// attach behind the interceptor of the container
|
// attach behind the interceptor of the container
|
||||||
public static final int PRIORITY = Interceptor.Priority.PLATFORM_BEFORE + 250;
|
public static final int PRIORITY = Interceptor.Priority.PLATFORM_BEFORE + 250;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ApplicationPU
|
@ApplicationPU
|
||||||
private EntityManager em;
|
private EntityManager em;
|
||||||
|
|
||||||
@AroundInvoke
|
@AroundInvoke
|
||||||
public Object joinTransaction(InvocationContext context) throws Exception {
|
public Object joinTransaction(InvocationContext context) throws Exception {
|
||||||
if (em == null) {
|
if (em == null) {
|
||||||
return context.proceed();
|
return context.proceed();
|
||||||
} else {
|
} else {
|
||||||
if (em.isJoinedToTransaction()) {
|
if (em.isJoinedToTransaction()) {
|
||||||
LOGGER.trace("transaction already joined");
|
LOGGER.trace("transaction already joined");
|
||||||
} else {
|
} else {
|
||||||
LOGGER.trace("joining transaction");
|
LOGGER.trace("joining transaction");
|
||||||
em.joinTransaction();
|
em.joinTransaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return context.proceed();
|
return context.proceed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,62 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 joern.muehlencord.
|
* Copyright 2019 joern.muehlencord.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.business;
|
package de.muehlencord.shared.db;
|
||||||
|
|
||||||
import javax.ejb.ApplicationException;
|
import javax.ejb.ApplicationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author joern.muehlencord
|
* @author joern.muehlencord
|
||||||
*/
|
*/
|
||||||
@ApplicationException(rollback=true)
|
@ApplicationException(rollback=true)
|
||||||
public class ControllerException extends Exception {
|
public class ControllerException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 5190280225284514859L;
|
private static final long serialVersionUID = 5190280225284514859L;
|
||||||
public static final int CAUSE_ALREADY_EXISTS = 1;
|
public static final int CAUSE_ALREADY_EXISTS = 1;
|
||||||
public static final int CAUSE_NOT_FOUND = 2;
|
public static final int CAUSE_NOT_FOUND = 2;
|
||||||
public static final int CAUSE_CANNOT_PERSIST = 3;
|
public static final int CAUSE_CANNOT_PERSIST = 3;
|
||||||
public static final int CAUSE_TOO_MANY_ROWS = 4;
|
public static final int CAUSE_TOO_MANY_ROWS = 4;
|
||||||
public static final int CAUSE_CANNOT_DELETE = 5;
|
public static final int CAUSE_CANNOT_DELETE = 5;
|
||||||
|
|
||||||
private final int causeCode;
|
private final int causeCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of <code>ControllerException</code> without detail
|
* Creates a new instance of <code>ControllerException</code> without detail
|
||||||
* message.
|
* message.
|
||||||
*
|
*
|
||||||
* @param cause the reason code
|
* @param cause the reason code
|
||||||
* @param message an explanation
|
* @param message an explanation
|
||||||
*/
|
*/
|
||||||
public ControllerException(int cause, String message) {
|
public ControllerException(int cause, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.causeCode = cause;
|
this.causeCode = cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param causeCode
|
* @param causeCode
|
||||||
* @param message
|
* @param message
|
||||||
* @param cause
|
* @param cause
|
||||||
*/
|
*/
|
||||||
public ControllerException(int causeCode, String message, Throwable cause) {
|
public ControllerException(int causeCode, String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.causeCode = causeCode;
|
this.causeCode = causeCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCauseCode() {
|
public int getCauseCode() {
|
||||||
return causeCode;
|
return causeCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package de.muehlencord.shared.account.util;
|
package de.muehlencord.shared.db;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ -1,29 +1,29 @@
|
|||||||
package de.muehlencord.shared.account.util;
|
package de.muehlencord.shared.db;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface is used for Entities which provide createdOn / createdBy
|
* This interface is used for Entities which provide createdOn / createdBy
|
||||||
* lastUpatedBy / lastUpdatedOn fields. The AbstractController uses this interface
|
* lastUpatedBy / lastUpdatedOn fields. The AbstractController uses this interface
|
||||||
* to automatically update the fields on creation / update.
|
* to automatically update the fields on creation / update.
|
||||||
*
|
*
|
||||||
* @author Joern Muehlencord <joern at muehlencord.de>
|
* @author Joern Muehlencord <joern at muehlencord.de>
|
||||||
*/
|
*/
|
||||||
public interface Updateable {
|
public interface Updateable {
|
||||||
|
|
||||||
void setCreatedBy(String createdBy);
|
void setCreatedBy(String createdBy);
|
||||||
|
|
||||||
String getCreatedBy();
|
String getCreatedBy();
|
||||||
|
|
||||||
void setCreatedOn(Date createdOn);
|
void setCreatedOn(Date createdOn);
|
||||||
|
|
||||||
Date getCreatedOn();
|
Date getCreatedOn();
|
||||||
|
|
||||||
void setLastUpdatedBy(String lastUpdatedBy);
|
void setLastUpdatedBy(String lastUpdatedBy);
|
||||||
|
|
||||||
String getLastUpdatedBy();
|
String getLastUpdatedBy();
|
||||||
|
|
||||||
void setLastUpdatedOn(Date lastUpdatedOn);
|
void setLastUpdatedOn(Date lastUpdatedOn);
|
||||||
|
|
||||||
Date getLastUpdatedOn();
|
Date getLastUpdatedOn();
|
||||||
}
|
}
|
||||||
@ -44,6 +44,10 @@ public class APIException extends RuntimeException {
|
|||||||
public APIException(APIError apiError, Locale locale, String rootCause) {
|
public APIException(APIError apiError, Locale locale, String rootCause) {
|
||||||
httpResponse = createHttpResponse(new APIErrorResponse(apiError, locale, 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) {
|
public APIException(Exception exception, Locale locale) {
|
||||||
httpResponse = createHttpResponse(new APIErrorResponse(exception, locale));
|
httpResponse = createHttpResponse(new APIErrorResponse(exception, locale));
|
||||||
|
|||||||
20
pom.xml
20
pom.xml
@ -19,6 +19,7 @@
|
|||||||
<module>poi-util</module>
|
<module>poi-util</module>
|
||||||
<module>account-ui</module>
|
<module>account-ui</module>
|
||||||
<module>account-dao</module>
|
<module>account-dao</module>
|
||||||
|
<module>db</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
@ -34,7 +35,19 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
|
<artifactId>shared-db</artifactId>
|
||||||
|
<version>1.2-SNAPSHOT</version>
|
||||||
|
<type>ejb</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
|
<artifactId>shared-account</artifactId>
|
||||||
|
<version>1.2-SNAPSHOT</version>
|
||||||
|
<type>ejb</type>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
<artifactId>shared-account-dao</artifactId>
|
<artifactId>shared-account-dao</artifactId>
|
||||||
@ -45,11 +58,6 @@
|
|||||||
<artifactId>shared-shiro-faces</artifactId>
|
<artifactId>shared-shiro-faces</artifactId>
|
||||||
<version>1.2-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
|
||||||
<artifactId>shared-account</artifactId>
|
|
||||||
<version>1.2-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
<artifactId>shared-util</artifactId>
|
<artifactId>shared-util</artifactId>
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
<artifactId>shared-sharepoint</artifactId>
|
<artifactId>shared-sharepoint</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
<version>1.2-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>de.muehlencord.shared.sharepoint</groupId>
|
<groupId>de.muehlencord.shared.sharepoint</groupId>
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>de.muehlencord</groupId>
|
<groupId>de.muehlencord</groupId>
|
||||||
<artifactId>shared</artifactId>
|
<artifactId>shared</artifactId>
|
||||||
<version>1.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
<artifactId>shared-sharepoint</artifactId>
|
<artifactId>shared-sharepoint</artifactId>
|
||||||
|
|||||||
@ -1,39 +1,39 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>de.muehlencord.shared</groupId>
|
<groupId>de.muehlencord.shared</groupId>
|
||||||
<artifactId>shared-shiro-faces</artifactId>
|
<artifactId>shared-shiro-faces</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>shared-shiro-faces</name>
|
|
||||||
|
<parent>
|
||||||
<parent>
|
<groupId>de.muehlencord</groupId>
|
||||||
<groupId>de.muehlencord</groupId>
|
<artifactId>shared</artifactId>
|
||||||
<artifactId>shared</artifactId>
|
<version>1.2-SNAPSHOT</version>
|
||||||
<version>1.2-SNAPSHOT</version>
|
</parent>
|
||||||
</parent>
|
|
||||||
|
<name>shared-shiro-faces</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.shiro</groupId>
|
<groupId>org.apache.shiro</groupId>
|
||||||
<artifactId>shiro-web</artifactId>
|
<artifactId>shiro-web</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.faces</groupId>
|
<groupId>com.sun.faces</groupId>
|
||||||
<artifactId>jsf-api</artifactId>
|
<artifactId>jsf-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.el</groupId>
|
<groupId>javax.el</groupId>
|
||||||
<artifactId>javax.el-api</artifactId>
|
<artifactId>javax.el-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax</groupId>
|
<groupId>javax</groupId>
|
||||||
<artifactId>javaee-api</artifactId>
|
<artifactId>javaee-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@ -2,6 +2,8 @@ package de.muehlencord.shared.util;
|
|||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -11,7 +13,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public abstract class StringUtil {
|
public abstract class StringUtil {
|
||||||
|
|
||||||
/** the logging object */
|
/**
|
||||||
|
* the logging object
|
||||||
|
*/
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +31,7 @@ public abstract class StringUtil {
|
|||||||
byte[] b = input.getBytes("UTF-8");
|
byte[] b = input.getBytes("UTF-8");
|
||||||
return new String(b, "ISO-8859-1");
|
return new String(b, "ISO-8859-1");
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} 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);
|
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) {
|
public static String getStackTraceString(Throwable ex) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append (ex.toString());
|
sb.append(ex.toString());
|
||||||
sb.append ("\n");
|
sb.append("\n");
|
||||||
|
|
||||||
StackTraceElement[] stack = ex.getStackTrace();
|
StackTraceElement[] stack = ex.getStackTrace();
|
||||||
for (StackTraceElement currentElement : stack) {
|
for (StackTraceElement currentElement : stack) {
|
||||||
sb.append (currentElement.toString());
|
sb.append(currentElement.toString());
|
||||||
sb.append ("\n");
|
sb.append("\n");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -56,7 +60,7 @@ public abstract class StringUtil {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
*
|
||||||
*
|
*
|
||||||
* @param length the needed length for this field
|
* @param length the needed length for this field
|
||||||
* @param s the field to extend with blanks
|
* @param s the field to extend with blanks
|
||||||
@ -68,42 +72,45 @@ public abstract class StringUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append (s);
|
sb.append(s);
|
||||||
while (sb.toString().length() < length) {
|
while (sb.toString().length() < length) {
|
||||||
sb.append (" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the string located between the two given keywords
|
* returns the string located between the two given keywords
|
||||||
|
*
|
||||||
* @param content the string to get the value from
|
* @param content the string to get the value from
|
||||||
* @param keyWord1 the starting keyword
|
* @param keyWord1 the starting keyword
|
||||||
* @param keyWord2 the end keywod
|
* @param keyWord2 the end keywod
|
||||||
* @return the string between keyword1 and keyword2
|
* @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 {
|
public static String getValueBetweenKeywords(String content, String keyWord1, String keyWord2) throws ParseException {
|
||||||
int pos1 = content.indexOf(keyWord1);
|
int pos1 = content.indexOf(keyWord1);
|
||||||
if (pos1 == -1) {
|
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);
|
int pos2 = content.indexOf(keyWord2, pos1);
|
||||||
if (pos2 == -1) {
|
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();
|
returnValue = returnValue.trim();
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true, if given string is either null or a blank string
|
* returns true, if given string is either null or a blank string
|
||||||
|
*
|
||||||
* @param s the string to check
|
* @param s the string to check
|
||||||
* @return true, if s is either null or s.equals("")
|
* @return true, if s is either null or s.equals("")
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(String s) {
|
public static boolean isEmpty(String s) {
|
||||||
return (s == null) || (s.equals (""));
|
return (s == null) || (s.equals(""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user