incubator-unomi git commit: UNOMI-101 : Add Exception mapper for error handling
Repository: incubator-unomi Updated Branches: refs/heads/master 8f6f2472d -> be379f8ec UNOMI-101 : Add Exception mapper for error handling Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/be379f8e Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/be379f8e Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/be379f8e Branch: refs/heads/master Commit: be379f8eca0a6f804b89d380c5c938dd684bf234 Parents: 8f6f247 Author: Abdelkader MidaniAuthored: Thu Jul 6 02:54:45 2017 +0200 Committer: Abdelkader Midani Committed: Thu Jul 6 02:54:45 2017 +0200 -- .../router/rest/ConfigRestExceptionMapper.java | 33 + .../ExportConfigurationServiceEndPoint.java | 17 +++-- .../ImportConfigurationServiceEndPoint.java | 11 ++- .../router/rest/PartialContentException.java| 74 .../resources/OSGI-INF/blueprint/blueprint.xml | 4 ++ 5 files changed, 131 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/be379f8e/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ConfigRestExceptionMapper.java -- diff --git a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ConfigRestExceptionMapper.java b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ConfigRestExceptionMapper.java new file mode 100644 index 000..179f3d4 --- /dev/null +++ b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ConfigRestExceptionMapper.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.unomi.router.rest; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +/** + * Created by amidani on 06/07/2017. + */ +public class ConfigRestExceptionMapper implements ExceptionMapper { + +@Override +public Response toResponse(PartialContentException exception) { +return Response.status(Response.Status.PARTIAL_CONTENT).header("Content-Type", MediaType.TEXT_PLAIN).entity(new String(exception.getMessage())).build(); +} + +} http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/be379f8e/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java -- diff --git a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java index 98dbe18..35d4f34 100644 --- a/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java +++ b/extensions/router/router-rest/src/main/java/org/apache/unomi/router/rest/ExportConfigurationServiceEndPoint.java @@ -32,10 +32,12 @@ import org.slf4j.LoggerFactory; import javax.jws.WebMethod; import javax.jws.WebService; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; @@ -85,11 +87,16 @@ public class ExportConfigurationServiceEndPoint extends AbstractConfigurationSer HttpResponse response = httpClient.execute(httpPut); if (response.getStatusLine().getStatusCode() != 200) { -throw new RuntimeException("Failed : HTTP error code : " -+ response.getStatusLine().getStatusCode()); +logger.error("Failed to update the running config: Please check the acceccibilty to the URI: \n{}", +"http://localhost:; +
[jira] [Resolved] (UNOMI-112) Inconsistent domains set on Apache Unomi context-profile-id cookies
[ https://issues.apache.org/jira/browse/UNOMI-112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Serge Huber resolved UNOMI-112. --- Resolution: Fixed > Inconsistent domains set on Apache Unomi context-profile-id cookies > --- > > Key: UNOMI-112 > URL: https://issues.apache.org/jira/browse/UNOMI-112 > Project: Apache Unomi > Issue Type: Bug > Components: core >Affects Versions: 1.2.0-incubating >Reporter: Serge Huber >Assignee: Serge Huber > Fix For: 1.2.0-incubating > > > In the ContextServlet we set the context-profile-id cookie with an associated > domain, but we do not use that domain anymore in the > MergeProfilesOnPropertyAction when we change the cookie. This leads to > problems in the tracking. > We need to make sure that the same domain is used throughout Apache Unomi. > We can also plan at a later time to support multiple domains, but first we > must correct this problem. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
incubator-unomi git commit: UNOMI-112 Inconsistent domains set on Apache Unomi context-profile-id cookies - Make sure we use the same configuration througout all the code that sets cookies.
Repository: incubator-unomi Updated Branches: refs/heads/master 2c5d5be4e -> 8f6f2472d UNOMI-112 Inconsistent domains set on Apache Unomi context-profile-id cookies - Make sure we use the same configuration througout all the code that sets cookies. Signed-off-by: Serge HuberProject: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/8f6f2472 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/8f6f2472 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/8f6f2472 Branch: refs/heads/master Commit: 8f6f2472d8514462ab47489b8a04146abb4beea1 Parents: 2c5d5be Author: Serge Huber Authored: Wed Jul 5 09:19:21 2017 +0200 Committer: Serge Huber Committed: Wed Jul 5 09:19:31 2017 +0200 -- .../actions/MergeProfilesOnPropertyAction.java | 39 .../resources/OSGI-INF/blueprint/blueprint.xml | 2 + .../org/apache/unomi/web/ContextServlet.java| 29 +++ .../java/org/apache/unomi/web/HttpUtils.java| 8 +--- .../resources/OSGI-INF/blueprint/blueprint.xml | 7 wab/src/main/resources/org.apache.unomi.web.cfg | 8 +++- 6 files changed, 62 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/8f6f2472/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java -- diff --git a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java index 12def48..b908586 100644 --- a/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java +++ b/plugins/baseplugin/src/main/java/org/apache/unomi/plugins/baseplugin/actions/MergeProfilesOnPropertyAction.java @@ -26,10 +26,7 @@ import org.apache.unomi.api.actions.Action; import org.apache.unomi.api.actions.ActionExecutor; import org.apache.unomi.api.actions.ActionPostExecutor; import org.apache.unomi.api.conditions.Condition; -import org.apache.unomi.api.services.DefinitionsService; -import org.apache.unomi.api.services.EventService; -import org.apache.unomi.api.services.PrivacyService; -import org.apache.unomi.api.services.ProfileService; +import org.apache.unomi.api.services.*; import org.apache.unomi.persistence.spi.PersistenceService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,9 +42,9 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor { private static final Logger logger = LoggerFactory.getLogger(MergeProfilesOnPropertyAction.class.getName()); -private final int MAX_COOKIE_AGE_IN_SECONDS = 60 * 60 * 24 * 365 * 10; // 10-years -private int cookieAgeInSeconds = MAX_COOKIE_AGE_IN_SECONDS; private String profileIdCookieName = "context-profile-id"; +private String profileIdCookieDomain; +private int profileIdCookieMaxAgeInSeconds; private ProfileService profileService; @@ -59,9 +56,7 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor { private PrivacyService privacyService; -public void setCookieAgeInSeconds(int cookieAgeInSeconds) { -this.cookieAgeInSeconds = cookieAgeInSeconds; -} +private ConfigSharingService configSharingService; public void setProfileIdCookieName(String profileIdCookieName) { this.profileIdCookieName = profileIdCookieName; @@ -99,7 +94,14 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor { this.definitionsService = definitionsService; } +public void setConfigSharingService(ConfigSharingService configSharingService) { +this.configSharingService = configSharingService; +} + public int execute(Action action, Event event) { +profileIdCookieName = (String) configSharingService.getProperty("profileIdCookieName"); +profileIdCookieDomain = (String) configSharingService.getProperty("profileIdCookieDomain"); +profileIdCookieMaxAgeInSeconds = (Integer) configSharingService.getProperty("profileIdCookieMaxAgeInSeconds"); Profile profile = event.getProfile(); if (profile instanceof Persona || profile.isAnonymousProfile()) { @@ -153,7 +155,7 @@ public class MergeProfilesOnPropertyAction implements ActionExecutor { logger.info("Different users, switch to " + profile.getItemId()); HttpServletResponse httpServletResponse = (HttpServletResponse) event.getAttributes().get(Event.HTTP_RESPONSE_ATTRIBUTE); -sendProfileCookie(profile, httpServletResponse); +