Skip to content

Commit

Permalink
Ditto 3.0 preparation: removed deprecated marked code and adjusted ja…
Browse files Browse the repository at this point in the history
…picmp excludes accordingly

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Aug 2, 2022
1 parent 19444ff commit 15f6be0
Show file tree
Hide file tree
Showing 54 changed files with 61 additions and 691 deletions.
4 changes: 4 additions & 0 deletions base/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@
<!--<exclude></exclude>-->
<exclude>org.eclipse.ditto.base.model.signals.commands.exceptions</exclude>
<exclude>org.eclipse.ditto.base.model.headers.DittoHeaderDefinition#POLICY_ENFORCER_INVALIDATED_PREEMPTIVELY</exclude>
<exclude>org.eclipse.ditto.base.model.entity.id.RegexPatterns</exclude>
<exclude>org.eclipse.ditto.base.model.exceptions.DittoHeaderInvalidException#newCustomMessageBuilder(java.lang.String)</exclude>
<exclude>org.eclipse.ditto.base.model.namespaces.signals.commands.PurgeNamespaceResponse$JsonFields</exclude>
<exclude>org.eclipse.ditto.base.model.signals.commands.CommandResponseJsonDeserializer</exclude>
</excludes>
</parameter>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,50 +69,13 @@ public final class RegexPatterns {
public static final String ALLOWED_NAMESPACE_CHARACTERS_REGEX_INNER =
"[.-]" + ALLOWED_NAMESPACE_CHARACTERS_REGEX;

/**
* @deprecated Use {@link #ALLOWED_NAMESPACE_CHARACTERS_REGEX_INNER}. The name of the variable actually described
* the content, which has now changed. The name new describes the purpose.
*/
@Deprecated
public static final String ALLOWED_NAMESPACE_CHARACTERS_INCLUDING_DOT = ALLOWED_NAMESPACE_CHARACTERS_REGEX_INNER;

/**
* The regex pattern for namespaces which validates that the namespace conforms the java package notation.
*/
public static final String NAMESPACE_REGEX = "(?<" + NAMESPACE_GROUP_NAME + ">|(?:" +
"(?:" + ALLOWED_NAMESPACE_CHARACTERS_REGEX + ")" +
"(?:" + ALLOWED_NAMESPACE_CHARACTERS_REGEX_INNER + ")*+))";

/**
* Regex pattern that matches URL escapes. E.G. %3A for a colon (':').
* @deprecated since 2.4.0
*/
@Deprecated
public static final String URL_ESCAPES = "%\\p{XDigit}{2}";

/**
* Adds the $ to allowed characters. Its defined as separate constant because names are not allowed to start
* with $.
* @deprecated since 2.4.0
*/
@Deprecated
public static final String ALLOWED_CHARACTERS_IN_NAME_INCLUDING_DOLLAR = ALLOWED_CHARACTERS_IN_NAME + "$";

/**
* First part of an entity name.
* @deprecated since 2.4.0
*/
@Deprecated
public static final String URI_PATH_SEGMENT = "(?:[" + ALLOWED_CHARACTERS_IN_NAME + "]|" + URL_ESCAPES + ")";

/**
* Second part of an entity name: This part allows the $ symbol.
* @deprecated since 2.4.0
*/
@Deprecated
public static final String URI_PATH_SEGMENT_INCLUDING_DOLLAR =
"(?:[" + ALLOWED_CHARACTERS_IN_NAME_INCLUDING_DOLLAR + "]|" + URL_ESCAPES + ")";

/**
* The regex pattern for an Entity Name.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,6 @@ public static DittoHeaderInvalidException.Builder newInvalidTypeBuilder(final He
return new DittoHeaderInvalidException.Builder(headerDefinition.getKey(), headerValue, headerType);
}

/**
* A mutable builder for a {@code DittoHeaderInvalidException} with a custom message.
*
* @param customMessage the custom message
* @return the builder.
* @deprecated as of Ditto 2.0 please use {@code newBuilder().message(String)}.
*/
@Deprecated
public static DittoHeaderInvalidException.Builder newCustomMessageBuilder(final String customMessage) {
return new DittoHeaderInvalidException.Builder(customMessage);
}

/**
* Returns a new mutable builder with a fluent API for creating a {@code DittoHeaderInvalidException}.
* The returned builder is initialized with a default message and a default description.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@

import org.eclipse.ditto.base.model.common.HttpStatus;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableCommandResponse;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.CommandResponseHttpStatusValidator;
import org.eclipse.ditto.base.model.signals.commands.CommandResponseJsonDeserializer;
import org.eclipse.ditto.json.JsonFieldDefinition;
import org.eclipse.ditto.json.JsonObject;

/**
Expand Down Expand Up @@ -112,7 +109,6 @@ public static PurgeNamespaceResponse failed(final CharSequence namespace,
* <ul>
* <li>{@link NamespaceCommandResponse.JsonFields#NAMESPACE},</li>
* <li>{@link NamespaceCommandResponse.JsonFields#RESOURCE_TYPE} or</li>
* <li>{@link PurgeNamespaceResponse.JsonFields#SUCCESSFUL}.</li>
* </ul>
*/
public static PurgeNamespaceResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) {
Expand Down Expand Up @@ -167,30 +163,4 @@ public String toString() {
return getClass().getSimpleName() + " [" + super.toString() + ", successful=" + isSuccessful() + "]";
}

/**
* This class contains definitions for all specific fields of a {@code PurgeNamespaceResponse}'s JSON
* representation.
*
* @deprecated as of 2.3.0 there are no additional JSON fields for {@code PurgeNamespaceResponse}.
*/
@Deprecated
@Immutable
public static final class JsonFields extends NamespaceCommandResponse.JsonFields {

/**
* This JSON field indicates whether the namespace was purged successfully.
*
* @deprecated as of 2.3.0 this field is not used anymore as the success
* status is derived from HTTP status code.
*/
@Deprecated
public static final JsonFieldDefinition<Boolean> SUCCESSFUL =
JsonFieldDefinition.ofBoolean("successful", FieldType.REGULAR, JsonSchemaVersion.V_2);

private JsonFields() {
throw new AssertionError();
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,60 +29,26 @@

/**
* This class helps to deserialize JSON to a sub-class of {@link CommandResponse}. Hereby this class extracts the
* values which are common for all command responses. All remaining required values have to be extracted in
* {@link CommandResponseJsonDeserializer.FactoryMethodFunction#create(org.eclipse.ditto.base.model.common.HttpStatus)}.
* There the actual command response object is created, too.
* values which are common for all command responses.
*/
public final class CommandResponseJsonDeserializer<T extends CommandResponse<?>> {

@Nullable private final JsonObject jsonObject;
private final String expectedCommandResponseType;
private final DeserializationFunction<T> deserializationFunction;

private CommandResponseJsonDeserializer(final CharSequence type,
@Nullable final JsonObject jsonObject,
final DeserializationFunction<T> deserializationFunction) {

this.jsonObject = jsonObject;
expectedCommandResponseType = ConditionChecker.checkArgument(checkNotNull(type, "type").toString(),
arg -> !arg.trim().isEmpty(),
() -> "The type must not be empty or blank.");
this.deserializationFunction = deserializationFunction;
}

/**
* Constructs a new {@code CommandResponseJsonDeserializer} object.
*
* @param type the type of the command response.
* @param jsonObject the JSON object to deserialize.
* @throws NullPointerException if any argument is {@code null}.
* @throws IllegalArgumentException if {@code type} is empty or blank.
* @deprecated as of 2.3.0 please use {@link #newInstance(CharSequence, DeserializationFunction)} instead.
*/
@Deprecated
public CommandResponseJsonDeserializer(final String type, final JsonObject jsonObject) {
this(type, checkJsonObjectNotNull(jsonObject), null);
}

private static JsonObject checkJsonObjectNotNull(@Nullable final JsonObject jsonObject) {
return checkNotNull(jsonObject, "jsonObject");
}

/**
* Constructs a new {@code CommandResponseJsonDeserializer} object.
*
* @param type the type of the target command response of deserialization.
* @param jsonString the JSON string to be deserialized.
* @throws NullPointerException if any argument is {@code null}.
* @throws IllegalArgumentException if {@code type} is empty or blank or if {@code jsonString} is empty.
* @throws org.eclipse.ditto.json.JsonParseException if {@code jsonString} does not contain a valid JSON object.
* @deprecated as of 2.3.0 please use {@link #newInstance(CharSequence, DeserializationFunction)} instead.
*/
@Deprecated
public CommandResponseJsonDeserializer(final String type, final String jsonString) {
this(type, JsonObject.of(jsonString));
}

/**
* Returns a new instance of {@code CommandResponseJsonDeserializer}.
*
Expand All @@ -99,33 +65,10 @@ public CommandResponseJsonDeserializer(final String type, final String jsonStrin
public static <T extends CommandResponse<?>> CommandResponseJsonDeserializer<T> newInstance(final CharSequence type,
final DeserializationFunction<T> deserializationFunction) {

return new CommandResponseJsonDeserializer(type,
null,
return new CommandResponseJsonDeserializer<>(type,
checkNotNull(deserializationFunction, "deserializationFunction"));
}

/**
* Partly deserializes the JSON which was given to this object's constructor. The factory method function which is
* given to this method is responsible for creating the actual {@code CommandResponseType}. This method receives
* the partly deserialized values which can be completed by implementors if further values are required.
*
* @param factoryMethodFunction creates the actual {@code CommandResponseType} object.
* @return the command response.
* @throws NullPointerException if {@code factoryMethodFunction} is {@code null}.
* @throws org.eclipse.ditto.json.JsonParseException if the JSON is invalid or if the command response type
* differs from the expected one.
* @deprecated as of 2.3.0 please use {@link #deserialize(JsonObject, DittoHeaders)} instead.
*/
@Deprecated
public T deserialize(final FactoryMethodFunction<T> factoryMethodFunction) {
final CommandResponseJsonDeserializer<T> deserializer =
new CommandResponseJsonDeserializer<>(expectedCommandResponseType,
checkJsonObjectNotNull(jsonObject),
context -> factoryMethodFunction.create(context.getDeserializedHttpStatus()));

return deserializer.deserialize(jsonObject, DittoHeaders.empty());
}

/**
* Deserializes the specified {@code JsonObject} argument to an instance of {@code CommandResponse}.
* Any exception that is thrown during deserialization will be subsumed as cause of a {@code JsonParseException}.
Expand Down Expand Up @@ -177,28 +120,6 @@ private JsonParseException newJsonParseException(final Exception cause) {
.build();
}

/**
* Represents a function that accepts three arguments to produce a {@code CommandResponse}. The arguments were
* extracted from a given JSON beforehand.
*
* @param <T> the type of the result of the function.
* @deprecated as of 2.3.0 please use {@link DeserializationFunction} instead.
*/
@Deprecated
@FunctionalInterface
public interface FactoryMethodFunction<T extends CommandResponse<?>> {

/**
* Creates a {@code CommandResponse} with the help of the given arguments.
*
* @param httpStatus the HTTP status of the response.
* @return the command response.
* @since 2.0.0
*/
T create(HttpStatus httpStatus);

}

/**
* Function that actually deserializes a {@code CommandResponse} from a provided {@link DeserializationContext}.
*
Expand Down
14 changes: 14 additions & 0 deletions connectivity/model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@
<excludes>
<!-- Don't add excludes here before checking with the whole Ditto team -->
<!--<exclude></exclude>-->
<exclude>org.eclipse.ditto.connectivity.model.AddressMetric$JsonFields</exclude>
<exclude>org.eclipse.ditto.connectivity.model.Connection#getUsername()</exclude>
<exclude>org.eclipse.ditto.connectivity.model.Connection#getPassword()</exclude>
<exclude>org.eclipse.ditto.connectivity.model.Connection$JsonFields#SCHEMA_VERSION</exclude>
<exclude>org.eclipse.ditto.connectivity.model.ConnectivityModelFactory#newClientStatus(java.lang.String,org.eclipse.ditto.connectivity.model.ConnectivityStatus,java.lang.String,java.time.Instant)</exclude>
<exclude>org.eclipse.ditto.connectivity.model.LogEntry#getThingId()</exclude>
<exclude>org.eclipse.ditto.connectivity.model.LogEntry$JsonFields#THING_ID</exclude>
<exclude>org.eclipse.ditto.connectivity.model.LogEntryBuilder#thingId(org.eclipse.ditto.things.model.ThingId)</exclude>
<exclude>org.eclipse.ditto.connectivity.model.ResourceStatus$JsonFields#SCHEMA_VERSION</exclude>
<exclude>org.eclipse.ditto.connectivity.model.Source$JsonFields#SCHEMA_VERSION</exclude>
<exclude>org.eclipse.ditto.connectivity.model.SourceMetrics$JsonFields#SCHEMA_VERSION</exclude>
<exclude>org.eclipse.ditto.connectivity.model.SshTunnel$JsonFields#SCHEMA_VERSION</exclude>
<exclude>org.eclipse.ditto.connectivity.model.Target$JsonFields#SCHEMA_VERSION</exclude>
<exclude>org.eclipse.ditto.connectivity.model.TargetMetrics$JsonFields#SCHEMA_VERSION</exclude>
</excludes>
</parameter>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@

import java.util.Set;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.json.Jsonifiable;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonFieldDefinition;
import org.eclipse.ditto.json.JsonFieldSelector;
import org.eclipse.ditto.json.JsonObject;

Expand Down Expand Up @@ -50,35 +46,4 @@ default JsonObject toJson(final JsonSchemaVersion schemaVersion, final JsonField
return toJson(schemaVersion, FieldType.notHidden()).get(fieldSelector);
}

/**
* An enumeration of the known {@code JsonField}s of an {@code AddressMetric}.
*/
@Immutable
final class JsonFields {

/**
* JSON field containing the {@code JsonSchemaVersion}.
*
* @deprecated as of 2.3.0 this field definition is not used anymore.
*/
@Deprecated
public static final JsonFieldDefinition<Integer> SCHEMA_VERSION = JsonFactory.newIntFieldDefinition(
JsonSchemaVersion.getJsonKey(),
FieldType.SPECIAL,
FieldType.HIDDEN,
JsonSchemaVersion.V_2
);

/**
* JSON field containing the timestamp when the last message was consumed/published.
*/
public static final JsonFieldDefinition<String> LAST_MESSAGE_AT =
JsonFactory.newStringFieldDefinition("lastMessageAt", FieldType.REGULAR,
JsonSchemaVersion.V_2);

private JsonFields() {
throw new AssertionError();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,6 @@ public interface Connection extends Jsonifiable.WithFieldSelectorAndPredicate<Js
*/
String getProtocol();


/**
* Returns the username part of the URI of this {@code Connection}.
*
* @return the username.
* @deprecated since 2.4.0 use {@link #getUsername(boolean)} instead.
*/
Optional<String> getUsername();

/**
* Returns the username part of the URI of this {@code Connection}.
*
Expand All @@ -148,14 +139,6 @@ public interface Connection extends Jsonifiable.WithFieldSelectorAndPredicate<Js
*/
Optional<String> getUsername(boolean shouldUriDecode);

/**
* Returns the password part of the URI of this {@code Connection}.
*
* @return the password.
* @deprecated since 2.4.0 use {@link #getPassword(boolean)} instead.
*/
Optional<String> getPassword();

/**
* Returns the password part of the URI of this {@code Connection}.
*
Expand Down Expand Up @@ -270,19 +253,6 @@ default JsonObject toJson(final JsonSchemaVersion schemaVersion, final JsonField
@Immutable
final class JsonFields {

/**
* JSON field containing the {@code JsonSchemaVersion}.
*
* @deprecated as of 2.3.0 this field definition is not used anymore.
*/
@Deprecated
public static final JsonFieldDefinition<Integer> SCHEMA_VERSION = JsonFactory.newIntFieldDefinition(
JsonSchemaVersion.getJsonKey(),
FieldType.SPECIAL,
FieldType.HIDDEN,
JsonSchemaVersion.V_2
);

/**
* JSON field containing the Connection's lifecycle.
*/
Expand Down
Loading

0 comments on commit 15f6be0

Please sign in to comment.