-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from WURFL/develop
Develop
- Loading branch information
Showing
51 changed files
with
301 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Contributing Guidelines | ||
======================= | ||
|
||
The WURFL Cloud Client for Java is released under the GNU GENERAL PUBLIC LICENSE, Version 2.0, as well as the MIT License. | ||
|
||
Contributors agree that any contributions are owned by the copyright holder and that contributors have absolutely no rights to their contributions. | ||
|
||
To get started, sign the [Contributor License Agreement](https://www.clahub.com/agreements/WURFL/wurfl-cloud-client-java). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
code/src/main/java/com/scientiamobile/wurflcloud/DefaultCloudRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** | ||
* Copyright (c) 2015 ScientiaMobile Inc. | ||
* | ||
* The WURFL Cloud Client is intended to be used in both open-source and | ||
* commercial environments. To allow its use in as many situations as possible, | ||
* the WURFL Cloud Client is dual-licensed. You may choose to use the WURFL | ||
* Cloud Client under either the GNU GENERAL PUBLIC LICENSE, Version 2.0, or | ||
* the MIT License. | ||
* | ||
* Refer to the COPYING.txt file distributed with this package. | ||
*/ | ||
package com.scientiamobile.wurflcloud; | ||
|
||
import java.util.Enumeration; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Vector; | ||
|
||
import javax.servlet.http.Cookie; | ||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import com.scientiamobile.wurflcloud.utils.Constants; | ||
|
||
/** | ||
* CloudRequest default implementation. | ||
* | ||
*/ | ||
public final class DefaultCloudRequest implements CloudRequest { | ||
|
||
private final Map<String, String> headers = new HashMap<String, String>(); | ||
|
||
public DefaultCloudRequest(HttpServletRequest servletRequest) throws IllegalArgumentException { | ||
if (servletRequest == null) { | ||
throw new IllegalArgumentException("Error: Servlet request cannot be null."); | ||
} | ||
String userAgentLC = servletRequest.getHeader(Constants.USER_AGENT_LC); | ||
String userAgentUC = servletRequest.getHeader("User-Agent"); | ||
this.headers.put("user-agent", userAgentUC != null ? userAgentUC : userAgentLC); | ||
} | ||
|
||
public DefaultCloudRequest(String userAgent) throws IllegalArgumentException { | ||
this.headers.put(Constants.USER_AGENT_LC, userAgent); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Enumeration<String> getHeaderNames() { | ||
return new Vector<String>(headers.keySet()).elements(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public String getHeader(String name) { | ||
return headers.get(name); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public String getRemoteAddr() { | ||
return null; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public Cookie[] getCookies() { | ||
throw new IllegalStateException("ERROR: Trying to get cookies from a CloudRequest which does not support cookie storage."); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
|
||
/** | ||
* The client request interface | ||
* @version $Id$ | ||
*/ | ||
public interface ICloudClientRequest { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.