Commit 4ea27d63 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'master' into emailvalidation-igoshin

Conflicts:
	pom.xml
	src/main/java/org/genesys2/server/service/UserService.java
	src/main/java/org/genesys2/server/service/impl/UserServiceImpl.java
	src/main/java/org/genesys2/server/servlet/controller/UserProfileController.java
	src/main/resources/spring/spring.properties
	src/main/webapp/WEB-INF/jsp/user/profile.jsp
parents 3211dc28 ce2304ed
......@@ -101,11 +101,6 @@
<version>${commons.beanutils.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
......@@ -352,13 +347,16 @@
<artifactId>spring-aspects</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.5.0-b01</version>
</dependency>
</dependencies>
<build>
......
......@@ -26,8 +26,7 @@ public class CountryInfo implements Serializable {
private final boolean active;
private final Long refnameId;
public CountryInfo(final String iso, final String iso3,
final String isoNum, final String name, final boolean active) {
public CountryInfo(final String iso, final String iso3, final String isoNum, final String name, final boolean active) {
this.iso = iso;
this.iso3 = iso3;
this.isoNum = isoNum;
......@@ -36,9 +35,7 @@ public class CountryInfo implements Serializable {
this.refnameId = null;
}
public CountryInfo(final String iso, final String iso3,
final String isoNum, final String name, final Long refnameId,
final boolean active) {
public CountryInfo(final String iso, final String iso3, final String isoNum, final String name, final Long refnameId, final boolean active) {
this.iso = iso;
this.iso3 = iso3;
this.isoNum = isoNum;
......@@ -119,8 +116,6 @@ public class CountryInfo implements Serializable {
@Override
public String toString() {
return MessageFormat.format(
"Country iso={0} iso3={1} name={2} active={3}", iso, iso3,
name, active);
return MessageFormat.format("Country iso={0} iso3={1} name={2} active={3}", iso, iso3, name, active);
}
}
\ No newline at end of file
......@@ -71,8 +71,7 @@ public class DavrosCountrySource {
try {
instream = entity.getContent();
final BufferedReader inreader = new BufferedReader(
new InputStreamReader(instream));
final BufferedReader inreader = new BufferedReader(new InputStreamReader(instream));
final List<CountryInfo> countries = new ArrayList<CountryInfo>();
......@@ -85,8 +84,7 @@ public class DavrosCountrySource {
if (line.startsWith("# Table 1: current codes")) {
active = true;
continue;
} else if (line
.startsWith("# Table 2: codes withdrawn from use")) {
} else if (line.startsWith("# Table 2: codes withdrawn from use")) {
active = false;
continue;
} else if (line.length() == 0) {
......@@ -124,8 +122,7 @@ public class DavrosCountrySource {
* @param line
* @return
*/
public static CountryInfo parseDavros(final String line,
final boolean active) {
public static CountryInfo parseDavros(final String line, final boolean active) {
final String a = line.substring(0, 10);
final String b = line.substring(11);
if (LOG.isTraceEnabled()) {
......
......@@ -46,8 +46,7 @@ import au.com.bytecode.opencsv.CSVReader;
public class GeoNamesCountrySource {
private static final String GEONAMES_ISO3166_URL = "http://download.geonames.org/export/dump/countryInfo.txt";
public static final Log LOG = LogFactory
.getLog(GeoNamesCountrySource.class);
public static final Log LOG = LogFactory.getLog(GeoNamesCountrySource.class);
/**
* Retrieve data from davros.org
......@@ -76,8 +75,7 @@ public class GeoNamesCountrySource {
try {
instream = entity.getContent();
final BufferedReader inreader = new BufferedReader(
new InputStreamReader(instream));
final BufferedReader inreader = new BufferedReader(new InputStreamReader(instream));
// Find line that starts with
// #ISO ISO3 ISO-Numeric fips
......@@ -105,8 +103,7 @@ public class GeoNamesCountrySource {
if (StringUtils.isNotBlank(data[16])) {
refnameId = Long.valueOf(data[16]);
}
final CountryInfo countryInfo = new CountryInfo(data[0],
data[1], data[2], data[4], refnameId, true);
final CountryInfo countryInfo = new CountryInfo(data[0], data[1], data[2], data[4], refnameId, true);
if (!countries.contains(countryInfo)) {
countries.add(countryInfo);
}
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server;
public class ApplicationException extends Exception {
......
......@@ -14,88 +14,86 @@
* limitations under the License.
**/
package org.genesys2.server;
public interface ServiceEndpoints {
/*===============================================================*/
/*==================== Service endpoint /me =====================*/
/*===============================================================*/
/* =============================================================== */
/* ==================== Service endpoint /me ===================== */
/* =============================================================== */
//Retrieve current User profile
// Retrieve current User profile
String ME = "/me";
//List Organizations that current User belongs to
// List Organizations that current User belongs to
String MY_ORGANIZATIONS = "/me/organizations";
//List DataSets owned by current User
// List DataSets owned by current User
String MY_DATA_SETS = "/me/datasets";
//List Traits owned by current User
// List Traits owned by current User
String MY_TRAITS = "/me/traits";
/*===============================================================*/
/*=============== Service endpoint /organizations ===============*/
/*===============================================================*/
/* =============================================================== */
/* =============== Service endpoint /organizations =============== */
/* =============================================================== */
//Lists all Traits associated with Organization $O
// Lists all Traits associated with Organization $O
String ORGANIZATION_TRAITS = "/organizations/{organizationId}/traits";
//Lists all DataSets associated with Organization $O
// Lists all DataSets associated with Organization $O
String ORGANIZATION_DATA_SETS = "/organizations/{organizationId}/datasets";
//List all Licenses associated with Organization $O
// List all Licenses associated with Organization $O
String ORGANIZATION_LICENSES = "/organizations/{organizationId}/licenses";
//Issue a request for current User to join Organization $O
// Issue a request for current User to join Organization $O
String JOIN_ORGANIZATION = "/organizations/{organizationId}/join";
/*===============================================================*/
/*=============== Service endpoint /traits ======================*/
/*===============================================================*/
/* =============================================================== */
/* =============== Service endpoint /traits ====================== */
/* =============================================================== */
//Lists all Traits available to Current User
// Lists all Traits available to Current User
String TRAITS = "/traits";
//Remove Trait
// Remove Trait
String REMOVE_TRAIT = "/traits/{traitId}";
/*===============================================================*/
/*=============== Service endpoint /licenses ====================*/
/*===============================================================*/
/* =============================================================== */
/* =============== Service endpoint /licenses ==================== */
/* =============================================================== */
//Lists all Licenses available to Current User
// Lists all Licenses available to Current User
String LICENSES = "/licenses";
//Remove License {licenseId}
// Remove License {licenseId}
String REMOVE_LICENSE = "/licenses/{licenseId}";
/* =============================================================== */
/* =============== Service endpoint /datasets ==================== */
/* =============================================================== */
/*===============================================================*/
/*=============== Service endpoint /datasets ====================*/
/*===============================================================*/
//List available DataSets
// List available DataSets
String DATASETS = "/datasets";
//Remove data set {dataSetId}
// Remove data set {dataSetId}
String REMOVE_DATASET = "/datasets/{dataSetId}";
//Get all Entries of DataSet {dataSetId}
// Get all Entries of DataSet {dataSetId}
String DATASET_ENTRIES = "/datasets/{dataSetId}/data";
//Update Entry {dataEntryId} in DataSet {dataSetId}
// Update Entry {dataEntryId} in DataSet {dataSetId}
String UPDATE_DATASET_ENTRY = "/datasets/{dataSetId}/data/{dataEntryId}";
//Delete Entry {dataEntryId} from DataSet {dataSetId}
// Delete Entry {dataEntryId} from DataSet {dataSetId}
String REMOVE_DATASET_ENTRY = "/datasets/{dataSetId}/data/{dataEntryId}";
/*===============================================================*/
/*=============== Service endpoint /tokens ====================*/
/*===============================================================*/
/* =============================================================== */
/* =============== Service endpoint /tokens ==================== */
/* =============================================================== */
//List available Tokens
// List available Tokens
String LIST_USER_TOKENS = "/users/{username}/list/tokens";
String REVOKE_USER_TOKEN = "/users/{username}/tokens/revoke/{token}";
......
......@@ -20,7 +20,7 @@ import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.genesys2.server.model.AclAwareModel;
import org.genesys2.server.service.AclAssignerService;
import org.genesys2.server.service.AclService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -33,7 +33,7 @@ public class AclAssignerAspect {
private static final Logger LOG = LoggerFactory.getLogger(AclAssignerAspect.class);
@Autowired
private AclAssignerService aclAssignerService;
private AclService aclService;
@Around("execution(* org.genesys2.server.persistence.domain.*.save(..))")
public Object aroundSaveAclObject(ProceedingJoinPoint pjp) throws Throwable {
......@@ -50,7 +50,7 @@ public class AclAssignerAspect {
if (needsAcl) {
AclAwareModel aclModel = (AclAwareModel) retval;
LOG.warn("Inserting ACL entries for owner: " + aclModel.getId());
aclAssignerService.addCreatorPermissions(aclModel);
aclService.addCreatorPermissions(aclModel);
}
return retval;
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.aspect;
import java.lang.annotation.Documented;
......@@ -25,7 +24,7 @@ import java.lang.annotation.Target;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface AsAdmin {
}
......@@ -48,7 +48,7 @@ public class AsAdminAspect {
@Around("org.genesys2.server.aspect.SystemArchitecture.allServices()" + " && @annotation(org.genesys2.server.aspect.AsAdmin)")
public Object authenticateAsAdmin(ProceedingJoinPoint pjp) throws Throwable {
loadSystemAdminAccount("SYSTEM");
getSystemAdminAccount();
// store previous version of auth (if any exists)
Authentication prevAuth = SecurityContextHolder.getContext().getAuthentication();
......@@ -75,7 +75,7 @@ public class AsAdminAspect {
}
}
private synchronized void loadSystemAdminAccount(String string) {
public synchronized Authentication getSystemAdminAccount() {
if (SYS_ADMIN == null) {
LOG.warn("SYS_ADMIN not loaded. Loading now.");
User sysUser = userService.getSystemUser("SYSTEM");
......@@ -94,6 +94,8 @@ public class AsAdminAspect {
SYS_ADMIN = new PreAuthenticatedAuthenticationToken(userDetails, null, userDetails.getAuthorities());
}
}
return SYS_ADMIN;
}
}
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.aspect;
import org.aspectj.lang.annotation.Aspect;
......@@ -28,40 +27,40 @@ public class SystemArchitecture {
*/
@Pointcut("businessServices() || sampleServices() || securityServices() || controllers()")
public void allServices(){
public void allServices() {
}
@Pointcut("execution(* org.genesys2.server.service.*.*(..))")
public void businessServices(){
public void businessServices() {
}
@Pointcut("execution(* org.genesys2.server.listener.sample.*.*(..))")
public void sampleServices(){
public void sampleServices() {
}
@Pointcut("execution(* org.genesys2.server.security.*.*(..))")
public void securityServices(){
public void securityServices() {
}
@Pointcut("execution(* org.genesys2.server.servlet.controller.*.*(..))")
public void controllers(){
public void controllers() {
}
/**
* ACL-based pointcuts
*/
//USER
// USER
@Pointcut("execution(* org.genesys2.server.service.impl.UserServiceImpl.addUser(..))")
public void addUserModel(){
public void addUserModel() {
}
@Pointcut("execution(* org.genesys2.server.service.impl.UserServiceImpl.updateUser(..))")
public void changeUserModel(){
public void changeUserModel() {
}
@Pointcut("execution(* org.genesys2.server.service.impl.UserServiceImpl.removeUser(..))")
public void removeUserModel(){
public void removeUserModel() {
}
}
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.config;
import org.springframework.beans.factory.annotation.Value;
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.exception;
public class ApplicationException extends Exception {
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.exception;
public class AuthorizationException extends ApplicationException {
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.exception;
public class NoSuchTokenException extends RuntimeException {
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.exception;
public class NoUserFoundException extends UserException {
......@@ -54,5 +53,4 @@ public class NoUserFoundException extends UserException {
return modelId;
}
}
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.exception;
public class NotUniqueUserException extends UserException {
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.exception;
import org.genesys2.server.ApplicationException;
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.factory;
import org.springframework.beans.BeansException;
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.genesys2.server.listener;
import java.util.concurrent.Callable;
......@@ -25,14 +24,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class RunAsAdminListener implements InitializingBean{
public abstract class RunAsAdminListener implements InitializingBean {
@Autowired
protected AsAdminInvoker asAdminInvoker;
protected Logger _logger = LoggerFactory.getLogger(getClass());
//in initializing stage @AsAdmin doesn't work properly
// in initializing stage @AsAdmin doesn't work properly
@Override
public void afterPropertiesSet() throws Exception {
asAdminInvoker.invoke(new Callable<Object>() {
......
......@@ -25,6 +25,7 @@ import org.genesys2.server.model.UserRole;
import org.genesys2.server.model.impl.User;
import org.genesys2.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
@Service("createAdminListener")
......@@ -37,7 +38,7 @@ public class CreateAdminListener extends RunAsAdminListener {
public void init() throws Exception {
_logger.info("Checking for at least one account");
if (userService.getCurrentPage(0, 1).getTotalElements() == 0) {
if (userService.listUsers(new PageRequest(0, 1)).getTotalElements() == 0) {
createDefaultAccounts();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment