Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 15 additions & 40 deletions cda-gui/package-lock.json

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this because it does not appear the packages are also being updated. Even then it looks unrelated to the rest of your PR.

I suspect you had an old lock file and have not ran npm install in the CDA gui dir and this is resulting in a previous lock file trying to commit?

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions cwms-data-api/src/main/java/cwms/cda/formatters/ContentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import java.util.Map;
import java.util.Objects;

/**
* Stores an instance of ContentType and it's parameters.
* Example <pre>application/json;q=1</pre> is different than <pre>application/json;q=2</pre>
*/
public class ContentType implements Comparable<ContentType> {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
public static final String PARAM_DELIM = ";";
Expand All @@ -13,8 +17,13 @@ public class ContentType implements Comparable<ContentType> {
private final String mediaType;
private final Map<String, String> parameters;

private String charset = null;
private String instanceCharset = null;

/**
* Create a ContentType instance given the provide ContentType or Accept Header.
* The contructor will parse query parameters out of the provided string.
* @param contentTypeHeader provided ContentType or Accept header text
*/
public ContentType(String contentTypeHeader) {
parameters = new LinkedHashMap<>();
String[] parts = contentTypeHeader.split(PARAM_DELIM);
Expand All @@ -26,7 +35,7 @@ public ContentType(String contentTypeHeader) {
String key = keyVal[0].trim();
String value = keyVal[1].trim();
if (CHARSET.equalsIgnoreCase(key)) {
charset = value;
instanceCharset = value;
} else {
parameters.put(key, value);
}
Expand All @@ -43,17 +52,19 @@ public Map<String, String> getParameters() {
return new LinkedHashMap<>(parameters);
}

public String getCharset() {
return charset;
public String getInstanceCharset() {
return instanceCharset;
Comment on lines +55 to +56

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there tests this could break renaming the getter here?

Rest looks formatting related but this is an API change

}

/**
* For the purposes of cwms-data-api content-type equals we only care about the following
* fields matching:
*
* fields matching.
*
* <p>
* - the mimetype itself
* - the version parameter
*
*
* <p>
* For us everything else is informational or used indirectly
*/
@Override
Expand All @@ -67,7 +78,7 @@ public boolean equals(Object other) {
return false;
}

/** We loop through instead of using contains key.
/* We loop through instead of using contains key.
* Content-type parameter names are not case sensitive.
*/
for (Map.Entry<String, String> entry : parameters.entrySet()) {
Expand Down Expand Up @@ -116,7 +127,7 @@ public String toString() {
/**
* Used for quick comparisons where we don't further need the content type
* so we can streamline the code a little.
*
*
* @param a first content type to check
* @param b second content type to check
* @return whether they are equivalent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@

import cwms.cda.data.dto.CwmsDTOBase;
import cwms.cda.formatters.annotations.FormattableWith;
import org.jetbrains.annotations.NotNull;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jetbrains.annotations.NotNull;

final class ContentTypeAliasMap {
private final Map<ContentType, ContentType> contentTypeMap = new ConcurrentHashMap<>();
private static final Map<Class<? extends CwmsDTOBase>, ContentTypeAliasMap> ALIAS_MAP = new ConcurrentHashMap<>();

private ContentTypeAliasMap()
{
private ContentTypeAliasMap() {
}

private ContentTypeAliasMap(Class<? extends CwmsDTOBase> dtoClass) {
Expand Down
Loading
Loading