mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Remove the use of datastore.Text (#1875)
There doesn't seem to be any reason to do this any more. This data is no longer persisted to datastore.
This commit is contained in:
parent
71024c706d
commit
88e3b5da94
2 changed files with 7 additions and 50 deletions
|
@ -17,12 +17,11 @@ package google.registry.model.smd;
|
|||
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||
import static com.google.common.io.BaseEncoding.base64;
|
||||
|
||||
import com.google.appengine.api.datastore.Text;
|
||||
import com.google.common.base.CharMatcher;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
* Encoded data representation of a {@link SignedMark} object.
|
||||
|
@ -35,31 +34,27 @@ public class EncodedSignedMark extends ImmutableObject implements AbstractSigned
|
|||
|
||||
private static final String ENCODING_DEFAULT = "base64";
|
||||
|
||||
private static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\r\n");
|
||||
|
||||
/** Encoding used for contained data. Default is {@value #ENCODING_DEFAULT}. */
|
||||
@XmlAttribute
|
||||
String encoding;
|
||||
|
||||
/**
|
||||
* Encoded data. This is stored in a Text field rather than a String due to historical reasons,
|
||||
* namely that Objectify cannot autoconvert Strings greater than 500 characters to Text within
|
||||
* {@code Embed} collections.
|
||||
*/
|
||||
@XmlValue
|
||||
@XmlJavaTypeAdapter(RemoveWhitespaceTextAdapter.class)
|
||||
Text encodedData;
|
||||
/** Encoded data. */
|
||||
@XmlValue String encodedData;
|
||||
|
||||
public String getEncoding() {
|
||||
return firstNonNull(encoding, ENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
public String getEncodedData() {
|
||||
return encodedData == null ? "" : encodedData.getValue();
|
||||
return encodedData == null ? "" : WHITESPACE.removeFrom(encodedData);
|
||||
}
|
||||
|
||||
public static EncodedSignedMark create(String encoding, String encodedData) {
|
||||
EncodedSignedMark instance = new EncodedSignedMark();
|
||||
instance.encoding = encoding;
|
||||
instance.encodedData = new Text(encodedData);
|
||||
instance.encodedData = encodedData;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright 2017 The Nomulus Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed 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 google.registry.model.smd;
|
||||
|
||||
import com.google.appengine.api.datastore.Text;
|
||||
import com.google.common.base.CharMatcher;
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
/**
|
||||
* {@link XmlAdapter} which removes all whitespace from a string and then converts the result a
|
||||
* {@link Text} object.
|
||||
*/
|
||||
public class RemoveWhitespaceTextAdapter extends XmlAdapter<String, Text> {
|
||||
|
||||
private static final CharMatcher WHITESPACE = CharMatcher.anyOf(" \t\r\n");
|
||||
|
||||
@Override
|
||||
public Text unmarshal(String value) {
|
||||
return (value == null) ? null : new Text(WHITESPACE.removeFrom(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String marshal(Text t) {
|
||||
return (t == null) ? null : t.getValue();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue