Skip to content

Commit

Permalink
GBOCI-375: Commit 2.4 release into GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
GBO-Provincies committed Feb 20, 2017
1 parent 202ebee commit aa22026
Show file tree
Hide file tree
Showing 107 changed files with 3,189 additions and 1,416 deletions.
27 changes: 27 additions & 0 deletions admin/src/main/java/nl/ipo/cds/admin/BaseConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ public class BaseConfiguration {
private String cdsVersion;
private String mavenVersion;
private String build;
private String requestAuthorizationPrompt;
private String requestAuthorizationHref;

public String getCdsVersion() {
System.err.println("get cdsVersion: "+cdsVersion);
Expand Down Expand Up @@ -36,6 +38,31 @@ public void setBuild(String build) {
this.build = build;
}

/**
* @return The prompt to display on the login page to request authorization.
*/
public String getRequestAuthorizationPrompt () {
return requestAuthorizationPrompt;
}

/**
* @param requestAuthorizationPrompt The prompt to display on the login page to request authorization.
*/
public void setRequestAuthorizationPrompt (final String requestAuthorizationPrompt) {
this.requestAuthorizationPrompt = requestAuthorizationPrompt;
}

/**
* @return The href to use on the authorization prompt.
*/
public String getRequestAuthorizationHref () {
return requestAuthorizationHref;
}

/**
* @param requestAuthorizationHref The href to use on the authorization prompt.
*/
public void setRequestAuthorizationHref (final String requestAuthorizationHref) {
this.requestAuthorizationHref = requestAuthorizationHref;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import nl.ipo.cds.dao.attributemapping.TransformOperationDTO;
import nl.ipo.cds.domain.Dataset;
import nl.ipo.cds.domain.FeatureType;
import nl.ipo.cds.domain.ValidateJob;
import nl.ipo.cds.etl.attributemapping.AttributeMappingValidator;
import nl.ipo.cds.etl.process.HarvesterException;
import nl.ipo.cds.etl.theme.AttributeDescriptor;
import nl.ipo.cds.etl.theme.ThemeConfig;
Expand Down Expand Up @@ -79,6 +81,22 @@ public static OperationDTO makeOperationTree (final OperationDiscoverer operatio
return factory.buildOperationCommand (mapping);
}

/**
* Test whether a mapping is valid or not.
* @param operationTree
* @param attributeDescriptor
* @param featureType
* @return the validity.
*/
public static boolean isMappingValid(OperationDTO rootOperation, AttributeDescriptor<?> attributeDescriptor,
FeatureType featureType) {

final AttributeMappingValidator validator = new AttributeMappingValidator(attributeDescriptor, featureType,
new AttributeMappingValidatorLogger());
final boolean isValid = validator.isValid(new ValidateJob(), rootOperation);
return isValid;
}

public static Set<AttributeDescriptor<?>> getAttributeDescriptors (final ThemeDiscoverer themeDiscoverer, final Dataset dataset) throws ThemeNotFoundException {
final ThemeConfig<?> themeConfig = themeDiscoverer.getThemeConfiguration (
dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ public InputOperationDTO buildInputOperation (final InputAttribute inputAttribut
throw new MappingParserException (String.format ("Attribute type not found: %s", inputAttribute.getInputAttributeType ()));
}

return new InputOperationDTO (attribute, inputAttribute.getName (), attribute != null ? attribute.getType () : null);
// attributeType is mandatory
return new InputOperationDTO (attribute, inputAttribute.getName (), attribute != null ? attribute.getType () : attributeType);
}

public TransformOperationDTO buildTransformOperation (final TransformOperation transformOperation) throws MappingParserException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand All @@ -27,7 +28,6 @@
import nl.idgis.commons.utils.DateTimeUtils;
import nl.ipo.cds.admin.ba.UnauthorizedException;
import nl.ipo.cds.admin.ba.attributemapping.AttributeMappingUtils;
import nl.ipo.cds.admin.ba.attributemapping.AttributeMappingValidatorLogger;
import nl.ipo.cds.admin.ba.attributemapping.FeatureTypeCache;
import nl.ipo.cds.admin.ba.attributemapping.MappingFactory;
import nl.ipo.cds.admin.ba.controller.beans.AttributeDescriptorsResponse;
Expand All @@ -53,20 +53,20 @@
import nl.ipo.cds.dao.attributemapping.AttributeMappingDao;
import nl.ipo.cds.dao.attributemapping.OperationDTO;
import nl.ipo.cds.domain.Bronhouder;
import nl.ipo.cds.domain.BronhouderThema;
import nl.ipo.cds.domain.Dataset;
import nl.ipo.cds.domain.DatasetFilter;
import nl.ipo.cds.domain.EtlJob;
import nl.ipo.cds.domain.FeatureType;
import nl.ipo.cds.domain.Gebruiker;
import nl.ipo.cds.domain.GebruikersRol;
import nl.ipo.cds.domain.Rol;
import nl.ipo.cds.domain.GebruikerThemaAutorisatie;
import nl.ipo.cds.domain.Thema;
import nl.ipo.cds.domain.ValidateJob;
import nl.ipo.cds.etl.DatasetHandlers;
import nl.ipo.cds.etl.FeatureOutputStream;
import nl.ipo.cds.etl.GenericFeature;
import nl.ipo.cds.etl.PersistableFeature;
import nl.ipo.cds.etl.attributemapping.AttributeMappingFactory;
import nl.ipo.cds.etl.attributemapping.AttributeMappingValidator;
import nl.ipo.cds.etl.filtering.DatasetFiltererFactory;
import nl.ipo.cds.etl.filtering.FilterExpressionValidator;
import nl.ipo.cds.etl.filtering.FilterExpressionValidator.MessageKey;
Expand Down Expand Up @@ -161,10 +161,16 @@ public Dataset getDataset (final @PathVariable("datasetId") long datasetId, fina

// Check whether the current user has access to the dataset:
final Bronhouder bronhouder = dataset.getBronhouder ();
final Thema thema = dataset.getDatasetType ().getThema ();
final Gebruiker gebruiker = managerDao.getGebruiker (principal.getName ());
final GebruikersRol rol = managerDao.getGebruikersRollenByGebruiker (gebruiker).get (0);
final Set<BronhouderThema> authorizedThemas = new HashSet<BronhouderThema> ();
final BronhouderThema bronhouderThema = managerDao.getBronhouderThema (bronhouder, thema);

if (!Rol.BEHEERDER.equals (rol.getRol ()) && !managerDao.isUserAuthorizedForBronhouder (bronhouder, principal.getName ())) {
for (final GebruikerThemaAutorisatie gta: managerDao.getGebruikerThemaAutorisatie (gebruiker)) {
authorizedThemas.add (gta.getBronhouderThema ());
}

if (!gebruiker.isSuperuser () && (bronhouderThema == null || !authorizedThemas.contains (bronhouderThema))) {
throw new UnauthorizedException (String.format ("Not authorized for dataset %d", datasetId));
}

Expand Down Expand Up @@ -263,6 +269,7 @@ public AttributeDescriptorsResponse getAttributes (final @ModelAttribute("datase
}

@RequestMapping (value = "/mapping", method = RequestMethod.GET, produces = "application/json")
@Transactional
@ResponseBody
public Mappings getAllMappings (final @ModelAttribute("dataset") Dataset dataset) throws ThemeNotFoundException, HarvesterException {
final Set<AttributeDescriptor<?>> attributeDescriptors = getAttributeDescriptors (themeDiscoverer, dataset);
Expand Down Expand Up @@ -305,9 +312,8 @@ public Mapping postMapping (final @ModelAttribute("dataset") Dataset dataset, fi
final OperationDTO operationTree = makeOperationTree (operationDiscoverer, conversionService, dataset, attributeDescriptor, featureType, reader);

// Determine whether the mapping is valid:
final OperationDTO rootOperation = (OperationDTO)operationTree.getInputs ().get (0).getOperation ();
final AttributeMappingValidator validator = new AttributeMappingValidator (attributeDescriptor, featureType, new AttributeMappingValidatorLogger ());
final boolean isValid = validator.isValid (new ValidateJob (), rootOperation);
final OperationDTO rootOperation = (OperationDTO) operationTree.getInputs().get(0).getOperation();
final boolean isValid = AttributeMappingUtils.isMappingValid(rootOperation, attributeDescriptor, featureType);

// Save the mapping:
final AttributeMappingDao dao = new AttributeMappingDao (managerDao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package nl.ipo.cds.admin.ba.controller;

import java.security.Principal;
import java.util.Collections;

import javax.validation.Valid;

Expand Down Expand Up @@ -35,10 +36,12 @@ public class BAIndexController {
@RequestMapping
public String index () {
AuthzImpl authz = new AuthzImpl();
if (authz.anyGranted("ROLE_BEHEERDER")){
if (authz.anyGranted("ROLE_SUPERUSER")){
return "redirect:/ba/monitoring";
}else{
} else if (authz.anyGranted("ROLE_RAADPLEGER")) {
return "redirect:/ba/etloverzicht";
}else{
return "redirect:/no-access";
}
}

Expand Down Expand Up @@ -98,9 +101,24 @@ public String changePasswordSubmit (@Valid ChangePasswordForm changePasswordForm
return "redirect:/";
}




/**
* Displays a view for users that have insufficient permissions to manage any data
* in the admin.
*
* @return The view name.
*/
@RequestMapping ("/no-access")
public String raadpleger (final Principal principal, final Model model) {
final Gebruiker gebruiker = managerDao.getGebruiker (principal.getName ());

if (gebruiker != null) {
model.addAttribute ("gebruikerThemas", managerDao.getGebruikerThemaAutorisatie (gebruiker));
} else {
model.addAttribute ("gebruikerThemas", Collections.emptyList ());
}

return "no-access";
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nl.ipo.cds.admin.ba.controller;

import nl.ipo.cds.domain.Dataset;
import nl.ipo.cds.domain.RefreshPolicy;

public class BronhouderDataset {

Expand All @@ -9,6 +10,7 @@ public class BronhouderDataset {
private String naam = "";
private boolean actief = false;
private String uuid;
private RefreshPolicy refreshPolicy;

private final int validAttributeMappings;
private final int totalAttributeMappings;
Expand All @@ -19,12 +21,13 @@ public BronhouderDataset() {
}

public BronhouderDataset(Dataset dataset, int validAttributeMappings, int totalAttributeMappings){

this.id = dataset.getId();
this.type = dataset.getDatasetType().getNaam();
this.naam = dataset.getNaam();
this.uuid = dataset.getUuid();
this.actief = dataset.getActief();

this.refreshPolicy = dataset.getRefreshPolicy(); //W1502 019
this.validAttributeMappings = validAttributeMappings;
this.totalAttributeMappings = totalAttributeMappings;
}
Expand Down Expand Up @@ -76,4 +79,14 @@ public boolean isActief() {
public void setActief(boolean actief) {
this.actief = actief;
}

//W1502 019

public void setRefreshPolicy(RefreshPolicy refreshPolicy){
this.refreshPolicy = refreshPolicy;
}

public RefreshPolicy getRefreshPolicy(){
return refreshPolicy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public void setEmailadres(String emailadres) {
this.bronhouder.setContactEmailadres(emailadres);
}

public String getExtraemailadres() {
return this.bronhouder.getContactExtraEmailadres();
}

public void setExtraemailadres(String emailadres) {
this.bronhouder.setContactExtraEmailadres(emailadres);
}

public Bronhouder getBronhouder() {
return bronhouder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
package nl.ipo.cds.admin.ba.controller;

import java.security.Principal;
import java.util.List;

import nl.ipo.cds.admin.ba.util.GebruikerAuthorization;
import nl.ipo.cds.dao.ManagerDao;
import nl.ipo.cds.domain.Bronhouder;
import nl.ipo.cds.domain.Thema;
import nl.ipo.cds.domain.TypeGebruik;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
Expand All @@ -29,42 +33,53 @@ public class BronhouderRedirectController {

@RequestMapping(value ="/ba/naw", method = RequestMethod.GET)
public String determineNAWBronhouder(Principal principal) {
Bronhouder bronhouder = managerDao.getFirstAuthorizedBronhouder(principal.getName());
final Bronhouder bronhouder = new GebruikerAuthorization (managerDao.getGebruiker (principal.getName ()), TypeGebruik.DATABEHEERDER, managerDao)
.getAuthorizedBronhouder (null);

// User is not bronhouder of any 'provincie'
//TODO:MES: If this happens the views will break, because they expect a bronhouder to be available in the model
if (bronhouder == null){
throw new IllegalStateException("User is not a bronhouder");
throw new IllegalStateException("No bronhouder");
}

return "redirect:/ba/naw/" + bronhouder.getId();
}

@RequestMapping(value ="/ba/datasetconfig", method = RequestMethod.GET)
public String determineDatasetBronhouder(Principal principal) {
Bronhouder bronhouder = managerDao.getFirstAuthorizedBronhouder(principal.getName());
final Bronhouder bronhouder = new GebruikerAuthorization (managerDao.getGebruiker (principal.getName ()), TypeGebruik.DATABEHEERDER, managerDao)
.getAuthorizedBronhouder (null);

// User is not bronhouder of any 'provincie'
//TODO:MES: If this happens the views will break, because they expect a bronhouder to be available in the model
if (bronhouder == null){
throw new IllegalStateException("User is not a bronhouder");
throw new IllegalStateException("No bronhouder");
}

return "redirect:/ba/datasetconfig/" + bronhouder.getId();
}

@RequestMapping(value ="/ba/validation", method = RequestMethod.GET)
public String determineValidationBronhouder(Principal principal) {
Bronhouder bronhouder = managerDao.getFirstAuthorizedBronhouder(principal.getName());
final Bronhouder bronhouder = new GebruikerAuthorization (managerDao.getGebruiker (principal.getName ()), TypeGebruik.DATABEHEERDER, managerDao)
.getAuthorizedBronhouder (null);

// User is not bronhouder of any 'provincie'
//TODO:MES: If this happens the views will break, because they expect a bronhouder to be available in the model
if (bronhouder == null){
throw new IllegalStateException("User is not a bronhouder");
throw new IllegalStateException("No bronhouder");
}

return "redirect:/ba/validation/" + bronhouder.getId();
}

@RequestMapping(value ="/ba/emailteksten", method = RequestMethod.GET)
public String determineThemas(Principal principal) {
List<Thema> themas = managerDao.getAllThemas ();

if (themas.size() == 0){
throw new IllegalStateException("No Themas");
}
return "redirect:/ba/emailteksten/" + themas.get(0).getId();
}
}
Loading

0 comments on commit aa22026

Please sign in to comment.