geomajas-commits Mailing List for Geomajas (Page 878)
Brought to you by:
piedere,
triathlon98
You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(188) |
Sep
(327) |
Oct
(169) |
Nov
(259) |
Dec
(244) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(251) |
Feb
(340) |
Mar
(370) |
Apr
(258) |
May
(184) |
Jun
(523) |
Jul
(655) |
Aug
(280) |
Sep
(434) |
Oct
(318) |
Nov
(196) |
Dec
(482) |
| 2011 |
Jan
(1121) |
Feb
(324) |
Mar
(613) |
Apr
(265) |
May
(320) |
Jun
(443) |
Jul
(193) |
Aug
(530) |
Sep
(840) |
Oct
(495) |
Nov
(348) |
Dec
(626) |
| 2012 |
Jan
(1065) |
Feb
(538) |
Mar
(293) |
Apr
(287) |
May
(375) |
Jun
(452) |
Jul
(376) |
Aug
(140) |
Sep
(322) |
Oct
(232) |
Nov
(136) |
Dec
(211) |
| 2013 |
Jan
(534) |
Feb
(442) |
Mar
(560) |
Apr
(277) |
May
(426) |
Jun
(468) |
Jul
(800) |
Aug
(324) |
Sep
(284) |
Oct
(386) |
Nov
(374) |
Dec
(215) |
| 2014 |
Jan
(236) |
Feb
(66) |
Mar
|
Apr
(21) |
May
(31) |
Jun
(40) |
Jul
(340) |
Aug
(41) |
Sep
(3) |
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
(14) |
Mar
|
Apr
(1) |
May
(2) |
Jun
(10) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
(13) |
May
|
Jun
(3) |
Jul
(5) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <sv...@ge...> - 2009-08-19 08:51:46
|
Author: kristofh
Date: 2009-08-19 09:52:01 +0200 (Wed, 19 Aug 2009)
New Revision: 3745
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/layermodels/hibernate/HibernateLayerModel.java
Log:
fgem + refgem gewijzigd naar hibernatelayers om extra (formule)veld te kunnen toevoegen. Filteren like werkt niet (overal) met wildcards.
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/layermodels/hibernate/HibernateLayerModel.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/layermodels/hibernate/HibernateLayerModel.java 2009-08-19 07:51:59 UTC (rev 3744)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/layermodels/hibernate/HibernateLayerModel.java 2009-08-19 07:52:01 UTC (rev 3745)
@@ -181,10 +181,13 @@
* @return the bounds of the specified features
*/
public Envelope getBounds(Filter filter) throws IOException {
- Envelope bounds = getBoundsDb(filter);
- if (bounds == null)
- bounds = getBoundsLocal(filter);
- return bounds;
+// Envelope bounds = getBoundsDb(filter);
+// if (bounds == null)
+// bounds = getBoundsLocal(filter);
+// return bounds;
+
+ // TODO getBoundsDb kan niet overweg met hibernate Formula fields
+ return getBoundsLocal(filter);
}
/**
|
|
From: <sv...@ge...> - 2009-08-19 08:51:42
|
Author: joachimvda Date: 2009-08-19 09:51:59 +0200 (Wed, 19 Aug 2009) New Revision: 3744 Added: branches/1.5.x/geomajas/geomajas-dojo-client/ Removed: branches/1.5.x/geomajas/modules/geomajas-dojo/ Log: MAJ-386 change module/directory structure Property changes on: branches/1.5.x/geomajas/geomajas-dojo-client ___________________________________________________________________ Added: svn:ignore + .classpath .project .settings target bin Added: svn:mergeinfo + |
|
From: <sv...@ge...> - 2009-08-19 08:48:55
|
Author: joachimvda Date: 2009-08-19 09:49:08 +0200 (Wed, 19 Aug 2009) New Revision: 3743 Added: branches/1.5.x/geomajas/geomajas-impl/ Removed: branches/1.5.x/geomajas/modules/geomajas-core/ Log: MAJ-386 change module/directory structure Property changes on: branches/1.5.x/geomajas/geomajas-impl ___________________________________________________________________ Added: svn:ignore + target .project .settings .classpath build bin Added: svn:mergeinfo + |
|
From: <sv...@ge...> - 2009-08-18 14:14:35
|
Author: pieterdg
Date: 2009-08-18 15:14:42 +0200 (Tue, 18 Aug 2009)
New Revision: 3742
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/RetrieveImageServlet.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/TileCacheService.java
Log:
Added a "useCache" option to the RetrieveImageServlet, that makes it easier to enable/disable the caching system.
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/RetrieveImageServlet.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/RetrieveImageServlet.java 2009-08-17 13:23:56 UTC (rev 3741)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/RetrieveImageServlet.java 2009-08-18 13:14:42 UTC (rev 3742)
@@ -33,6 +33,8 @@
private static final Log logger = LogFactory.getLog(RetrieveImageServlet.class);
+ private static final String PARAM_USE_CACHE = "useCache";
+
private static final String PARAM_BASE_PATH = "cacheBasePath";
private static final String PARAM_MAXIMUM_SIZE = "cacheMaximumSize";
@@ -57,37 +59,48 @@
String basePath = config.getInitParameter(PARAM_BASE_PATH);
String maximumSize = config.getInitParameter(PARAM_MAXIMUM_SIZE);
+ String useCacheStr = config.getInitParameter(PARAM_USE_CACHE);
+ boolean useCache = false;
+ if (useCacheStr != null && useCacheStr.equalsIgnoreCase("true")) {
+ useCache = true;
+ }
- if (basePath == null) {
- basePath = DEFAULT_CACHE_DIRECTORY;
- File file = new File(config.getServletContext().getRealPath(basePath));
- if (!file.exists()) {
- file.mkdir();
- } else {
- File[] subDirs = file.listFiles();
- for (int i = 0; i < subDirs.length; i++) {
- deleteDirectory(subDirs[i]);
+ if (useCache) {
+ logger.info("Raster image caching enabled.");
+ if (basePath == null) {
+ basePath = DEFAULT_CACHE_DIRECTORY;
+ File file = new File(config.getServletContext().getRealPath(basePath));
+ if (!file.exists()) {
+ file.mkdir();
+ } else {
+ File[] subDirs = file.listFiles();
+ for (int i = 0; i < subDirs.length; i++) {
+ deleteDirectory(subDirs[i]);
+ }
}
}
- }
- File baseDirectory;
- try {
- baseDirectory = CacheUtil.findCacheDirectory(config, basePath);
- } catch (CacheIOException e1) {
+ File baseDirectory;
try {
- logger.error(e1.getMessage());
- baseDirectory = CacheUtil.findCacheDirectory(config, DEFAULT_CACHE_DIRECTORY);
- } catch (CacheIOException e) {
- baseDirectory = null;
+ baseDirectory = CacheUtil.findCacheDirectory(config, basePath);
+ } catch (CacheIOException e1) {
+ try {
+ logger.error(e1.getMessage());
+ baseDirectory = CacheUtil.findCacheDirectory(config, DEFAULT_CACHE_DIRECTORY);
+ } catch (CacheIOException e) {
+ baseDirectory = null;
+ }
}
- }
- int max = 0;
- try {
- max = Integer.parseInt(maximumSize);
- service = new TileCacheService(baseDirectory, max);
- } catch (Exception e) {
- service = new TileCacheService(baseDirectory);
+ int max = 0;
+ try {
+ max = Integer.parseInt(maximumSize);
+ service = new TileCacheService(baseDirectory, max);
+ } catch (Exception e) {
+ service = new TileCacheService(baseDirectory);
+ }
+ } else {
+ logger.info("Raster image caching disabled.");
+ service = new TileCacheService(false);
}
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/TileCacheService.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/TileCacheService.java 2009-08-17 13:23:56 UTC (rev 3741)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/TileCacheService.java 2009-08-18 13:14:42 UTC (rev 3742)
@@ -59,6 +59,14 @@
* This constructor initializes the service object with a certain base path
* to store the cache's files.
*/
+ public TileCacheService(boolean useCache) {
+ realTime = new RealTimeBroker();
+ }
+
+ /**
+ * This constructor initializes the service object with a certain base path
+ * to store the cache's files.
+ */
public TileCacheService(File baseDirectory) {
this(baseDirectory, 0);
}
|
|
From: <sv...@ge...> - 2009-08-17 14:23:45
|
Author: kristofh
Date: 2009-08-17 15:23:56 +0200 (Mon, 17 Aug 2009)
New Revision: 3741
Added:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/CQLFilterUtils.java
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/filters/ExtendedLikeFilterImpl.java
Log:
filters tostring / tofilter gehacked
- policyfile aangepast voor correct filteren
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java 2009-08-17 09:07:15 UTC (rev 3740)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java 2009-08-17 13:23:56 UTC (rev 3741)
@@ -32,8 +32,8 @@
import org.geomajas.core.aaa.policy.Resource;
import org.geomajas.core.aaa.policy.SecurityManager;
import org.geomajas.core.filters.FilterCreator;
-import org.geomajas.core.filters.cql.CQL;
import org.geomajas.core.filters.cql.CQLException;
+import org.geomajas.core.util.CQLFilterUtils;
import org.geomajas.core.util.StringUtils;
/**
@@ -83,9 +83,9 @@
securityFilter = StringUtils.substituteParameters(pr.filter, userContext.getUser()
.getRoleProperties());
if (fltr != null) {
- securityFilter = FilterCreator.createLogicFilter(CQL.toFilter(fltr), "and",
- CQL.toFilter(securityFilter)).toString();
- logger.debug("FilterString: " + fltr);
+ securityFilter = CQLFilterUtils.toString(FilterCreator.createLogicFilter(CQLFilterUtils.toFilter(fltr), "and",
+ CQLFilterUtils.toFilter(securityFilter)));
+ logger.debug("FilterString: " + securityFilter);
}
setFilter(securityFilter);
} catch (IllegalArgumentException iae) {
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/filters/ExtendedLikeFilterImpl.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/filters/ExtendedLikeFilterImpl.java 2009-08-17 09:07:15 UTC (rev 3740)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/filters/ExtendedLikeFilterImpl.java 2009-08-17 13:23:56 UTC (rev 3741)
@@ -423,7 +423,8 @@
* @return String representation of this like filter.
*/
public String toString() {
- return "[ " + attribute.toString() + " is like " + pattern + " ]";
+ // TODO test if change affects anything else
+ return "[ " + attribute.toString() + " like '" + pattern + "' ]";
}
/**
Added: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/CQLFilterUtils.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/CQLFilterUtils.java (rev 0)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/CQLFilterUtils.java 2009-08-17 13:23:56 UTC (rev 3741)
@@ -0,0 +1,26 @@
+package org.geomajas.core.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.geomajas.core.filters.cql.CQL;
+import org.geomajas.core.filters.cql.CQLException;
+import org.opengis.filter.Filter;
+
+public class CQLFilterUtils {
+
+ private static final Log logger = LogFactory.getLog(CQLFilterUtils.class);
+
+ private static final String p = "\\[|\\]";
+
+ public static final String toString(Filter filter) {
+ String value = filter.toString();
+ value = value.replaceAll(p, "");
+ return value;
+ }
+
+ public static final Filter toFilter(String expression) throws CQLException {
+ if (expression != null && expression.startsWith("[") && expression.endsWith("]"))
+ expression = expression.substring(1, expression.length() - 1);
+ return CQL.toFilter(expression);
+ }
+}
|
|
From: <sv...@ge...> - 2009-08-17 10:07:02
|
Author: pieterdg
Date: 2009-08-17 11:07:15 +0200 (Mon, 17 Aug 2009)
New Revision: 3740
Added:
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/images/export.gif
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/images/import_xml.gif
Modified:
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/default_icons.css
Log:
Added a few icons to the default icons list.
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/default_icons.css
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/default_icons.css 2009-08-17 08:55:03 UTC (rev 3739)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/default_icons.css 2009-08-17 09:07:15 UTC (rev 3740)
@@ -108,3 +108,19 @@
height: 18px;
text-align: center;
}
+
+.importIcon {
+ background-image: url('images/import_xml.gif');
+ background-repeat: no-repeat;
+ width: 18px;
+ height: 18px;
+ text-align: center;
+}
+
+.exportIcon {
+ background-image: url('images/export.gif');
+ background-repeat: no-repeat;
+ width: 18px;
+ height: 18px;
+ text-align: center;
+}
Added: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/images/export.gif
===================================================================
(Binary files differ)
Property changes on: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/images/export.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/images/import_xml.gif
===================================================================
(Binary files differ)
Property changes on: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/themes/images/import_xml.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
|
|
From: <sv...@ge...> - 2009-08-17 09:54:52
|
Author: kristofh
Date: 2009-08-17 10:55:03 +0200 (Mon, 17 Aug 2009)
New Revision: 3739
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java
Log:
aanpassing login zoals ROP, oplossen RWOPB 88 / 94 / 96
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java 2009-08-14 13:33:05 UTC (rev 3738)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java 2009-08-17 08:55:03 UTC (rev 3739)
@@ -41,12 +41,12 @@
return true;
} else {
return setErrorResult(
- "Beveiligingsfout: Aanvraag komt vanuit een andere dan de aangemelde applicatie.",
+ "Beveiligingsfout: Niet aangemeld. Aanvraag komt vanuit een andere dan de aangemelde applicatie.",
"Wrong application request, user is not logged into requesting app.");
}
} else {
return setErrorResult(
- "Beveiligingsfout: U dient aangemeld te zijn om deze opdracht uit te voeren! ("
+ "Beveiligingsfout: Niet aangemeld. U dient aangemeld te zijn om deze opdracht uit te voeren! ("
+ this.getClass().getSimpleName() + ")",
"SecurityException. Insufficient rights to execute request (not logged in). ("
+ this.getClass().getSimpleName() + ")");
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java 2009-08-14 13:33:05 UTC (rev 3738)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java 2009-08-17 08:55:03 UTC (rev 3739)
@@ -30,7 +30,6 @@
import org.geomajas.core.aaa.User;
import org.geomajas.core.aaa.UserContextManager;
import org.geomajas.core.aaa.policy.SecurityManager;
-import org.geomajas.core.global.MajasConstants;
public class UserLoginCommand extends AbstractApplicationCommand {
@@ -99,6 +98,9 @@
userContext.setUser(getUCM().getGuest(application.getUrl()));
userContext.setAuthenticated(true);
}
+ if (userContext.isAuthenticated() && !userContext.getUser().isInApplication(application.getUrl())) {
+ res.setWrongApplication(true);
+ }
} catch (IOException e) {
log.error("Could not count users", e);
}
@@ -172,16 +174,7 @@
}
public boolean checkSecurity(SecurityManager sm) {
- // do not allow requests from other applications
- if (userContext.isAuthenticated() && userContext.getUser().getActiveProfile() != null) {
- String userAppName = userContext.getUser().getApplicationName();
- if (!MajasConstants.GLOB.equals(userAppName) && !userAppName.equals(application.getUrl())) {
- result = new ApplicationResult();
- result
- .addErrorMessage("U bent reeds aangemeld in een ander loket. Gelieve eerst uit te loggen vooraleer een ander loket te openen.");
- return false;
- }
- }
+ // can't return false here or you wopn't ba able to log in...
return true;
}
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java 2009-08-14 13:33:05 UTC (rev 3738)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java 2009-08-17 08:55:03 UTC (rev 3739)
@@ -31,6 +31,8 @@
private String[] profileNames;
+ private boolean wrongApplication = false;
+
private boolean canLogout = true;
// ------------------------------------------------------------------------
@@ -66,4 +68,12 @@
public void setProfileNames(String[] profileNames) {
this.profileNames = profileNames;
}
+
+ public boolean isWrongApplication() {
+ return wrongApplication;
+ }
+
+ public void setWrongApplication(boolean wrongApplication) {
+ this.wrongApplication = wrongApplication;
+ }
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java 2009-08-14 13:33:05 UTC (rev 3738)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java 2009-08-17 08:55:03 UTC (rev 3739)
@@ -63,6 +63,11 @@
setRoleName(roleName);
setApplicationName(applicationName);
}
+
+ public Profile(String profileName, String roleName, String applicationName, Map<String, String> properties) {
+ this(profileName, roleName, applicationName);
+ this.properties = properties;
+ }
// ---------------------------------------------------------
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java 2009-08-14 13:33:05 UTC (rev 3738)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java 2009-08-17 08:55:03 UTC (rev 3739)
@@ -94,7 +94,7 @@
if (activeProfile == null)
return false;
String userAppName = activeProfile.getApplicationName();
- return (MajasConstants.GLOB.equals(userAppName) || applicationName.equals(userAppName));
+ return (applicationName.equals(userAppName));
}
public String[] getProfileNames(String applicationName) {
@@ -139,7 +139,8 @@
if (pr.getProfileName().equals(profileName)
&& (MajasConstants.GLOB.equals(pr.getApplicationName()) || pr.getApplicationName()
.equals(applicationName)))
- activeProfile = pr;
+ activeProfile = new Profile(pr.getProfileName(), pr.getRoleName(), applicationName, pr
+ .getRoleProperties());
}
if (activeProfile == null)
throw new IllegalArgumentException("No profile with name: " + profileName);
|
|
From: <sv...@ge...> - 2009-08-14 14:32:52
|
Author: kristofh
Date: 2009-08-14 15:33:05 +0200 (Fri, 14 Aug 2009)
New Revision: 3738
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/broker/RealTimeBroker.java
Log:
userlogin-- ook checken op applicatie ok.
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/broker/RealTimeBroker.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/broker/RealTimeBroker.java 2009-08-14 13:26:53 UTC (rev 3737)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/broker/RealTimeBroker.java 2009-08-14 13:33:05 UTC (rev 3738)
@@ -105,15 +105,14 @@
// 3: Check security:
UserContext uc = renderContent.getUserContext();
- if (uc == null || !uc.isAuthenticated()) {
- return false;
- }
SecurityInterceptor secInt = null;
for (CommandInterceptor ci : app.getCommandInterceptors()) {
if (ci instanceof SecurityInterceptor)
secInt = (SecurityInterceptor) ci;
}
if (secInt != null) {
+ if (uc == null || !uc.isAuthenticated() || !uc.getUser().isInApplication(app.getUrl()))
+ return false;
SecurityManager sm = secInt.getSecurityManager();
PermissionResult pr = sm.checkPermission(uc, EnumSet.of(OperationType.READ),
new Resource(layerId), app.getUrl());
|
Author: kristofh
Date: 2009-08-14 15:26:53 +0200 (Fri, 14 Aug 2009)
New Revision: 3737
Added:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Profile.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/xml/Role.java
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/aaa/ProfileTest.java
Removed:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Role.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Role.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/xml/Role.java
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/aaa/RoleTest.java
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractApplicationCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractRoleSecurityApplicationCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetFeatureByCoordinateCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserMaximumExtentCommand.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/interceptor/UserContextInterceptor.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/User.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContext.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextImpl.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextManager.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/PolicyRule.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/HibernateUserContextManager.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/xml/SecurityManager.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/xml/User.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/cache/broker/RealTimeBroker.java
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/global/GGISJSONServlet.java
branches/1.3.x_planbaten/majas-core/src/main/resources/corehibernate.cfg.xml
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/aaa/UserTest.java
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/aaa/policy/PolicyRuleTest.java
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/aaa/policy/hibernate/UserTest.java
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/aaa/policy/xml/SecurityManagerTest.java
Log:
login met profielen.
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractApplicationCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractApplicationCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractApplicationCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -152,8 +152,11 @@
if (t == null)
return;
else {
- if (t.getCause() != null)
+ if (t.getCause() != null) {
+ if (t.getCause().getCause() != null)
+ result.addErrorMessage(t.getCause().getCause().getMessage());
result.addErrorMessage(t.getCause().getMessage());
+ }
result.addErrorMessage(t.getMessage());
}
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractBasicSecurityApplicationCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -29,23 +29,35 @@
/**
* Extends AbstractApplicationCommand with basic security (User must be logged
- * in to be able to execute this command).
+ * in (& profile set) to be able to execute this command).
*/
public abstract class AbstractBasicSecurityApplicationCommand extends AbstractApplicationCommand {
private static final Log logger = LogFactory.getLog(AbstractBasicSecurityApplicationCommand.class);
public boolean checkSecurity(SecurityManager sm) {
- if (getUserContext().isAuthenticated()) {
- return true;
+ if (getUserContext().isAuthenticated() && getUserContext().getUser() != null) {
+ if (getUserContext().getUser().isInApplication(application.getUrl())) {
+ return true;
+ } else {
+ return setErrorResult(
+ "Beveiligingsfout: Aanvraag komt vanuit een andere dan de aangemelde applicatie.",
+ "Wrong application request, user is not logged into requesting app.");
+ }
} else {
- result = new ApplicationResult();
- result
- .addErrorMessage("Beveiligingsfout: U dient aangemeld te zijn om deze opdracht uit te voeren! ("
+ return setErrorResult(
+ "Beveiligingsfout: U dient aangemeld te zijn om deze opdracht uit te voeren! ("
+ + this.getClass().getSimpleName() + ")",
+ "SecurityException. Insufficient rights to execute request (not logged in). ("
+ this.getClass().getSimpleName() + ")");
- logger.info("SecurityException. Insufficient rights to execute request (not logged in). ("
- + this.getClass().getSimpleName() + ")");
- return false;
}
}
+
+ protected boolean setErrorResult(String message, String logmessage) {
+ result = new ApplicationResult();
+ result.addErrorMessage(message);
+ if (logmessage != null)
+ logger.warn(logmessage);
+ return false;
+ }
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractDataFilterSecurityApplicationCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -40,7 +40,8 @@
* Extends AbstractApplicationCommand with basic role security (User must have a
* certain role to be able to execute this command).
*/
-public abstract class AbstractDataFilterSecurityApplicationCommand extends AbstractApplicationCommand {
+public abstract class AbstractDataFilterSecurityApplicationCommand extends
+ AbstractBasicSecurityApplicationCommand {
private static final Log logger = LogFactory.getLog(AbstractDataFilterSecurityApplicationCommand.class);
@@ -68,55 +69,50 @@
logger.debug("Checking security: user: "
+ (userContext.getUser() == null ? "null" : userContext.getUser().getUserName()) + " - "
+ getRequiredOperations() + " - " + getLayer() + " - " + application.getUrl());
- if (getUserContext().isAuthenticated()) {
- PermissionResult pr = sm.checkPermission(userContext, getRequiredOperations(), new Resource(
- getLayer()), application.getUrl());
- if (pr.allowed) {
- if (pr.filter != null) {
- // security ok, but need to add a filter
- String fltr = getFilter();
- String securityFilter;
- try {
- securityFilter = StringUtils.substituteParameters(pr.filter, userContext.getUser()
- .getParameters(application.getUrl()));
- if (fltr != null) {
- securityFilter = FilterCreator.createLogicFilter(CQL.toFilter(fltr), "and",
- CQL.toFilter(securityFilter)).toString();
- logger.debug("FilterString: " + fltr);
- }
- setFilter(securityFilter);
- } catch (IllegalArgumentException iae) {
- logger.warn("Failed parsing filter, user does not have a required property: "
- + iae.getMessage());
- result = getEmptyResult();
- result.addErrorMessage("Fout bij filteren! (Userproperty niet ingesteld: "
- + iae.getMessage() + ")");
- return false;
- } catch (CQLException e) {
- logger.warn("Failed parsing filter", e);
- result = getEmptyResult();
- result
- .addErrorMessage("Fout bij filteren! (" + this.getClass().getSimpleName()
- + ")");
- return false;
+ if (!super.checkSecurity(sm))
+ return false;
+
+ PermissionResult pr = sm.checkPermission(userContext, getRequiredOperations(), new Resource(
+ getLayer()), application.getUrl());
+ if (pr.allowed) {
+ if (pr.filter != null) {
+ // security ok, but need to add a filter
+ String fltr = getFilter();
+ String securityFilter;
+ try {
+ securityFilter = StringUtils.substituteParameters(pr.filter, userContext.getUser()
+ .getRoleProperties());
+ if (fltr != null) {
+ securityFilter = FilterCreator.createLogicFilter(CQL.toFilter(fltr), "and",
+ CQL.toFilter(securityFilter)).toString();
+ logger.debug("FilterString: " + fltr);
}
+ setFilter(securityFilter);
+ } catch (IllegalArgumentException iae) {
+ return setErrorResult("Fout bij filteren! (filterparameter niet ingesteld: "
+ + iae.getMessage() + ")",
+ "Failed parsing filter, user does not have a required property: "
+ + iae.getMessage());
+ } catch (CQLException e) {
+ return setErrorResult("Fout bij filteren! (" + this.getClass().getSimpleName() + ")",
+ "Failed parsing filter: " + e.getMessage());
}
- return true;
- } else {
- result = getEmptyResult();
- logger.info("SecurityException. user: " + userContext.getUser().getUserName()
- + " has insufficient rights to execute request. (" + this.getClass().getSimpleName()
- + ")");
- return false;
}
+ return true;
} else {
- result = getEmptyResult();
- result
- .addErrorMessage("Beveiligingsfout: U dient aangemeld te zijn om deze opdracht uit te voeren! ("
- + this.getClass().getSimpleName() + ")");
- logger.info("SecurityException. Insufficient rights to execute request (not logged in). ("
+ return setErrorResult("Beveiligingsfout: Gebruiker: " + userContext.getUser().getUserName()
+ + " heeft niet voldoende rechten om deze aanvraag uit te voeren ("
+ + this.getClass().getSimpleName() + ")", "SecurityException. user: "
+ + userContext.getUser().getUserName() + " has insufficient rights to execute request. ("
+ this.getClass().getSimpleName() + ")");
- return false;
}
}
+
+ protected boolean setErrorResult(String message, String logmessage) {
+ result = getEmptyResult();
+ result.addErrorMessage(message);
+ if (logmessage != null)
+ logger.warn(logmessage);
+ return false;
+ }
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractRoleSecurityApplicationCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractRoleSecurityApplicationCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/AbstractRoleSecurityApplicationCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -23,45 +23,31 @@
*/
package org.geomajas.command;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.geomajas.core.aaa.policy.SecurityManager;
/**
* Extends AbstractApplicationCommand with basic role security (User must have a
* certain role to be able to execute this command).
*/
-public abstract class AbstractRoleSecurityApplicationCommand extends AbstractApplicationCommand {
+public abstract class AbstractRoleSecurityApplicationCommand extends AbstractBasicSecurityApplicationCommand {
- private static final Log logger = LogFactory.getLog(AbstractRoleSecurityApplicationCommand.class);
-
/**
* @return The role required to execute this command
*/
abstract String getRequiredRole();
public boolean checkSecurity(SecurityManager sm) {
- if (getUserContext().isAuthenticated()) {
- if (getUserContext().isUserInRole(getRequiredRole(), application.getUrl())) {
- return true;
- } else {
- result = new ApplicationResult();
- result
- .addErrorMessage("Beveiligingsfout: U beschikt niet over voldoende rechten om deze opdracht uit te voeren! ("
- + this.getClass().getSimpleName() + ")");
- logger.info("SecurityException. user: " + userContext.getUser().getUserName()
- + " has insufficient rights to execute request. (" + this.getClass().getSimpleName()
- + ")");
- return false;
- }
+ if (!super.checkSecurity(sm))
+ return false;
+
+ if (getUserContext().isUserInRole(getRequiredRole())) {
+ return true;
} else {
- result = new ApplicationResult();
- result
- .addErrorMessage("Beveiligingsfout: U dient aangemeld te zijn om deze opdracht uit te voeren! ("
- + this.getClass().getSimpleName() + ")");
- logger.info("SecurityException. Insufficient rights to execute request (not logged in). ("
+ return setErrorResult("Beveiligingsfout: Gebruiker: " + userContext.getUser().getUserName()
+ + " heeft niet voldoende rechten om deze aanvraag uit te voeren ("
+ + this.getClass().getSimpleName() + ")", "SecurityException. user: "
+ + userContext.getUser().getUserName() + " has insufficient rights to execute request. ("
+ this.getClass().getSimpleName() + ")");
- return false;
}
}
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetFeatureByCoordinateCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetFeatureByCoordinateCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetFeatureByCoordinateCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -31,7 +31,7 @@
*
* @author Pieter De Graef
*/
-public class GetFeatureByCoordinateCommand extends AbstractApplicationCommand {
+public class GetFeatureByCoordinateCommand extends AbstractBasicSecurityApplicationCommand {
private static final Log logger = LogFactory.getLog(GetFeatureByCoordinateCommand.class);
@@ -120,6 +120,9 @@
}
public boolean checkSecurity(SecurityManager sm) {
+ if (!super.checkSecurity(sm))
+ return false;
+
if (layerIds == null || layerIds.length == 0)
return true;
@@ -132,13 +135,13 @@
// filter
try {
String securityFilter = StringUtils.substituteParameters(pr.filter, userContext
- .getUser().getParameters(application.getUrl()));
+ .getUser().getRoleProperties());
filters[i] = CQL.toFilter(securityFilter);
logger.debug("FilterString: " + filters[i].toString());
} catch (CQLException e) {
logger.warn("Failed parsing filter", e);
result = new ApplicationResult();
- result.addErrorMessage("Fout bij filteren! (RetrieveFeaturesCommand)");
+ result.addErrorMessage("Fout bij filteren! (GetFeatureByCoordinateCommand)");
return false;
}
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -24,13 +24,13 @@
package org.geomajas.command;
import java.io.IOException;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.geomajas.core.aaa.User;
import org.geomajas.core.aaa.UserContextManager;
import org.geomajas.core.aaa.policy.SecurityManager;
+import org.geomajas.core.global.MajasConstants;
public class UserLoginCommand extends AbstractApplicationCommand {
@@ -40,13 +40,15 @@
private static final String LOGIN_ACTION = "LOGIN";
+ private static final String CHANGE_PROFILE = "PROFILE";
+
private static final String LOGOUT_ACTION = "LOGOUT";
private static UserContextManager ucm;
private String action;
- private String organisation;
+ private String profileName;
private String loginId;
@@ -68,10 +70,6 @@
this.password = password;
}
- public boolean checkSecurity(SecurityManager sm) {
- return true; // don't check now
- }
-
public String getAction() {
return action;
}
@@ -80,12 +78,12 @@
this.action = action;
}
- public String getOrganisation() {
- return organisation;
+ public String getProfileName() {
+ return profileName;
}
- public void setOrganisation(String organisation) {
- this.organisation = organisation;
+ public void setProfileName(String profileName) {
+ this.profileName = profileName;
}
// ------------------------------------------------
@@ -100,9 +98,6 @@
// anonymous login
userContext.setUser(getUCM().getGuest(application.getUrl()));
userContext.setAuthenticated(true);
- } else {
- List<String> orgs = getUCM().getOrganisations();
- res.setOrganisations(orgs.toArray(new String[orgs.size()]));
}
} catch (IOException e) {
log.error("Could not count users", e);
@@ -111,21 +106,44 @@
} else if (LOGIN_ACTION.equals(action)) {
// if either org, name or pw is empty we log out
userContext.clear();
- if (organisation == null || "".equals(organisation) || loginId == null || "".equals(loginId)
- || password == null || "".equals(password)) {
+ if (loginId == null || "".equals(loginId) || password == null || "".equals(password)) {
// logout
} else {
try {
- User u = getUCM().getUser(organisation, loginId, password);
- if (u != null && u.isInApplication(application.getUrl())) {
- userContext.setUser(u);
- userContext.setAuthenticated(true);
+ User u = getUCM().getUser(loginId, password);
+ if (u != null) {
+ String[] prNames = u.getProfileNames(application.getUrl());
+ if (prNames.length > 0) {
+ userContext.setUser(u);
+ userContext.setAuthenticated(true);
+ res.setProfileNames(prNames);
+ if (prNames.length == 1) {
+ u.setActiveProfile(prNames[0], application.getUrl());
+ }
+ } else {
+ // valid user, but no access to this application
+ }
}
} catch (IOException e) {
log.error("Could not get user", e);
}
}
+ } else if (CHANGE_PROFILE.equals(action)) {
+ if (userContext.isAuthenticated() && userContext.getUser() != null) {
+ if (profileName == null || "".equals(profileName)) {
+ res.addErrorMessage("Gelieve een profielnaam op te geven.");
+ } else {
+ try {
+ userContext.getUser().setActiveProfile(profileName, application.getUrl());
+ } catch (IllegalArgumentException e) {
+ res.addErrorMessage(e.getMessage());
+ }
+ }
+ } else {
+ res.addErrorMessage("U dient ingelogd te zijn om uw profiel te wijzigen");
+ }
+
} else if (LOGOUT_ACTION.equals(action)) {
userContext.clear();
}
@@ -133,9 +151,11 @@
res.setAuthenticated(userContext.isAuthenticated());
if (userContext.getUser() != null) {
res.setUserName(userContext.getUser().getUserName());
- String canLogout = userContext.getUser().getParameters().get("canLogout");
- if (canLogout != null)
- res.setCanLogout(Boolean.parseBoolean(canLogout));
+ if (userContext.getUser().getActiveProfile() != null) {
+ String canLogout = userContext.getUser().getRoleProperties().get("canLogout");
+ if (canLogout != null)
+ res.setCanLogout(Boolean.parseBoolean(canLogout));
+ }
}
}
@@ -150,4 +170,18 @@
throw new IllegalStateException("UserContextManager is not set");
return ucm;
}
+
+ public boolean checkSecurity(SecurityManager sm) {
+ // do not allow requests from other applications
+ if (userContext.isAuthenticated() && userContext.getUser().getActiveProfile() != null) {
+ String userAppName = userContext.getUser().getApplicationName();
+ if (!MajasConstants.GLOB.equals(userAppName) && !userAppName.equals(application.getUrl())) {
+ result = new ApplicationResult();
+ result
+ .addErrorMessage("U bent reeds aangemeld in een ander loket. Gelieve eerst uit te loggen vooraleer een ander loket te openen.");
+ return false;
+ }
+ }
+ return true;
+ }
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserLoginResult.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -23,17 +23,18 @@
*/
package org.geomajas.command;
-
public class UserLoginResult extends ApplicationResult {
private boolean authenticated = false;
private String userName = "";
- private String[] organisations;
+ private String[] profileNames;
private boolean canLogout = true;
+ // ------------------------------------------------------------------------
+
public String getUserName() {
return userName;
}
@@ -58,11 +59,11 @@
this.canLogout = canLogout;
}
- public String[] getOrganisations() {
- return organisations;
+ public String[] getProfileNames() {
+ return profileNames;
}
- public void setOrganisations(String[] organisations) {
- this.organisations = organisations;
+ public void setProfileNames(String[] profileNames) {
+ this.profileNames = profileNames;
}
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserMaximumExtentCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserMaximumExtentCommand.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/UserMaximumExtentCommand.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -51,7 +51,7 @@
import com.vividsolutions.jts.geom.Envelope;
-public class UserMaximumExtentCommand extends AbstractApplicationCommand {
+public class UserMaximumExtentCommand extends AbstractBasicSecurityApplicationCommand {
private static final Log log = LogFactory.getLog(UserMaximumExtentCommand.class);
@@ -144,7 +144,9 @@
log.info("need to filter: " + filters[i].toString());
if (layer instanceof VectorLayer) {
VectorLayer vLayer = (VectorLayer) layer;
- log.info("getting bounds for layer: " + layer.getId() + " - layermodel: " + vLayer.getLayerModel().getClass().getName());
+ log.info("getting bounds for layer: " + layer.getId()
+ + " - layermodel: "
+ + vLayer.getLayerModel().getClass().getName());
bounds = vLayer.getLayerModel().getBounds(filters[i]);
if (layer.getCRS() != null && !mapCRS.equals(layer.getCRS())) {
log.info(" **** bounds before transforming: " + layers[i]
@@ -183,6 +185,9 @@
* in itself doesn't fail, if we have no readaccess anywhere we fail
*/
public boolean checkSecurity(SecurityManager sm) {
+ if (!super.checkSecurity(sm))
+ return false;
+
if (!init())
return false;
log.info("Checking security with map: " + mapId);
@@ -197,7 +202,7 @@
// security ok, but need to add a filter
try {
String securityFilter = StringUtils.substituteParameters(pr.filter, userContext
- .getUser().getParameters(application.getUrl()));
+ .getUser().getRoleProperties());
filters[i] = CQL.toFilter(securityFilter);
} catch (CQLException e) {
log.warn("Failed parsing filter", e);
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/interceptor/UserContextInterceptor.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/interceptor/UserContextInterceptor.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/interceptor/UserContextInterceptor.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -27,7 +27,7 @@
import org.apache.commons.logging.LogFactory;
import org.geomajas.command.ApplicationCommand;
import org.geomajas.command.CommandInterceptor;
-import org.geomajas.core.aaa.UserContextImpl;
+import org.geomajas.core.aaa.UserContext;
/**
* Interceptor for user context. This is an alternative to passing the user
@@ -40,7 +40,7 @@
private static final Log log = LogFactory.getLog(UserContextInterceptor.class);
- private static final ThreadLocal<UserContextImpl> userContext = new ThreadLocal<UserContextImpl>();
+ private static final ThreadLocal<UserContext> userContext = new ThreadLocal<UserContext>();
public UserContextInterceptor() {
}
@@ -50,7 +50,7 @@
public boolean beforeExecute(ApplicationCommand command) {
log.debug("Putting user context in this thread.");
- UserContextImpl uct = userContext.get();
+ UserContext uct = userContext.get();
if (uct != null) {
command.setUserContext(uct);
return true;
@@ -64,7 +64,7 @@
/**
* used at the start of a new httprequest
*/
- public static void setUserContext(UserContextImpl uc) {
+ public static void setUserContext(UserContext uc) {
userContext.set(uc);
}
}
Copied: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Profile.java (from rev 3675, branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Role.java)
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Profile.java (rev 0)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Profile.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -0,0 +1,76 @@
+/**
+ * This software project is called Geomajas, a component framework for building
+ * rich Internet applications (RIA) with sophisticated capabilities for the
+ * display, analysis and management of geographic information.
+ * It is a building block that allows developers to add maps
+ * and other geographic data capabilities to their web applications.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Copyright 2009 Geosparc, http://www.geosparc.com, Belgium
+ * This file is part of Geomajas.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.geomajas.core.aaa;
+
+import java.util.Map;
+
+public abstract class Profile {
+
+ public abstract String getProfileName();
+
+ public abstract String getRoleName();
+
+ public abstract String getApplicationName();
+
+ public abstract Map<String, String> getRoleProperties();
+
+ // -------------------------------------------------
+
+ /**
+ * custom implementation as there might be different implementations, but
+ * all conceptually same Profiles should be equal
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode());
+ result = prime * result + ((getRoleName() == null) ? 0 : getRoleName().hashCode());
+ return result;
+ }
+
+ /**
+ * custom implementation as there might be different implementations, but
+ * all conceptually same Profiles should be equal
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ org.geomajas.core.aaa.Profile other = (org.geomajas.core.aaa.Profile) obj;
+ if (getApplicationName() == null) {
+ if (other.getApplicationName() != null)
+ return false;
+ } else if (!getApplicationName().equals(other.getApplicationName()))
+ return false;
+ if (getRoleName() == null) {
+ if (other.getRoleName() != null)
+ return false;
+ } else if (!getRoleName().equals(other.getRoleName()))
+ return false;
+ return true;
+ }
+}
Deleted: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Role.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Role.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/Role.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -1,78 +0,0 @@
-/**
- * This software project is called Geomajas, a component framework for building
- * rich Internet applications (RIA) with sophisticated capabilities for the
- * display, analysis and management of geographic information.
- * It is a building block that allows developers to add maps
- * and other geographic data capabilities to their web applications.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * Copyright 2009 Geosparc, http://www.geosparc.com, Belgium
- * This file is part of Geomajas.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.geomajas.core.aaa;
-
-import java.util.Map;
-
-public abstract class Role {
-
- public abstract String getRoleName();
-
- public abstract String getApplicationName();
-
- /**
- * Map of parameters specific for this application, will only be relevant
- * for a role coupled with a user
- */
- public abstract Map<String, String> getParameters();
-
- // -------------------------------------------------
-
- /**
- * custom implementation as there might be different implementations, but
- * all conceptually same Roles should be equal
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode());
- result = prime * result + ((getRoleName() == null) ? 0 : getRoleName().hashCode());
- return result;
- }
-
- /**
- * custom implementation as there might be different implementations, but
- * all conceptually same Roles should be equal
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- org.geomajas.core.aaa.Role other = (org.geomajas.core.aaa.Role) obj;
- if (getApplicationName() == null) {
- if (other.getApplicationName() != null)
- return false;
- } else if (!getApplicationName().equals(other.getApplicationName()))
- return false;
- if (getRoleName() == null) {
- if (other.getRoleName() != null)
- return false;
- } else if (!getRoleName().equals(other.getRoleName()))
- return false;
- return true;
- }
-}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/User.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/User.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/User.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -28,28 +28,42 @@
public abstract class User {
public abstract String getUserName();
-
- public abstract String getOrganisation();
-
+
+ public abstract Profile getActiveProfile();
+
+ public abstract String getProfileName();
+
public abstract String getApplicationName();
- public abstract boolean hasRole(String roleName, String applicationName);
+ public abstract void setActiveProfile(String profileName, String applicationName);
+ public abstract String[] getProfileNames(String applicationName);
+
+ /**
+ * this is active profile only
+ *
+ * @param applicationName
+ * @return
+ */
public abstract boolean isInApplication(String applicationName);
- public abstract Map<String, String> getParameters();
-
/**
- * should return default parameters if no parameters for given application,
- * not null
+ * this is active profile only
+ *
+ * @param roleName
+ * @return
*/
- public abstract Map<String, String> getParameters(String application);
+ public abstract boolean hasRole(String roleName);
+ public abstract Map<String, String> getRoleProperties();
+
+ public abstract Map<String, String> getUserProperties();
+
// -------------------------------------------------
/**
* custom implementation as there might be different implementations, but
- * all conceptually same Roles should be equal
+ * all conceptually same Users should be equal
*/
@Override
public int hashCode() {
@@ -61,7 +75,7 @@
/**
* custom implementation as there might be different implementations, but
- * all conceptually same Roles should be equal
+ * all conceptually same Users should be equal
*/
@Override
public boolean equals(Object obj) {
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContext.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContext.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContext.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -29,7 +29,12 @@
public void setUser(User user);
- public boolean isUserInRole(String roleName, String applicationName);
+ /**
+ * checks if role of active profile is the same as given rolename
+ * @param roleName
+ * @return
+ */
+ public boolean isUserInRole(String roleName);
/**
* used at logon to decide if user should be allowed to login
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextImpl.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextImpl.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextImpl.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -52,8 +52,8 @@
this.user = user;
}
- public boolean isUserInRole(String roleName, String applicationName) {
- return (user == null ? false : user.hasRole(roleName, applicationName));
+ public boolean isUserInRole(String roleName) {
+ return (user == null ? false : user.hasRole(roleName));
}
public boolean isAuthenticated() {
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextManager.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextManager.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/UserContextManager.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -24,7 +24,6 @@
package org.geomajas.core.aaa;
import java.io.IOException;
-import java.util.List;
public interface UserContextManager {
@@ -33,7 +32,7 @@
* @return the userobject (load from file or database)
* @throws IOException
*/
- public User getUser(String organisation, String userId, String password) throws IOException;
+ public User getUser(String userId, String password) throws IOException;
public boolean hasUsers(String applicationName) throws IOException;
@@ -43,6 +42,4 @@
* @return
*/
public User getGuest(String applicationName);
-
- public List<String> getOrganisations() throws IOException;
}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/PolicyRule.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/PolicyRule.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/PolicyRule.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -25,9 +25,9 @@
import java.util.EnumSet;
-import org.geomajas.core.aaa.Role;
import org.geomajas.core.aaa.User;
import org.geomajas.core.aaa.UserContext;
+import org.geomajas.core.aaa.policy.xml.Role;
import org.geomajas.core.global.MajasConstants;
public class PolicyRule {
@@ -163,7 +163,7 @@
if (isApplicable(applicationName)) {
if (isRolePolicyRule()) {
// has the necessary role
- if (userContext.isUserInRole(this.role.getRoleName(), applicationName)) {
+ if (userContext.isUserInRole(this.role.getRoleName())) {
// is operation allowed
if (this.operations.containsAll(operations)) {
// correct resource
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/HibernateUserContextManager.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/HibernateUserContextManager.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/HibernateUserContextManager.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -24,8 +24,6 @@
package org.geomajas.core.aaa.policy.hibernate;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,23 +40,23 @@
private final UserDao userDao = new UserDao();
- public User getUser(String organisation, String loginId, String password) throws IOException {
+ public User getUser(String loginId, String password) throws IOException {
synchronized (userDao) { // only one dao for all requests
// get session for current thread
userDao.setSession(HibernateUtil.getInstance().getCurrentSession());
- User u = userDao.findLoginUser(organisation, loginId, password);
+ User u = userDao.findLoginUser(loginId, password);
if (u != null) {
// preload, object won't be reconnected
- log.debug("Retrieved user: " + u.getUserName() + " - roles: " + u.getRoleNames());
+ log.debug("Retrieved user: " + u.getUserName());
}
return u;
}
}
public User getGuest(String applicationName) {
- User u = new User("Guest", "guest");
- u.addRole(new Role("Public", applicationName));
- u.getParameters().put("canLogout", "false");
+ User u = new User("Gast");
+ u.setActiveProfile(new Profile("_[none]_", "Public", applicationName));
+ u.getRoleProperties().put("canLogout", "false");
return u;
}
@@ -70,13 +68,6 @@
}
}
- public List<String> getOrganisations() throws IOException {
- synchronized (userDao) { // only one dao for all requests
- userDao.setSession(HibernateUtil.getInstance().getCurrentSession());
- return userDao.findOrganisations();
- }
- }
-
// -------------------------------------------------
private static class UserDao extends GenericHibernateDAO<User, String> {
@@ -90,35 +81,26 @@
this.session = s;
}
- public User findLoginUser(String organisation, String loginId, String password) {
+ public User findLoginUser(String loginId, String password) {
SQLQuery q = getSession()
.createSQLQuery(
- "SELECT {users.*} FROM {users} WHERE username = ? AND organisation = ? AND password = md5(?)");
+ "SELECT {users.*} FROM {users} WHERE username = ? AND password = md5(?)");
q.addEntity("users", User.class);
q.setString(0, loginId);
- q.setString(1, organisation);
- q.setString(2, password);
+ q.setString(1, password);
return (User) q.uniqueResult();
}
- @SuppressWarnings("unchecked")
- public List<String> findOrganisations() {
- List<String> orgs = new ArrayList<String>();
- SQLQuery q = getSession()
- .createSQLQuery(
- "SELECT DISTINCT organisation FROM users ORDER BY 1");
- List<Object> res = (List<Object>) q.list();
- for (Object o : res) {
- orgs.add((String) o);
- }
- return orgs;
- }
-
+ /**
+ * check to see if an application has users
+ * @param applicationName
+ * @return
+ */
public boolean hasRoles(String applicationName) {
SQLQuery q = getSession()
.createSQLQuery(
- "SELECT CAST(count(application) as INT) as result FROM user_roles WHERE application = ? OR application = '*'");
+ "SELECT CAST(count(application) as INT) as result FROM user_profiles WHERE application = ? OR application = '*'");
q.addScalar("result", Hibernate.INTEGER);
q.setString(0, applicationName);
Integer count = (Integer) q.uniqueResult();
Copied: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java (from rev 3697, branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Role.java)
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java (rev 0)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Profile.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -0,0 +1,169 @@
+/**
+ * This software project is called Geomajas, a component framework for building
+ * rich Internet applications (RIA) with sophisticated capabilities for the
+ * display, analysis and management of geographic information.
+ * It is a building block that allows developers to add maps
+ * and other geographic data capabilities to their web applications.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Copyright 2009 Geosparc, http://www.geosparc.com, Belgium
+ * This file is part of Geomajas.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.geomajas.core.aaa.policy.hibernate;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.hibernate.annotations.Type;
+
+@Entity
+@Table(name = "user_profiles")
+public class Profile extends org.geomajas.core.aaa.Profile {
+
+ /**
+ * this is not a nice domainclass, it was tweaked to fit hibernate, may be
+ * better to just add a surrogate key to user & role to define association
+ * (but this then mucks up the databaseschema...)
+ */
+ @EmbeddedId
+ private UserProfilePK compositeKey = new UserProfilePK();
+
+ @Column(name = "rolename")
+ private String roleName;
+
+ @Column(name = "properties")
+ @Type(type = "org.geomajas.core.aaa.policy.hibernate.PropertyMapType")
+ Map<String, String> properties = new HashMap<String, String>();
+
+ public Profile() {
+ }
+
+ public Profile(String profileName, String roleName, String applicationName) {
+ setProfileName(profileName);
+ setRoleName(roleName);
+ setApplicationName(applicationName);
+ }
+
+ // ---------------------------------------------------------
+
+ public String getApplicationName() {
+ return compositeKey.applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ if (applicationName == null || "".equals(applicationName))
+ throw new IllegalArgumentException("Please provide a applicationName");
+ compositeKey.applicationName = applicationName;
+ }
+
+ public void setProfileName(String profileName) {
+ if (profileName == null || "".equals(profileName))
+ throw new IllegalArgumentException("Please provide a profileName");
+ compositeKey.profileName = profileName;
+ }
+
+ public User getUser() {
+ return compositeKey.user;
+ }
+
+ public String getRoleName() {
+ return roleName;
+ }
+
+ public void setRoleName(String roleName) {
+ if (roleName == null || "".equals(roleName))
+ throw new IllegalArgumentException("Please provide a roleName");
+ this.roleName = roleName;
+ }
+
+ public Map<String, String> getRoleProperties() {
+ return properties;
+ }
+
+ @Override
+ public String getProfileName() {
+ return compositeKey.profileName;
+ }
+
+ public String toString() {
+ return getProfileName() + " - " + getApplicationName() + " - " + getRoleName() + " - "
+ + getUser().getUserName();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * needed for composite Id
+ */
+ private static class UserProfilePK implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ManyToOne
+ @JoinColumn(name = "username")
+ User user;
+
+ @Column(name = "profilename")
+ String profileName;
+
+ @Column(name = "application")
+ String applicationName;
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((applicationName == null) ? 0 : applicationName.hashCode());
+ result = prime * result + ((profileName == null) ? 0 : profileName.hashCode());
+ result = prime * result + ((user == null) ? 0 : user.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ UserProfilePK other = (UserProfilePK) obj;
+ if (applicationName == null) {
+ if (other.applicationName != null)
+ return false;
+ } else if (!applicationName.equals(other.applicationName))
+ return false;
+ if (profileName == null) {
+ if (other.profileName != null)
+ return false;
+ } else if (!profileName.equals(other.profileName))
+ return false;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ return true;
+ }
+ }
+}
Deleted: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Role.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Role.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/Role.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -1,143 +0,0 @@
-/**
- * This software project is called Geomajas, a component framework for building
- * rich Internet applications (RIA) with sophisticated capabilities for the
- * display, analysis and management of geographic information.
- * It is a building block that allows developers to add maps
- * and other geographic data capabilities to their web applications.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * Copyright 2009 Geosparc, http://www.geosparc.com, Belgium
- * This file is part of Geomajas.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.geomajas.core.aaa.policy.hibernate;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.persistence.Column;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
-import org.hibernate.annotations.Type;
-
-@Entity
-@Table(name = "user_roles")
-public class Role extends org.geomajas.core.aaa.Role {
-
- /**
- * this is not a nice domainclass, it was tweaked to fit hibernate, may be
- * better to just add a surrogate key to user & role to define association
- * (but this then mucks up the databaseschema...)
- */
- @EmbeddedId
- private UserRolePK compositeKey = new UserRolePK();
-
- @Column(name = "application")
- private String applicationName;
-
- @Column(name = "properties")
- @Type(type = "org.geomajas.core.aaa.policy.hibernate.PropertyMapType")
- Map<String, String> properties = new HashMap<String, String>();
-
- public Role() {
- }
-
- public Role(String roleName, String applicationName) {
- setRoleName(roleName);
- setApplicationName(applicationName);
- }
-
- // ---------------------------------------------------------
-
- public String getApplicationName() {
- return applicationName;
- }
-
- public void setApplicationName(String applicationName) {
- this.applicationName = applicationName;
- }
-
- public User getUser() {
- return compositeKey.user;
- }
-
- public String getRoleName() {
- return compositeKey.roleName;
- }
-
- public void setRoleName(String roleName) {
- compositeKey.roleName = roleName;
- }
-
- public Map<String, String> getParameters() {
- return properties;
- }
-
- public String toString() {
- return getRoleName() + (applicationName != null ? " (" + applicationName + ")" : "");
- }
-
- /**
- * needed for composite Id
- */
- private static class UserRolePK implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @ManyToOne
- @JoinColumns( { @JoinColumn(name = "username", referencedColumnName = "username"),
- @JoinColumn(name = "organisation", referencedColumnName = "organisation") })
- User user;
-
- @Column(name = "rolename")
- String roleName;
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((roleName == null) ? 0 : roleName.hashCode());
- result = prime * result + ((user == null) ? 0 : user.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- UserRolePK other = (UserRolePK) obj;
- if (roleName == null) {
- if (other.roleName != null)
- return false;
- } else if (!roleName.equals(other.roleName))
- return false;
- if (user == null) {
- if (other.user != null)
- return false;
- } else if (!user.equals(other.user))
- return false;
- return true;
- }
- }
-}
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java 2009-08-14 11:27:04 UTC (rev 3736)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/aaa/policy/hibernate/User.java 2009-08-14 13:26:53 UTC (rev 3737)
@@ -23,183 +23,150 @@
*/
package org.geomajas.core.aaa.policy.hibernate;
-import static org.geomajas.core.global.MajasConstants.GLOB;
-
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Column;
-import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
+import javax.persistence.Transient;
-import org.apache.commons.lang.NotImplementedException;
+import org.geomajas.core.global.MajasConstants;
import org.hibernate.annotations.Type;
@Entity
@Table(name = "users")
public class User extends org.geomajas.core.aaa.User {
- @EmbeddedId
- private UserPK compositeKey = new UserPK();
+ @Id
+ @Column(name = "username")
+ private String userName;
@OneToMany(mappedBy = "compositeKey.user")
// don't fetch = FetchType.EAGER, doesn't work!
- private List<Role> roles = new ArrayList<Role>();
+ private List<Profile> profiles = new ArrayList<Profile>();
@Column(name = "properties")
@Type(type = "org.geomajas.core.aaa.policy.hibernate.PropertyMapType")
- Map<String, String> properties = new HashMap<String, String>();
+ private Map<String, String> properties = new HashMap<String, String>();
+ @Transient
+ private Profile activeProfile;
+
public User() {
}
- public User(String userName, String organisation) {
- setUserName(userName);
- setOrganisation(organisation);
+ public User(String userName) {
+ this.userName = userName;
}
// -------------------------------------------------------
- public Role[] getRoles() {
- if (roles == null || roles.size() < 1)
- return new Role[0];
- return roles.toArray(new Role[roles.size()]);
- }
-
public String getUserName() {
- return compositeKey.user;
+ return userName;
}
public User setUserName(String userName) {
- compositeKey.user = userName;
+ this.userName = userName;
return this;
}
-
- public String getOrganisation() {
- return compositeKey.organisation;
- }
- public User setOrganisation(String organisation) {
- compositeKey.organisation = organisation;
- return this;
+ public String getProfileName() {
+ if (activeProfile == null)
+ throw new IllegalStateException("Profile not set");
+ return activeProfile.getProfileName();
}
-
- public void addRole(Role role) {
- if (role == null)
- throw new IllegalArgumentException("Please provide a role");
- roles.add(role);
- }
- public Map<String, String> getParameters() {
- return properties;
+ public void addProfile(Profile profile) {
+ if (profile == null)
+ throw new IllegalArgumentException("Please provide a profile");
+ profiles.add(profile);
}
- @SuppressWarnings("unchecked")
- public Map<String, String> getParameters(String application) {
- if (application == null || "".equals(application))
- return properties;
- for (Role r : roles) {
- if (r.getApplicationName().equals(application)) {
- if (r.getParameters().isEmpty()) {
- return properties;
- } else {
- Map m = new HashMap<String, String>();
- m.putAll(properties);
- m.putAll(r.getParameters());
- return m;
- }
- }
- }
- return properties;
- }
-
@Override
- public boolean hasRole(String roleName, String applicationName) {
- if (roleName == null || "".equals(roleName) || applicationName == null || "".equals(applicationName))
- throw new IllegalArgumentException("Please provide a role and applicationName");
- for (Role r : getRoles()) {
- if (r.getRoleName().equals(roleName)) {
- if (GLOB.equals(r.getApplicationName()) || applicationName.equals(r.getApplicationName()))
- return true;
- }
- }
- return false;
- }
-
- @Override
public boolean isInApplication(String applicationName) {
if (applicationName == null || "".equals(applicationName))
throw new IllegalArgumentException("Please provide an applicationName");
- for (Role r : roles) {
- if (applicationName.equals(r.getApplicationName()) || GLOB.equals(r.getApplicationName()))
- return true;
- }
- return false;
+ if (activeProfile == null)
+ return false;
+ String userAppName = activeProfile.getApplicationName();
+ return (MajasConstants.GLOB.equals(userAppName) || applicationName.equals(userAppName));
}
- public String getRoleNames() {
- StringBuilder sb = new StringBuilder(100);
- for (Role r : roles) {
- sb.append(r.toString());
- sb.append(", ");
+ public String[] getProfileNames(String applicationName) {
+ if (applicationName == null || "".equals(applicationName))
+ throw new IllegalArgumentException("Please provide an applicationname");
+ ArrayList<String> names = new ArrayList<String>();
+ for (Profile p : profiles) {
+ if (MajasConstants.GLOB.equals(p.getApplicationName())
+ || p.getApplicationName().equals(applicationName))
+ names.add(p.getProfileName());
}
- return sb.substring(0, sb.length() - 2);
+ return names.toArray(new String[names.size()]);
}
@Override
public String getApplicationName() {
- throw new NotImplementedException("not used atm");
+ if (activeProfile == null)
+ throw new IllegalStateException("Profile not set");
+ return activeProfile.getApplicationName();
}
- // ------------------------------------------------------------------------
+ public List<Profile> getProfiles() {
+ return profiles;
+ }
- /**
- * needed for composite Id
- */
- private static class UserPK implements Serializable {
+ public Profile getActiveProfile() {
+ return activeProfile;
+ }
- private static final long serialVersionUID = 1L;
+ public void setActiveProfile(Profile profile) {
+ this.activeProfile = profile;
+ }
- @Column(name = "username")
- String user;
+ public void setActiveProfile(String profileName, String applicationName) {
+ activeProfile = null;
+ if (profileName == null || "".equals(profileName))
+ return;
+ if (applicationName == null)
+ throw new IllegalArgumentException("Please provide an applicationname");
- @Column(name = "organisation")
- String organisation;
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((organisation == null) ? 0 : organisation.hashCode());
- result = prime * result + ((user == null) ? 0 : user.hashCode());
- return result;
+ for (Profile pr : profiles) {
+ if (pr.getProfileName().equals(profileName)
+ && (MajasConstants.GLOB.equals(pr.getApplicationName()) || pr.getApplicationName()
+ .equals(applicationName)))
+ activeProfile = pr;
}
+ if (activeProfile == null)
+ throw new IllegalArgumentException("No profile with name: " + profileName);
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- UserPK other = (UserPK) obj;
...
[truncated message content] |
|
From: <sv...@ge...> - 2009-08-14 12:27:47
|
Author: jandm
Date: 2009-08-14 13:27:04 +0200 (Fri, 14 Aug 2009)
New Revision: 3736
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/StringUtils.java
branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/util/StringUtilsTest.java
Log:
RWOPB-91: schema changes (padding) + scales corrected
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/StringUtils.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/StringUtils.java 2009-08-14 06:06:56 UTC (rev 3735)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/core/util/StringUtils.java 2009-08-14 11:27:04 UTC (rev 3736)
@@ -65,4 +65,21 @@
sb.append(expression.substring(pos, max));
return sb.toString();
}
+
+ public static String leftPad(String str, int length, char ch) {
+ return (length > str.length()) ? createPadding(ch, length - str.length()).concat(str) : str;
+ }
+
+ public static String rightPad(String str, int length, char ch) {
+ return (length > str.length()) ? str.concat(createPadding(ch, length - str.length())) : str;
+ }
+
+ public static String createPadding(char ch, int length) {
+ char padding[] = new char[length];
+ for (int i = 0; i < length; ++i) {
+ padding[i] = ch;
+ }
+ return new String(padding).intern();
+ }
+
}
Modified: branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/util/StringUtilsTest.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/util/StringUtilsTest.java 2009-08-14 06:06:56 UTC (rev 3735)
+++ branches/1.3.x_planbaten/majas-core/src/test/java/org/geomajas/core/util/StringUtilsTest.java 2009-08-14 11:27:04 UTC (rev 3736)
@@ -63,4 +63,14 @@
Map<String, String> params = new HashMap<String, String>();
StringUtils.substituteParameters("niet gevonden ${param}", params);
}
+
+ @Test
+ public void testPadding() throws Exception {
+ assertEquals("0000000123",StringUtils.leftPad("123", 10, '0'));
+ assertEquals("1230000000",StringUtils.rightPad("123", 10, '0'));
+ assertEquals("12345678910",StringUtils.leftPad("12345678910", 10, '0'));
+ assertEquals("12345678910",StringUtils.rightPad("12345678910", 10, '0'));
+ }
+
+
}
|
|
From: <sv...@ge...> - 2009-08-14 07:06:46
|
Author: pieterdg
Date: 2009-08-14 08:06:56 +0200 (Fri, 14 Aug 2009)
New Revision: 3735
Modified:
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/FeatureListTable.js
Log:
fix for RWOPB-49 : no ID in the featurelisttable
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/FeatureListTable.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/FeatureListTable.js 2009-08-14 05:55:41 UTC (rev 3734)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/FeatureListTable.js 2009-08-14 06:06:56 UTC (rev 3735)
@@ -38,14 +38,14 @@
widgetsInTemplate : true,
templatePath : dojo.moduleUrl("geomajas.widget", "html/FeatureListTable.html"),
- useIdInTable : true, // Add the feature's ID as a column or not. Right now, this MUST be true!!!
+ useIdInTable : true,
grid : null,
layer : null,
data : null,
editingTopic : null,
selectionTopic : null,
singleSelection : false,
- supportEditing : false, // Allows editing of a feature, by doubleclicking on it's row.
+ supportEditing : false, // Allows editing of a feature, by double clicking on it's row.
dialog : null,
mapWidget : null,
@@ -125,6 +125,8 @@
var thead = [];
if (this.useIdInTable) {
thead.push({ name:"id", width: "50px" });
+ } else {
+ thead.push({ name:"id", width: "0px", styles: "display:none;" });
}
var w = parseInt(100/keys.length) + "%";
for (var i=0; i<keys.length; i++) {
@@ -171,10 +173,7 @@
if (this.layer != null && this.layer instanceof VectorLayer) {
this.features.add(feature.getLocalId(), feature);
var row = [];
- if (this.useIdInTable) {
- row.push (feature.getLocalId());
- }
-
+ row.push (feature.getLocalId());
var attr = this.layer.getFeatureType().getIdentifyingAttributes();
var keys = attr.getKeyList();
for (var i=0; i<keys.length; i++) {
@@ -287,7 +286,6 @@
if (this.grid) {
var row = this.grid.model.getRow(rowIndex);
if (row) {
- //var feature = this.layer.getFeatureStore().getFeatureById(row[0]);
var feature = this.features.item(row[0]);
this.stopListening = true;
dojo.publish (this.selectionTopic, ["select", feature]);
@@ -302,7 +300,6 @@
if (this.grid) {
var row = this.grid.model.getRow(rowIndex);
if (row) {
- //var feature = this.layer.getFeatureStore().getFeatureById(row[0]);
var feature = this.features.item(row[0]);
this.stopListening = true;
dojo.publish (this.selectionTopic, ["deselect", feature]);
@@ -356,8 +353,6 @@
_onCellDblClick : function (e) {
var rowIndex = this.grid.focus.rowIndex;
var row = this.grid.model.getRow(rowIndex);
- //var localFeatureId = this.data[rowIndex][0];
- //var tmpFeature = this.layer.getFeatureStore().getFeatureById(localFeatureId);
var tmpFeature = this.features.item(row[0]);
if (tmpFeature == null) {
return;
|
|
From: <sv...@ge...> - 2009-08-14 06:55:30
|
Author: jandm
Date: 2009-08-14 07:55:41 +0200 (Fri, 14 Aug 2009)
New Revision: 3734
Modified:
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js
Log:
RWOPB-81: scales to rounded numbers, pixel set to 0.0003 m
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js 2009-08-13 08:19:00 UTC (rev 3733)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js 2009-08-14 05:55:41 UTC (rev 3734)
@@ -42,7 +42,7 @@
/** Width of a pixel. Default is 1/72 inch. This determines how
* accurate the calculations in this class are! */
- this.pixelWidth = 0.0035294117647058823529411764705887;
+ this.pixelWidth = 0.0003;
},
/**
@@ -94,20 +94,27 @@
* @return Returns a string like (1:x).
*/
scaleToString : function (scale) {
- var value = Math.round(this.unitLength / scale * this.pixelWidth);
+ log.debug("scaleToString : scale = "+scale);
+ log.debug("scaleToString : unit length = "+this.unitLength);
+ log.debug("scaleToString : pixel width = "+this.pixelWidth);
+ var value = Math.round(this.unitLength / (scale * this.pixelWidth));
+ log.debug("scaleToString : value = "+value);
var inverse = false;
if(value == 0){
- value = Math.round(temp / this.unitLength);
+ value = Math.round((scale * this.pixelWidth) / this.unitLength);
+ log.debug("scaleToString : inverse value = "+value);
inverse = true;
}
var strValue = "" + value;
var count = strValue.length - 3;
+ log.debug("scaleToString : strValue = "+strValue);
while (count > 0) {
var before = strValue.substring(0, count);
var after = strValue.substring(count);
strValue = before + "." + after;
count = count - 3;
}
+ log.debug("scaleToString : strValue after = "+strValue);
return inverse ? strValue+": 1" : "1 : " + strValue;
},
@@ -144,7 +151,7 @@
if(inverse){
scale = parseFloat(value * this.pixelWidth / this.unitLength);
}else {
- scale = parseFloat(this.unitLength / value * this.pixelWidth);
+ scale = parseFloat(this.unitLength / (value * this.pixelWidth));
}
return scale;
}
|
|
From: <sv...@ge...> - 2009-08-13 09:18:43
|
Author: pieterdg
Date: 2009-08-13 10:19:00 +0200 (Thu, 13 Aug 2009)
New Revision: 3733
Removed:
branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonResult.java
Modified:
branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java
Log:
Modified: branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java
===================================================================
--- branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java 2009-08-13 08:18:12 UTC (rev 3732)
+++ branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java 2009-08-13 08:19:00 UTC (rev 3733)
@@ -73,7 +73,7 @@
private MultiPolygon polygon;
public void execute() {
- result = new GetFeaturesByPolygonResult();
+ result = new SearchFeaturesResult();
try {
// create the bbox filter
Deleted: branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonResult.java
===================================================================
--- branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonResult.java 2009-08-13 08:18:12 UTC (rev 3732)
+++ branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonResult.java 2009-08-13 08:19:00 UTC (rev 3733)
@@ -1,48 +0,0 @@
-/**
- * This software project is called Geomajas, a component framework for building
- * rich Internet applications (RIA) with sophisticated capabilities for the
- * display, analysis and management of geographic information.
- * It is a building block that allows developers to add maps
- * and other geographic data capabilities to their web applications.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * Copyright 2009 Geosparc, http://www.geosparc.com, Belgium
- * This file is part of Geomajas.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.geomajas.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class GetFeaturesByPolygonResult extends ApplicationResult {
-
- private List<String> ids;
-
- // Constructors:
-
- public GetFeaturesByPolygonResult() {
- ids = new ArrayList<String>();
- }
-
- // Getters and setters:
-
- public List<String> getIds() {
- return ids;
- }
-
- public void addAll(List<String> ids) {
- this.ids.addAll(ids);
- }
-}
|
|
From: <sv...@ge...> - 2009-08-13 09:17:58
|
Author: pieterdg
Date: 2009-08-13 10:18:12 +0200 (Thu, 13 Aug 2009)
New Revision: 3732
Modified:
branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java
Log:
Modified: branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java
===================================================================
--- branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java 2009-08-13 08:17:59 UTC (rev 3731)
+++ branches/1.3.x/majas-core/src/main/java/org/geomajas/command/GetFeaturesByPolygonCommand.java 2009-08-13 08:18:12 UTC (rev 3732)
@@ -87,24 +87,26 @@
Filter f = FilterCreator.createIntersectsFilter(polygon, geomName);
FeatureRenderer painter = new FeatureRenderer();
- map.paint(painter, new String[] { layer }, new Filter[] { f }, null);
- List<String> ids = new ArrayList<String>();
+ map
+ .paint(painter, new String[] { layer }, new Filter[] { f },
+ null);
+ List<Feature> features = new ArrayList<Feature>();
Iterator<Feature> iterator = painter.getFeatures().iterator();
while (iterator.hasNext()) {
Feature feature = iterator.next();
- Geometry geometry = vectorLayer.getLayerModel()
- .getFeatureModel().getGeometry(feature);
+ Geometry geometry = feature.getGeometry();
double area = geometry.getArea();
Geometry intersection = geometry.intersection(polygon);
double interArea = intersection.getArea();
float geomPercentage = (float) (interArea / area);
if (geomPercentage > percentage) {
- ids.add(feature.getLocalId());
+ features.add(feature);
}
}
- ((GetFeaturesByPolygonResult) result).addAll(ids);
+ result = new SearchFeaturesResult(layer, features
+ .toArray(new Feature[] {}));
} catch (IOException e) {
logger.error("execute() : problem accessing layer", e);
result.addErrorMessage("problem accessing layer");
|
|
From: <sv...@ge...> - 2009-08-13 09:17:47
|
Author: pieterdg
Date: 2009-08-13 10:17:59 +0200 (Thu, 13 Aug 2009)
New Revision: 3731
Added:
branches/1.3.x/majas-core/src/main/java/org/geomajas/command/LogCommand.java
Log:
Added: branches/1.3.x/majas-core/src/main/java/org/geomajas/command/LogCommand.java
===================================================================
--- branches/1.3.x/majas-core/src/main/java/org/geomajas/command/LogCommand.java (rev 0)
+++ branches/1.3.x/majas-core/src/main/java/org/geomajas/command/LogCommand.java 2009-08-13 08:17:59 UTC (rev 3731)
@@ -0,0 +1,58 @@
+package org.geomajas.command;
+
+import org.apache.log4j.Logger;
+import org.geomajas.command.AbstractApplicationCommand;
+import org.geomajas.command.ApplicationResult;
+
+public class LogCommand extends AbstractApplicationCommand {
+
+ private static final int LEVEL_DEBUG = 0;
+
+ private static final int LEVEL_INFO = 1;
+
+ private static final int LEVEL_WARN = 2;
+
+ private static final int LEVEL_ERROR = 3;
+
+ private static final Logger logger = Logger.getLogger(LogCommand.class);
+
+ private String statement;
+
+ private int level = 1;
+
+ // ApplicationCommand implementation:
+
+ public void execute() {
+ switch (level) {
+ case LEVEL_DEBUG:
+ logger.debug(statement);
+ break;
+ case LEVEL_INFO:
+ logger.info(statement);
+ break;
+ case LEVEL_WARN:
+ logger.warn(statement);
+ break;
+ case LEVEL_ERROR:
+ logger.error(statement);
+ break;
+ }
+ result = new ApplicationResult();
+ }
+
+ public String getStatement() {
+ return statement;
+ }
+
+ public void setStatement(String statement) {
+ this.statement = statement;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public void setLevel(int level) {
+ this.level = level;
+ }
+}
\ No newline at end of file
Property changes on: branches/1.3.x/majas-core/src/main/java/org/geomajas/command/LogCommand.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
|
|
From: <sv...@ge...> - 2009-08-13 09:17:36
|
Author: pieterdg
Date: 2009-08-13 10:17:39 +0200 (Thu, 13 Aug 2009)
New Revision: 3730
Modified:
branches/1.3.x/majas-js/src/main/webapp/js/geomajas/io/CommandDispatcher.js
Log:
Modified: branches/1.3.x/majas-js/src/main/webapp/js/geomajas/io/CommandDispatcher.js
===================================================================
--- branches/1.3.x/majas-js/src/main/webapp/js/geomajas/io/CommandDispatcher.js 2009-08-12 14:49:55 UTC (rev 3729)
+++ branches/1.3.x/majas-js/src/main/webapp/js/geomajas/io/CommandDispatcher.js 2009-08-13 08:17:39 UTC (rev 3730)
@@ -75,5 +75,18 @@
}
// !!!!! must return result for the next callback !!!!
return result;
+ },
+
+ /**
+ * Make a log entry on the server, stating the given statement.
+ * @param level The level of logging:<ul><li>0 = LEVEL_DEBUG</li>
+ * <li>1 = LEVEL_INFO</li><li>2 = LEVEL_WARN</li><li>3 = LEVEL_ERROR</li></ul>
+ * @param statement The statement to log on the server.
+ */
+ logOnServer : function (level, statement) {
+ var command = new JsonCommand("org.geomajas.command.LogCommand", null, false);
+ command.addParam("level", level);
+ command.addParam("statement", statement);
+ var deferred = this.execute(command);
}
});
\ No newline at end of file
|
|
From: <sv...@ge...> - 2009-08-12 15:49:44
|
Author: kristofh
Date: 2009-08-12 16:49:55 +0200 (Wed, 12 Aug 2009)
New Revision: 3729
Modified:
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/action/toolbar/ZoomToMaximumExtentAction.js
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/LayerTreeNode.js
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/RasterLayer.js
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/VectorLayer.js
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/LegendWidget.js
Log:
Legendwidget: updaten bij elke wijziging van layers.
- horizontaal scrollen indien label te lang.
- fout in IE opgelost wanneer meer labels dan voorheen slechts gedeleeltijk getekend.
andere bestanden is enkel wat opgekuist.
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/action/toolbar/ZoomToMaximumExtentAction.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/action/toolbar/ZoomToMaximumExtentAction.js 2009-08-12 09:08:28 UTC (rev 3728)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/action/toolbar/ZoomToMaximumExtentAction.js 2009-08-12 14:49:55 UTC (rev 3729)
@@ -73,7 +73,7 @@
_zoomToMaxExtent : function () {
var bounds = majasConfig["zoomMaxExtentBounds"];
if (bounds != null) {
- console.log("setBounds: x,y,w,h" + bounds.x + ", " + bounds.y + ", " + bounds.width + ", " + bounds.height);
+ log.info("setBounds: x,y,w,h" + bounds.x + ", " + bounds.y + ", " + bounds.width + ", " + bounds.height);
dojo.publish(this.mapWidget.getMapView().getExternalRenderTopic(), [{event:"setBounds", x:bounds.x, y:bounds.y, width:bounds.width, height:bounds.height, option:3}]);// Option:ZOOM_OPTION_MUST_FIT
} else {
console.warn("Cannot zoom to maximum extent: bounds is not set.");
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/LayerTreeNode.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/LayerTreeNode.js 2009-08-12 09:08:28 UTC (rev 3728)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/LayerTreeNode.js 2009-08-12 14:49:55 UTC (rev 3729)
@@ -120,6 +120,15 @@
this.expanded = expanded;
},
+ isVisible : function () {
+ return this.visible;
+ },
+
+ setVisible : function (visible) {
+ log.debug("layer: setVisible: " + visible);
+ this.visible = visible;
+ },
+
getChildren : function () {
return this.children;
},
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/RasterLayer.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/RasterLayer.js 2009-08-12 09:08:28 UTC (rev 3728)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/RasterLayer.js 2009-08-12 14:49:55 UTC (rev 3729)
@@ -24,9 +24,9 @@
*/
dojo.require("geomajas.map.store.common");
dojo.require("geomajas.map.layertree.RasterImageFactory");
-dojo.require("geomajas.gfx.PainterVisitable");
+dojo.require("geomajas.map.layertree.LayerTreeNode");
-dojo.declare("RasterLayer", [PainterVisitable, LayerTreeNode], {
+dojo.declare("RasterLayer", [LayerTreeNode], {
/**
* @fileoverview Represents a layer for raster images.
@@ -102,22 +102,6 @@
return false;
},
- isVisible : function () {
- return this.visible;
- },
-
- setVisible : function (visible) {
- this.visible = visible;
- },
-
- isSelected : function () {
- return this.selected;
- },
-
- setSelected : function (selected) {
- this.selected = selected;
- },
-
getLayerType : function () {
return this.layerType;
},
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/VectorLayer.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/VectorLayer.js 2009-08-12 09:08:28 UTC (rev 3728)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/layertree/VectorLayer.js 2009-08-12 14:49:55 UTC (rev 3729)
@@ -28,10 +28,10 @@
dojo.require("geomajas._base");
dojo.require("geomajas.map.store.common");
dojo.require("geomajas.map.workflow.WorkflowHandler");
-dojo.require("geomajas.gfx.PainterVisitable");
+dojo.require("geomajas.map.layertree.LayerTreeNode");
dojo.require("geomajas.gfx.PainterVisitor");
-dojo.declare("VectorLayer", [PainterVisitable, LayerTreeNode], {
+dojo.declare("VectorLayer", [LayerTreeNode], {
/**
* @fileoverview Represents a layer for vector data.
@@ -233,22 +233,6 @@
setLabelAttribute : function (labelAttribute) {
this.labelAttribute = labelAttribute;
},
-
- isSelected : function () {
- return this.selected;
- },
-
- setSelected : function (/*Boolean*/selected) {
- this.selected = selected;
- },
-
- isVisible : function () {
- return this.visible;
- },
-
- setVisible : function (/*Boolean*/visible) {
- this.visible = visible;
- },
getEditPermissions : function () {
return this.editPermissions;
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/LegendWidget.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/LegendWidget.js 2009-08-12 09:08:28 UTC (rev 3728)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/LegendWidget.js 2009-08-12 14:49:55 UTC (rev 3729)
@@ -46,6 +46,9 @@
polygon : null,
lineString : null,
lineHeight : 25,
+ letterWidth : 8.5, // nattevingerwerk
+ textMargin : 40, // 10 + 25 + 5 zie drawstyle
+
editor : null,
automaticResize : false, // Resize the widget automatically?
checkShapeTypeSize : false, // Should we resize shapetypes when they are too large?
@@ -94,6 +97,7 @@
dojo.disconnect(this.layerHandle);
dojo.disconnect(this.visibleHandle);
dojo.forEach(this.destroyables, function(d) {d.destroy();});
+ dojo.unsubscribe(this.mapChangeHandle);
this.inherited(arguments);
},
@@ -101,14 +105,6 @@
log.debug("LegendWidget.setMapModel => initializes the legend.");
this.mapModel = mapModel;
- var layers = this.mapModel.getLayerList();
- for (var i=0; i<layers.count; i++) {
- var layer = layers.item(i);
- dojo.connect(layer, "setVisible", this, "layout");
- //dojo.connect(layer, "replaceStyle", this, "layout");
- }
- this.layerHandle = dojo.connect(mapModel, "registerLayer", this, "_onRegisterLayer");
-
try {
this._render();
} catch (e) {
@@ -116,16 +112,19 @@
}
if(this.mapModel){
this.destroyables.push(this.mapModel);
+ this.mapChangeHandle = dojo.subscribe(mapModel.getRenderTopic(), this, "_onMapViewChange");
}
},
- /**
- * @private
- */
- _onRegisterLayer : function (layer) {
- this.visibleHandle = dojo.connect(layer, "setVisible", this, "layout");
+ _onMapViewChange : function(event, feature) {
+ if (event == null || event instanceof MapModel || event instanceof LayerTreeNode) {
+ if (feature == "all") {
+ log.debug("updating legend: " + event + " - " + feature);
+ this.layout();
+ }
+ }
},
-
+
/**
* @private
*/
@@ -135,36 +134,65 @@
this.graphics.deleteShape(this.id + "geom" + i);
this.graphics.deleteShape(this.id + "style" + i);
}
-
+
// Then we draw:
- var layers = this.mapModel.getLayerList();
- var count = 1;
- for (var i=0; i<layers.count; i++) {
- var layer = layers.item(i);
- if (layer instanceof VectorLayer && layer.isVisible() && layer.checkScaleVisibility()) {
- var styles = layer.getStyles();
- for (var j=0; j<styles.count; j++) {
- this._drawStyle(count++, styles.item(j), layer.getLayerType());
- }
- } else if (layer instanceof RasterLayer && layer.isVisible() && layer.checkScaleVisibility()) {
- var styleDef = new StyleDefinition(null, layer.getLabel(), null, new PictureStyle(layer.getStyle()));
- this._drawStyle(count++, styleDef, layer.getLayerType());
- }
- }
-
- // If no layer is visible, we should say so:
- if (count == 1) {
+ var layers = this.mapModel.getVisibleLayerList();
+ var maxWidth = 0;
+ var width = 100;
+ var height = this.lineHeight;
+
+ if (layers.count == 0) {
+ // If no layer is visible, we should say so:
+ maxWidth = widgetLocale.noLayersVisible.length * this.letterWidth;
+ this.graphics.setScreenBox(new AABBox(0,0,100,height));
var widgetLocale = dojo.i18n.getLocalization("geomajas.widget", "legend");
var text = new Text(this.id+"style"+count, widgetLocale.noLayersVisible);
var textX = 10;
var textY = parseInt(this.lineHeight/2 + this.textStyle.getFontSize()/2);
text.setPosition(new Coordinate(textX, textY));
this.graphics.drawText(text, {id:this.id+"style"+count, style:this.textStyle});
+ maxWidth = widgetLocale.noLayersVisible.length * this.letterWidth;
+
+ } else {
+ var count = 0;
+ var legendStyleDef = new Array();
+ var legendLayerType = new Array();
+
+ // collecting items
+ for (var i=0; i<layers.count; i++) {
+ var layer = layers.item(i);
+ if (layer instanceof VectorLayer) {
+ var styles = layer.getStyles();
+ for (var j=0; j<styles.count; j++) {
+ legendStyleDef[count] = styles.item(j);
+ legendLayerType[count] = layer.getLayerType();
+ width = this.textMargin + legendStyleDef[count].getName().length * this.letterWidth;
+ if (width > maxWidth) {
+ maxWidth = width;
+ }
+ count++;
+ }
+ } else if (layer instanceof RasterLayer) {
+ legendStyleDef[count] = new StyleDefinition(null, layer.getLabel(), null, new PictureStyle(layer.getStyle()));
+ legendLayerType[count] = layer.getLayerType();
+ width = this.textMargin + legendStyleDef[count].getName().length * this.letterWidth;
+ if (width > maxWidth) {
+ maxWidth = width;
+ }
+ count++;
+ }
+ }
+
+ // reset size first for IE
+ height = 10 + count * this.lineHeight;
+ this.graphics.setScreenBox(new AABBox(0,0,maxWidth,height));
+
+ // really painting
+ for (var i=0; i < count; i++) {
+ this._drawStyle(i + 1, legendStyleDef[i], legendLayerType[i]);
+ }
}
- var width = this._contentBox ? (this._contentBox.w - 20) : 0; //var width = this.graphics.getWidth();
- var height = count * this.lineHeight;
- this.graphics.setScreenBox(new AABBox(0,0,width,height));
this.lastCount = count;
},
|
|
From: <sv...@ge...> - 2009-08-12 10:08:18
|
Author: joachimvda Date: 2009-08-12 11:08:28 +0200 (Wed, 12 Aug 2009) New Revision: 3728 Modified: branches/1.3.x/majas-tutorial/pom.xml Log: MAJ-382 rename majas-tutorial to geomajas-tutorial Modified: branches/1.3.x/majas-tutorial/pom.xml =================================================================== --- branches/1.3.x/majas-tutorial/pom.xml 2009-08-12 09:01:45 UTC (rev 3727) +++ branches/1.3.x/majas-tutorial/pom.xml 2009-08-12 09:08:28 UTC (rev 3728) @@ -59,7 +59,7 @@ </dependency> </dependencies> <build> - <finalName>majas-tutorial</finalName> + <finalName>geomajas-tutorial</finalName> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> |
|
From: <sv...@ge...> - 2009-08-12 10:01:33
|
Author: joachimvda Date: 2009-08-12 11:01:45 +0200 (Wed, 12 Aug 2009) New Revision: 3727 Modified: branches/1.3.x/majas-maven/pom.xml Log: test commit notification mails Modified: branches/1.3.x/majas-maven/pom.xml =================================================================== --- branches/1.3.x/majas-maven/pom.xml 2009-08-12 09:00:14 UTC (rev 3726) +++ branches/1.3.x/majas-maven/pom.xml 2009-08-12 09:01:45 UTC (rev 3727) @@ -11,7 +11,7 @@ <module>../majas-tutorial</module> </modules> <name>Geomajas Maven project</name> - <description>Mapping With Asynchronous Javascript and SVG</description> + <description>Mapping with Asynchronous Javascript and SVG</description> <url>http://www.geomajas.org/</url> <scm> <connection>scm:svn:https://svn.geomajas.org/svn/majas/branches/1.3.x/majas-maven</connection> |
|
From: <sv...@ge...> - 2009-08-12 10:00:04
|
Author: pieterdg
Date: 2009-08-12 11:00:14 +0200 (Wed, 12 Aug 2009)
New Revision: 3726
Modified:
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/MapView.js
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js
branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/ScaleSelect.js
Log:
Fixed the zooming problems with the scale select
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/MapView.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/MapView.js 2009-08-12 08:58:28 UTC (rev 3725)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/MapView.js 2009-08-12 09:00:14 UTC (rev 3726)
@@ -385,7 +385,7 @@
var lower = this.resolutions[i + 1];
if (screenResolution <= upper && screenResolution >= lower) {
log.info("upper = "+upper+", lower="+lower);
- if (this.ZOOM_OPTION_MUST_FIT) {
+ if (option == this.ZOOM_OPTION_MUST_FIT) {
newResolutionIndex = i;
break;
} else {
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js 2009-08-12 08:58:28 UTC (rev 3725)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/map/ScaleUtil.js 2009-08-12 09:00:14 UTC (rev 3726)
@@ -42,7 +42,7 @@
/** Width of a pixel. Default is 1/72 inch. This determines how
* accurate the calculations in this class are! */
- this.pixelWidth = parseFloat(0.003527777);
+ this.pixelWidth = 0.0035294117647058823529411764705887;
},
/**
@@ -72,16 +72,32 @@
},
/**
+ * Get the unit length must be expressed in meters per
+ * unit (of a map's CRS).
+ */
+ getUnitLength : function () {
+ return this.unitLength;
+ },
+
+ /**
+ * Return the width of a pixel. Default is 1/72 inch. This determines how
+ * accurate the calculations in this class are!
+ */
+ getPixelWidth : function () {
+ return this.pixelWidth;
+ },
+
+ /**
* Transform a floating point scale (as they come from the MapView), to a
* string format, such as (1:x).
* @param scale The scale you wish to format.
* @return Returns a string like (1:x).
*/
scaleToString : function (scale) {
- var value = parseInt(this.unitLength / (scale * this.pixelWidth));
+ var value = Math.round(this.unitLength / scale * this.pixelWidth);
var inverse = false;
if(value == 0){
- value = parseInt((scale * this.pixelWidth)/this.unitLength);
+ value = Math.round(temp / this.unitLength);
inverse = true;
}
var strValue = "" + value;
@@ -126,9 +142,9 @@
} else {
var scale = 1;
if(inverse){
- scale = parseFloat((value * this.pixelWidth)/this.unitLength);
+ scale = parseFloat(value * this.pixelWidth / this.unitLength);
}else {
- scale = parseFloat(this.unitLength / (value * this.pixelWidth));
+ scale = parseFloat(this.unitLength / value * this.pixelWidth);
}
return scale;
}
@@ -152,7 +168,7 @@
var text = "";
if (unitType == "english") {
- var length = parseInt( (this.unitLength * pixelCount) / scale );
+ var length = Math.round( (this.unitLength * pixelCount) / scale );
length = parseFloat(length / 1609.344); // to miles
if (length < 10) {
text = length.toFixed(2) + " mi";
@@ -171,7 +187,7 @@
text = length.toFixed(2) + " u";
}
} else { // metric
- var length = parseInt( (this.unitLength * pixelCount) / scale );
+ var length = Math.round( (this.unitLength * pixelCount) / scale );
if (length < 10000) {
text = length+" m";
} else if (length < 100000) {
Modified: branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/ScaleSelect.js
===================================================================
--- branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/ScaleSelect.js 2009-08-12 08:58:28 UTC (rev 3725)
+++ branches/1.3.x_planbaten/majas-js/src/main/webapp/js/geomajas/widget/ScaleSelect.js 2009-08-12 09:00:14 UTC (rev 3726)
@@ -91,9 +91,9 @@
if (resolutions != null) {
var scales = [];
for(var i=resolutions.length-1; i>=0; i--) {
- var scale = 1 / resolutions[i];
- var value = parseInt(this.mapWidget.getScaleUtil().unitLength /
- (scale * this.mapWidget.getScaleUtil().pixelWidth));
+ var scale = parseFloat(1 / resolutions[i]);
+ var temp = scale * this.mapWidget.getScaleUtil().getPixelWidth();
+ var value = Math.round(this.mapWidget.getScaleUtil().getUnitLength() / temp);
scales.push(value);
}
this.setScaleArray(scales);
|
|
From: <sv...@ge...> - 2009-08-12 09:58:19
|
Author: pieterdg
Date: 2009-08-12 10:58:28 +0200 (Wed, 12 Aug 2009)
New Revision: 3725
Modified:
branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetMapUnitLengthCommand.java
Log:
Calculate the unit length on a flat surface
Modified: branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetMapUnitLengthCommand.java
===================================================================
--- branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetMapUnitLengthCommand.java 2009-08-12 08:34:53 UTC (rev 3724)
+++ branches/1.3.x_planbaten/majas-core/src/main/java/org/geomajas/command/GetMapUnitLengthCommand.java 2009-08-12 08:58:28 UTC (rev 3725)
@@ -26,13 +26,17 @@
import java.io.IOException;
import org.geomajas.core.application.Map;
-import org.geotools.geometry.jts.JTS;
+import org.geomajas.core.util.GeoUtil;
+import org.geotools.geometry.DirectPosition2D;
+import org.geotools.referencing.CRS;
+import org.opengis.geometry.DirectPosition;
import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.FactoryException;
+import org.opengis.referencing.NoSuchAuthorityCodeException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
-import com.vividsolutions.jts.geom.Coordinate;
-
/**
* <p>
* Get the CRS conversion factor for a specific map. Simply put: how many meters
@@ -56,11 +60,26 @@
Map map = application.getMap(mapId);
if (map != null) {
try {
- CoordinateReferenceSystem crs = map.getDefaultCrs();
- Coordinate c1 = new Coordinate(0, 0);
- Coordinate c2 = new Coordinate(1, 0);
- double distance = JTS.orthodromicDistance(c1, c2, crs);
- result = new GetMapUnitLengthResult(distance);
+ CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:31300");
+ CoordinateReferenceSystem sourceCRS = map.getDefaultCrs();
+ MathTransform transform = GeoUtil.findMathTransform(sourceCRS, targetCRS);
+ if (transform != null) {
+ if (!transform.isIdentity()) {
+ DirectPosition src1 = new DirectPosition2D(0, 0);
+ DirectPosition src2 = new DirectPosition2D(1, 0);
+ DirectPosition d1 = new DirectPosition2D(0, 0);
+ DirectPosition d2 = new DirectPosition2D(0, 0);
+ transform.transform(src1, d1);
+ transform.transform(src2, d2);
+
+ double dx = Math.abs(d1.getOrdinate(0) - d2.getOrdinate(0));
+ double dy = Math.abs(d1.getOrdinate(1) - d2.getOrdinate(1));
+ double distance = Math.sqrt(dx * dx + dy * dy);
+ result = new GetMapUnitLengthResult(distance);
+ return;
+ }
+ }
+ result = new GetMapUnitLengthResult(1);
} catch (IOException e) {
result = new GetMapUnitLengthResult(0);
result.addErrorMessage("Error fetching CRS unit length: " + e.getMessage());
@@ -71,6 +90,12 @@
} catch (TransformException e) {
result = new GetMapUnitLengthResult(0);
e.printStackTrace();
+ } catch (NoSuchAuthorityCodeException e) {
+ result = new GetMapUnitLengthResult(0);
+ e.printStackTrace();
+ } catch (FactoryException e) {
+ result = new GetMapUnitLengthResult(0);
+ e.printStackTrace();
}
} else {
result = new GetMapUnitLengthResult(0);
|
|
From: <sv...@ge...> - 2009-08-12 09:34:42
|
Author: joachimvda Date: 2009-08-12 10:34:53 +0200 (Wed, 12 Aug 2009) New Revision: 3724 Modified: branches/1.3.x/majas-maven/pom.xml Log: test commit notification mails Modified: branches/1.3.x/majas-maven/pom.xml =================================================================== --- branches/1.3.x/majas-maven/pom.xml 2009-08-12 08:25:45 UTC (rev 3723) +++ branches/1.3.x/majas-maven/pom.xml 2009-08-12 08:34:53 UTC (rev 3724) @@ -20,7 +20,7 @@ </scm> <organization> - <name>Geosparc NV</name> + <name>Geosparc nv</name> <url>http://www.geosparc.com</url> </organization> <properties> |
|
From: <sv...@ge...> - 2009-08-12 09:25:33
|
Author: joachimvda Date: 2009-08-12 10:25:45 +0200 (Wed, 12 Aug 2009) New Revision: 3723 Modified: branches/1.3.x/majas-maven/pom.xml Log: fix site location Modified: branches/1.3.x/majas-maven/pom.xml =================================================================== --- branches/1.3.x/majas-maven/pom.xml 2009-08-12 08:23:47 UTC (rev 3722) +++ branches/1.3.x/majas-maven/pom.xml 2009-08-12 08:25:45 UTC (rev 3723) @@ -147,7 +147,7 @@ <site> <id>geomajas.org</id> <name>Mapping with Asynchronous Java and SVG</name> - <url>http://www.geomajas.org/maven</url> + <url>http://www.geomajas.org/maven/</url> </site> </distributionManagement> |