1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 02:27:58 +01:00

Bump ErrorProne to 2.5.1 and refactor Providers a bit

This also resulted in a refactoring of the Providers and parsing
Exceptions. NumberFormatException and ParseException can now be thrown
directly, the wrapping in a SmackParsingException is down at a higher
layer, i.e. in AbstractProvider.
This commit is contained in:
Florian Schmaus 2021-01-28 22:05:47 +01:00
parent 1df0763f92
commit a7b3303f3e
136 changed files with 574 additions and 551 deletions

View file

@ -12,7 +12,7 @@ buildscript {
plugins {
id 'ru.vyarus.animalsniffer' version '1.5.0'
id 'net.ltgt.errorprone' version '1.1.1'
id 'net.ltgt.errorprone' version '1.3.0'
// Use e.g. "gradle <task> taskTree" to show its dependency tree.
id 'com.dorongold.task-tree' version '1.5'
id 'com.github.kt3k.coveralls' version '2.10.2'
@ -218,6 +218,8 @@ allprojects {
// Disabled but should be re-enabled at some point
//'-Xep:InconsistentCapitalization:OFF',
'-Xep:MixedMutabilityReturnType:OFF',
// TODO: Re-enable once Smack's minimum Android SDK level is 26 or higher.
'-Xep:JavaUtilDate:OFF',
]
}
}
@ -293,7 +295,7 @@ tasks.withType(Javadoc) {
testImplementation 'org.mockito:mockito-inline:3.3.3'
testImplementation 'com.jamesmurty.utils:java-xmlbuilder:1.2'
errorprone 'com.google.errorprone:error_prone_core:2.3.4'
errorprone 'com.google.errorprone:error_prone_core:2.5.1'
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2017 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.jivesoftware.smackx.ping.android;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.logging.Logger;
@ -113,14 +112,14 @@ public final class ServerPingWithAlarmManager extends Manager {
@Override
public void onReceive(Context context, Intent intent) {
LOGGER.fine("Ping Alarm broadcast received");
Set<Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
Set<Map.Entry<XMPPConnection, ServerPingWithAlarmManager>> managers;
synchronized (ServerPingWithAlarmManager.class) {
// Make a copy to avoid ConcurrentModificationException when
// iterating directly over INSTANCES and the Set is modified
// concurrently by creating a new ServerPingWithAlarmManager.
managers = new HashSet<>(INSTANCES.entrySet());
}
for (Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
for (Map.Entry<XMPPConnection, ServerPingWithAlarmManager> entry : managers) {
XMPPConnection connection = entry.getKey();
if (entry.getValue().isEnabled()) {
LOGGER.fine("Calling pingServerIfNecessary for connection "

View file

@ -249,7 +249,6 @@ public final class SASLAuthentication {
* Notification message saying that SASL authentication was successful. The next step
* would be to bind the resource.
* @param success result of the authentication.
* @throws SmackException if Smack detected an exceptional situation.
* @throws InterruptedException if the calling thread was interrupted.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws SmackSaslException if a SASL specific error occurred.

View file

@ -343,7 +343,7 @@ public final class StanzaCollector implements AutoCloseable {
*
* @param packet the stanza to process.
*/
protected void processStanza(Stanza packet) {
void processStanza(Stanza packet) {
if (packetFilter == null || packetFilter.accept(packet)) {
synchronized (this) {
if (resultQueue.size() == maxQueueSize) {

View file

@ -99,7 +99,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
private boolean featuresReceived;
protected boolean streamResumed;
private boolean streamResumed;
private GraphVertex<State> currentStateVertex;
@ -264,7 +264,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
walkStateGraph(walkStateGraphContext);
}
protected WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
private WalkStateGraphContext.Builder buildNewWalkTo(Class<? extends StateDescriptor> finalStateClass) {
return WalkStateGraphContext.builder(currentStateVertex.getElement().getStateDescriptor().getClass(), finalStateClass);
}
@ -279,7 +279,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
revertedState.resetState();
}
protected void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
private void walkStateGraph(WalkStateGraphContext walkStateGraphContext)
throws XMPPException, IOException, SmackException, InterruptedException {
// Save a copy of the current state
GraphVertex<State> previousStateVertex = currentStateVertex;
@ -491,7 +491,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
}
}
protected SSLSession getSSLSession() {
private SSLSession getSSLSession() {
final XmppClientToServerTransport transport = activeTransport;
if (transport == null) {
return null;
@ -505,7 +505,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
notifyWaitingThreads();
}
protected void parseAndProcessElement(String element) {
private void parseAndProcessElement(String element) {
try {
XmlPullParser parser = PacketParserUtils.getParserFor(element);
@ -556,11 +556,11 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
}
}
protected synchronized void prepareToWaitForFeaturesReceived() {
private synchronized void prepareToWaitForFeaturesReceived() {
featuresReceived = false;
}
protected void waitForFeaturesReceived(String waitFor)
private void waitForFeaturesReceived(String waitFor)
throws InterruptedException, SmackException, XMPPException {
waitForConditionOrThrowConnectionException(() -> featuresReceived, waitFor);
}
@ -571,7 +571,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
return streamOpenAndCloseFactory.createStreamOpen(to, from, id, lang);
}
protected void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
private void newStreamOpenWaitForFeaturesSequence(String waitFor) throws InterruptedException,
SmackException, XMPPException {
prepareToWaitForFeaturesReceived();
@ -1028,7 +1028,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
return connectionStateMachineListeners.remove(connectionStateMachineListener);
}
protected void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
private void invokeConnectionStateMachineListener(ConnectionStateEvent connectionStateEvent) {
if (connectionStateMachineListeners.isEmpty()) {
return;
}
@ -1056,7 +1056,7 @@ public final class ModularXmppClientToServerConnection extends AbstractXMPPConne
walkStateGraph(walkStateGraphContext);
}
protected Map<String, Object> getFilterStats() {
private Map<String, Object> getFilterStats() {
Collection<XmppInputOutputFilter> filters;
synchronized (this) {
if (inputOutputFilters.isEmpty() && previousInputOutputFilters != null) {

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.util.Objects;
* @author Alexander Wenckus
*
*/
@SuppressWarnings("BadImport")
public final class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
public static final StanzaFilter GET = new IQTypeFilter(Type.get);

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.packet.Message.Type;
* @see org.jivesoftware.smack.packet.Message.Type
* @author Ward Harold
*/
@SuppressWarnings("BadImport")
public final class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> {
public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2014 Florian Schmaus
* Copyright 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,6 +24,7 @@ import org.jivesoftware.smack.util.Objects;
* A filter for Presence types. Returns true only if the stanza is an Presence stanza and it matches the type provided in the
* constructor.
*/
@SuppressWarnings("BadImport")
public final class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> {
public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015 Florian Schmaus
* Copyright 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.jivesoftware.smack.iqrequest;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
/**
* Convenience class to create IQ requests handlers.
@ -26,10 +25,10 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
private final String element;
private final String namespace;
private final Type type;
private final IQ.Type type;
private final Mode mode;
protected AbstractIqRequestHandler(String element, String namespace, Type type, Mode mode) {
protected AbstractIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
switch (type) {
case set:
case get:
@ -52,7 +51,7 @@ public abstract class AbstractIqRequestHandler implements IQRequestHandler {
}
@Override
public Type getType() {
public IQ.Type getType() {
return type;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2020 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -34,12 +34,24 @@ public class SmackParsingException extends Exception {
super(message);
}
/**
* Deprecated, do not import.
* @deprecated do not import.
*/
@Deprecated
// TODO: Remove in Smack 4.6.
public static class SmackTextParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Deprecated, do not use.
* @param parsingException the exception.
* @deprecated do not use, simply throw ParseException.
*/
@Deprecated
public SmackTextParseException(ParseException parsingException) {
super(parsingException);
}

View file

@ -16,11 +16,15 @@
*/
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.xml.XmlPullParserException;
public class AbstractProvider<E extends Element> {
@ -55,4 +59,51 @@ public class AbstractProvider<E extends Element> {
public final Class<E> getElementClass() {
return elementClass;
}
public static final class TextParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
private final ParseException parseException;
private TextParseException(ParseException parseException) {
super(parseException);
this.parseException = parseException;
}
public ParseException getParseException() {
return parseException;
}
}
public static final class NumberFormatParseException extends SmackParsingException {
/**
*
*/
private static final long serialVersionUID = 1L;
private NumberFormatParseException(NumberFormatException numberFormatException) {
super(numberFormatException);
}
}
protected interface WrappableParser<E> {
E parse() throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}
protected static <E> E wrapExceptions(WrappableParser<E> parser)
throws XmlPullParserException, IOException, SmackParsingException {
E e;
try {
e = parser.parse();
} catch (ParseException parseException) {
throw new TextParseException(parseException);
} catch (NumberFormatException numberFormatException) {
throw new NumberFormatParseException(numberFormatException);
}
return e;
}
}

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
@ -50,7 +51,7 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
I e = parse(parser, initialDepth, xmlEnvironment);
I e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
@ -59,11 +60,12 @@ public abstract class IQProvider<I extends IQ> extends IqProvider<I> {
@Override
public final I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
// Old-style IQ parsers do not need IqData.
return parse(parser, initialDepth, xmlEnvironment);
}
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
public abstract I parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -117,7 +117,7 @@ public class IntrospectionProvider{
* @param type the type of the property.
* @param value the encode String value to decode.
* @return the String value decoded into the specified type.
* @throws ClassNotFoundException
* @throws ClassNotFoundException if the provided class was not found.
*/
private static Object decode(Class<?> type, String value) throws ClassNotFoundException {
String name = type.getName();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
@ -37,10 +38,12 @@ public abstract class IqProvider<I extends IQ> extends AbstractProvider<I> {
final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
return parse(parser, initialDepth, iqData, xmlEnvironment);
I i = wrapExceptions(() -> parse(parser, initialDepth, iqData, xmlEnvironment));
return i;
}
public abstract I parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException;
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@
package org.jivesoftware.smack.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -50,12 +51,13 @@ public abstract class Provider<E extends Element> extends AbstractProvider<E> {
final int initialDepth = parser.getDepth();
final XmlEnvironment xmlEnvironment = XmlEnvironment.from(parser, outerXmlEnvironment);
E e = parse(parser, initialDepth, xmlEnvironment);
E e = wrapExceptions(() -> parse(parser, initialDepth, xmlEnvironment));
// XPP3 calling convention assert: Parser should be at end tag of the consumed/parsed element
ParserUtils.forwardToEndTagOfDepth(parser, initialDepth);
return e;
}
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
public abstract E parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2014-2020 Florian Schmaus
* Copyright 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +26,6 @@ import java.util.Random;
import javax.security.auth.callback.CallbackHandler;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.SmackSaslException;
import org.jivesoftware.smack.sasl.SASLMechanism;
import org.jivesoftware.smack.util.ByteUtils;
@ -263,6 +262,7 @@ public abstract class ScramMechanism extends SASLMechanism {
}
/**
* Get the channel binding data.
*
* @return the Channel Binding data.
* @throws SmackSaslException if a SASL specific error occurred.
@ -361,7 +361,7 @@ public abstract class ScramMechanism extends SASLMechanism {
* @param key TODO javadoc me please
* @param str TODO javadoc me please
* @return the HMAC-SHA1 value of the input.
* @throws SmackException if Smack detected an exceptional situation.
* @throws SmackSaslException if Smack detected an exceptional situation.
*/
private byte[] hmac(byte[] key, byte[] str) throws SmackSaslException {
try {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2015-2020 Florian Schmaus
* Copyright © 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
@ -251,7 +250,7 @@ public class MultiMap<K, V> {
public MultiMap<K, V> asUnmodifiableMultiMap() {
LinkedHashMap<K, List<V>> mapCopy = new LinkedHashMap<>(map.size());
for (Entry<K, List<V>> entry : map.entrySet()) {
for (Map.Entry<K, List<V>> entry : map.entrySet()) {
K key = entry.getKey();
List<V> values = entry.getValue();
@ -266,7 +265,7 @@ public class MultiMap<K, V> {
Map<K, List<V>> clonedMap = new LinkedHashMap<>(map.size());
// TODO: Use Map.forEach() once Smack's minimum Android API is 24 or higher.
for (Entry<K, List<V>> entry : map.entrySet()) {
for (Map.Entry<K, List<V>> entry : map.entrySet()) {
List<V> clonedList = CollectionUtil.newListWith(entry.getValue());
clonedMap.put(entry.getKey(), clonedList);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,7 +30,6 @@ import org.jivesoftware.smack.datatypes.UInt32;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.RequiredAttributeMissingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
@ -308,30 +307,23 @@ public class ParserUtils {
return s;
}
public static Date getDateFromOptionalXep82String(String dateString) throws SmackTextParseException {
public static Date getDateFromOptionalXep82String(String dateString) throws ParseException {
if (dateString == null) {
return null;
}
return getDateFromXep82String(dateString);
}
public static Date getDateFromXep82String(String dateString) throws SmackTextParseException {
try {
return XmppDateTime.parseXEP0082Date(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
public static Date getDateFromXep82String(String dateString) throws ParseException {
return XmppDateTime.parseXEP0082Date(dateString);
}
public static Date getDateFromString(String dateString) throws SmackTextParseException {
try {
return XmppDateTime.parseDate(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
public static Date getDateFromString(String dateString) throws ParseException {
return XmppDateTime.parseDate(dateString);
}
public static Date getDateFromNextText(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
public static Date getDateFromNextText(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
String dateString = parser.nextText();
return getDateFromString(dateString);
}

View file

@ -104,6 +104,8 @@ public class Base32 {
for (int j = 0; j < blocklen; j++)
ds.writeByte((byte) (t[j] & 0xFF));
} catch (IOException e) {
// This should not happen.
throw new AssertionError(e);
}
}

View file

@ -53,7 +53,7 @@ public class ConnectionConfigurationTest {
private static final class DummyConnectionConfiguration extends ConnectionConfiguration {
protected DummyConnectionConfiguration(Builder builder) {
DummyConnectionConfiguration(Builder builder) {
super(builder);
}

View file

@ -20,17 +20,14 @@ import static org.junit.Assert.assertEquals;
import java.util.Map;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.packet.StanzaError.Type;
import org.junit.Test;
public class XMPPErrorTest {
@Test
public void testConditionHasDefaultTypeMapping() throws NoSuchFieldException, IllegalAccessException {
Map<Condition, Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
Map<StanzaError.Condition, StanzaError.Type> conditionToTypeMap = StanzaError.CONDITION_TO_TYPE;
assertEquals("CONDITION_TO_TYPE map is likely out of sync with Condition enum",
Condition.values().length,
StanzaError.Condition.values().length,
conditionToTypeMap.size());
}
}

View file

@ -0,0 +1,70 @@
/**
*
* Copyright 2021 Florian Schmaus.
*
* 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 org.jivesoftware.smack.provider;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.junit.jupiter.api.Test;
public class AbstractProviderTest {
private static final ExtensionElementProvider<ExtensionElement> NUMBER_FORMAT_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
throw new NumberFormatException();
}
};
private static final String MESSAGE = "dummy message";
private static final int VALUE = 14768234;
private static final ExtensionElementProvider<ExtensionElement> PARSE_EXCEPTION_THROWING_PROVIDER = new ExtensionElementProvider<ExtensionElement>() {
@Override
public ExtensionElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
throw new ParseException(MESSAGE, VALUE);
}
};
@Test
public void testWrapsNumberFormatException() throws XmlPullParserException, IOException {
XmlPullParser parser = SmackTestUtil.createDummyParser();
assertThrows(AbstractProvider.NumberFormatParseException.class,
() -> NUMBER_FORMAT_THROWING_PROVIDER.parse(parser));
}
@Test
public void testWrapsParseException() throws XmlPullParserException, IOException {
XmlPullParser parser = SmackTestUtil.createDummyParser();
AbstractProvider.TextParseException testParseException = assertThrows(AbstractProvider.TextParseException.class,
() -> PARSE_EXCEPTION_THROWING_PROVIDER.parse(parser));
ParseException parseException = testParseException.getParseException();
assertEquals(MESSAGE, parseException.getMessage());
assertEquals(VALUE, parseException.getErrorOffset());
}
}

View file

@ -24,7 +24,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
@ -58,7 +57,7 @@ public class ThreadedDummyConnection extends DummyConnection {
replyPacket.setStanzaId(packet.getStanzaId());
replyPacket.setTo(packet.getFrom());
if (replyPacket.getType() == null) {
replyPacket.setType(Type.result);
replyPacket.setType(IQ.Type.result);
}
new ProcessQueue(replyQ).start();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,6 +30,7 @@ import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.Provider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParserFactory;
@ -125,6 +126,11 @@ public class SmackTestUtil {
return parser;
}
public static XmlPullParser createDummyParser() throws XmlPullParserException, IOException {
String dummyElement = "<empty-element/>";
return PacketParserUtils.getParserFor(dummyElement);
}
@SuppressWarnings("unchecked")
private static <E extends Element, P extends Provider<E>> P providerClassToProvider(Class<P> providerClass) {
P provider;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus.
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.carbons.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.forward.provider.ForwardedProvider;
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
@Override
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public CarbonExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Direction dir = Direction.valueOf(parser.getName());
Forwarded<Message> fwd = null;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019 Florian Schmaus
* Copyright 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +31,6 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.packet.StanzaError.Type;
import org.jivesoftware.smack.util.RandomUtil;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -89,7 +88,7 @@ public final class DnsOverXmppManager extends Manager {
response = resolver.resolve(query);
} catch (IOException exception) {
StanzaError errorBuilder = StanzaError.getBuilder()
.setType(Type.CANCEL)
.setType(StanzaError.Type.CANCEL)
.setCondition(Condition.internal_server_error)
.setDescriptiveEnText("Exception while resolving your DNS query", exception)
.build()

View file

@ -27,7 +27,6 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.WeakHashMap;
import java.util.logging.Level;
@ -437,7 +436,7 @@ public final class HttpFileUploadManager extends Manager {
urlConnection.setDoOutput(true);
urlConnection.setFixedLengthStreamingMode(fileSize);
urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
for (Entry<String, String> header : slot.getHeaders().entrySet()) {
for (Map.Entry<String, String> header : slot.getHeaders().entrySet()) {
urlConnection.setRequestProperty(header.getKey(), header.getValue());
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2016 Florian Schmaus
* Copyright 2016-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.iot.provisioning.IoTProvisioningManager;
@ -70,7 +69,7 @@ public abstract class IoTManager extends Manager {
protected abstract class IoTIqRequestHandler extends AbstractIqRequestHandler {
protected IoTIqRequestHandler(String element, String namespace, Type type, Mode mode) {
protected IoTIqRequestHandler(String element, String namespace, IQ.Type type, Mode mode) {
super(element, namespace, type, mode);
}

View file

@ -23,7 +23,6 @@ import java.util.Iterator;
import org.jivesoftware.smackx.iot.control.ThingControlRequest;
import org.jivesoftware.smackx.iot.data.ThingMomentaryReadOutRequest;
import org.jivesoftware.smackx.iot.discovery.element.Tag;
import org.jivesoftware.smackx.iot.discovery.element.Tag.Type;
import org.jivesoftware.smackx.iot.element.NodeInfo;
public final class Thing {
@ -112,35 +111,35 @@ public final class Thing {
public Builder setSerialNumber(String sn) {
final String name = "SN";
Tag tag = new Tag(name, Type.str, sn);
Tag tag = new Tag(name, Tag.Type.str, sn);
metaTags.put(name, tag);
return this;
}
public Builder setKey(String key) {
final String name = "KEY";
Tag tag = new Tag(name, Type.str, key);
Tag tag = new Tag(name, Tag.Type.str, key);
metaTags.put(name, tag);
return this;
}
public Builder setManufacturer(String manufacturer) {
final String name = "MAN";
Tag tag = new Tag(name, Type.str, manufacturer);
Tag tag = new Tag(name, Tag.Type.str, manufacturer);
metaTags.put(name, tag);
return this;
}
public Builder setModel(String model) {
final String name = "MODEL";
Tag tag = new Tag(name, Type.str, model);
Tag tag = new Tag(name, Tag.Type.str, model);
metaTags.put(name, tag);
return this;
}
public Builder setVersion(String version) {
final String name = "V";
Tag tag = new Tag(name, Type.num, version);
Tag tag = new Tag(name, Tag.Type.num, version);
metaTags.put(name, tag);
return this;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2016-2019 Florian Schmaus
* Copyright © 2016-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -24,8 +24,6 @@ import java.util.List;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
@ -45,7 +43,8 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
private static final Logger LOGGER = Logger.getLogger(IoTFieldsExtensionProvider.class.getName());
@Override
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException, XmlPullParserException, SmackTextParseException {
public IoTFieldsExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws IOException, XmlPullParserException, ParseException {
int seqNr = ParserUtils.getIntegerAttributeOrThrow(parser, "seqnr", "IoT data request <accepted/> without sequence number");
boolean done = ParserUtils.getBooleanAttribute(parser, "done", false);
List<NodeElement> nodes = new ArrayList<>();
@ -74,7 +73,7 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
return new IoTFieldsExtension(seqNr, done, nodes);
}
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
public NodeElement parseNode(XmlPullParser parser) throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth();
final NodeInfo nodeInfo = NodeInfoParser.parse(parser);
List<TimestampElement> timestampElements = new ArrayList<>();
@ -103,15 +102,11 @@ public class IoTFieldsExtensionProvider extends ExtensionElementProvider<IoTFiel
return new NodeElement(nodeInfo, timestampElements);
}
public TimestampElement parseTimestampElement(XmlPullParser parser) throws XmlPullParserException, IOException, SmackTextParseException {
public TimestampElement parseTimestampElement(XmlPullParser parser)
throws XmlPullParserException, IOException, ParseException {
final int initialDepth = parser.getDepth();
final String dateString = parser.getAttributeValue(null, "value");
Date date;
try {
date = XmppDateTime.parseDate(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
Date date = XmppDateTime.parseDate(dateString);
List<IoTDataField> fields = new ArrayList<>();
outerloop: while (true) {
final XmlPullParser.Event eventType = parser.next();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2016-2019 Florian Schmaus
* Copyright 2016-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
@ -201,7 +200,7 @@ public final class IoTProvisioningManager extends Manager {
}, FRIEND_MESSAGE);
connection.registerIQRequestHandler(
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, Type.set, Mode.async) {
new AbstractIqRequestHandler(ClearCache.ELEMENT, ClearCache.NAMESPACE, IQ.Type.set, Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
if (!isFromProvisioningService(iqRequest, true)) {

View file

@ -44,7 +44,7 @@ public class JingleFileTransferProvider
extends JingleContentDescriptionProvider<JingleFileTransfer> {
@Override
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public JingleFileTransfer parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException, ParseException {
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
JingleFileTransferChild.Builder builder = JingleFileTransferChild.getBuilder();
@ -59,11 +59,7 @@ public class JingleFileTransferProvider
elementName = parser.getName();
switch (elementName) {
case JingleFileTransferChild.ELEM_DATE:
try {
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
break;
case JingleFileTransferChild.ELEM_DESC:

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2016 Fernando Ramirez, 2020 Florian Schmaus
* Copyright 2016 Fernando Ramirez, 2020-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.mam.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -40,7 +41,8 @@ import org.jivesoftware.smackx.mam.element.MamElements.MamResultExtension;
public class MamResultProvider extends ExtensionElementProvider<MamResultExtension> {
@Override
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public MamResultExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Forwarded<Message> forwarded = null;
String queryId = parser.getAttributeValue("", "queryid");
String id = parser.getAttributeValue("", "id");

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.message_retraction.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment;
@ -34,7 +35,7 @@ public class RetractedElementProvider extends ExtensionElementProvider<Retracted
@Override
public RetractedElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Date date = ParserUtils.getDateFromXep82String(parser.getAttributeValue("", RetractedElement.ATTR_STAMP));
OriginIdElement originIdElement = null;

View file

@ -31,7 +31,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
@ -228,7 +227,7 @@ public final class MultiUserChatLightManager extends Manager {
private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
mucLightBlockingIQ.setType(Type.get);
mucLightBlockingIQ.setType(IQ.Type.get);
mucLightBlockingIQ.setTo(mucLightService);
StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection());
@ -278,7 +277,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendBlockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
}
@ -322,7 +321,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendBlockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
}
@ -366,7 +365,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendUnblockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
}
@ -410,7 +409,7 @@ public final class MultiUserChatLightManager extends Manager {
private void sendUnblockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users)
throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(mucLightService);
connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow();
}

View file

@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muclight.provider;
import java.io.IOException;
import java.util.HashMap;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
@ -65,7 +65,7 @@ public class MUCLightBlockingIQProvider extends IQProvider<MUCLightBlockingIQ> {
}
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.result);
mucLightBlockingIQ.setType(IQ.Type.result);
return mucLightBlockingIQ;
}

View file

@ -28,7 +28,6 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPConnectionRegistry;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
import org.jivesoftware.smackx.push_notifications.element.DisablePushNotificationsIQ;
@ -166,7 +165,7 @@ public final class PushNotificationsManager extends Manager {
throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException {
final XMPPConnection connection = connection();
IQ responseIQ = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow();
return responseIQ.getType() != Type.error;
return responseIQ.getType() != IQ.Type.error;
}
}

View file

@ -17,6 +17,7 @@
package org.jivesoftware.smackx.stanza_content_encryption.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.ExtensionElement;
@ -42,7 +43,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
@Override
public ContentElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, ParseException, SmackParsingException {
ContentElement.Builder builder = ContentElement.builder();
while (true) {
@ -117,7 +118,7 @@ public class ContentElementProvider extends ExtensionElementProvider<ContentElem
}
private static void parseTimestampAffix(XmlPullParser parser, ContentElement.Builder builder)
throws SmackParsingException.SmackTextParseException {
throws ParseException {
Date timestamp = ParserUtils.getDateFromXep82String(
parser.getAttributeValue("", TimestampAffixElement.ATTR_STAMP));
builder.setTimestamp(timestamp);

View file

@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
@ -68,7 +67,7 @@ public class MamFinProviderTest extends MamTest {
IQ iq = PacketParserUtils.parseStanza(IQ_LIMITED_RESULTS_EXAMPLE);
MamFinIQ mamFinIQ = (MamFinIQ) iq;
assertEquals(mamFinIQ.getType(), Type.result);
assertEquals(mamFinIQ.getType(), IQ.Type.result);
assertTrue(mamFinIQ.isComplete());
assertEquals(mamFinIQ.getRSMSet().getCount(), 16);

View file

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.mam.element.MamQueryIQ;
@ -57,7 +56,7 @@ public class MamQueryIQProviderTest {
IQ iq1 = PacketParserUtils.parseStanza(exampleMamQueryIQ1);
MamQueryIQ mamQueryIQ1 = (MamQueryIQ) iq1;
assertEquals(mamQueryIQ1.getType(), Type.set);
assertEquals(mamQueryIQ1.getType(), IQ.Type.set);
assertEquals(mamQueryIQ1.getQueryId(), "test");
DataForm dataForm1 = (DataForm) mamQueryIQ1.getExtension(DataForm.NAMESPACE);
@ -73,7 +72,7 @@ public class MamQueryIQProviderTest {
IQ iq2 = PacketParserUtils.parseStanza(exampleMamQueryIQ2);
MamQueryIQ mamQueryIQ2 = (MamQueryIQ) iq2;
assertEquals(mamQueryIQ2.getType(), Type.result);
assertEquals(mamQueryIQ2.getType(), IQ.Type.result);
assertNull(mamQueryIQ2.getQueryId());
DataForm dataForm2 = (DataForm) mamQueryIQ2.getExtension(DataForm.NAMESPACE);

View file

@ -24,7 +24,6 @@ import java.util.TimeZone;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.StanzaBuilder;
import org.jivesoftware.smack.packet.StreamOpen;
@ -75,7 +74,7 @@ public class QueryArchiveTest extends MamTest {
DelayInformation delay = new DelayInformation(date);
Message forwardedMessage = StanzaBuilder.buildMessage("162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2")
.from(JidCreate.from("coven@chat.shakespeare.lit/firstwitch"))
.ofType(Type.chat)
.ofType(Message.Type.chat)
.setBody("Thrice the brinded cat hath mew.")
.build();
@ -93,7 +92,7 @@ public class QueryArchiveTest extends MamTest {
Message resultMessage = mamResultExtension.getForwarded().getForwardedStanza();
assertEquals(resultMessage.getFrom(), JidCreate.from("coven@chat.shakespeare.lit/firstwitch"));
assertEquals(resultMessage.getStanzaId(), "162BEBB1-F6DB-4D9A-9BD8-CFDCC801A0B2");
assertEquals(resultMessage.getType(), Type.chat);
assertEquals(resultMessage.getType(), Message.Type.chat);
assertEquals(resultMessage.getBody(), "Thrice the brinded cat hath mew.");
}

View file

@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.HashMap;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -59,7 +58,7 @@ public class MUCLightBlockingTest {
@Test
public void checkGetBlockingListIQ() throws Exception {
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null);
mucLightBlockingIQ.setType(Type.get);
mucLightBlockingIQ.setType(IQ.Type.get);
mucLightBlockingIQ.setStanzaId("getblock1");
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
@ -86,7 +85,7 @@ public class MUCLightBlockingTest {
rooms.put(JidCreate.from("chapel@shakespeare.lit"), false);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("block1");
@ -100,7 +99,7 @@ public class MUCLightBlockingTest {
users.put(JidCreate.from("hag66@shakespeare.lit"), false);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("block2");
@ -116,7 +115,7 @@ public class MUCLightBlockingTest {
rooms.put(JidCreate.from("coven@muclight.shakespeare.lit"), true);
MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, users);
mucLightBlockingIQ.setType(Type.set);
mucLightBlockingIQ.setType(IQ.Type.set);
mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit"));
mucLightBlockingIQ.setStanzaId("unblock1");

View file

@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.StandardExtensionElement;
@ -40,7 +41,7 @@ import org.jxmpp.jid.impl.JidCreate;
public class ContentElementProviderTest {
@Test
public void testParsing() throws XmlPullParserException, IOException, SmackParsingException {
public void testParsing() throws XmlPullParserException, IOException, SmackParsingException, ParseException {
String xml = "" +
"<content xmlns='urn:xmpp:sce:0'>\n" +
" <payload>\n" +

View file

@ -26,7 +26,6 @@ import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
import org.jivesoftware.smackx.address.packet.MultipleAddresses.Type;
import org.jxmpp.jid.Jid;
@ -50,7 +49,7 @@ public class MultipleAddressesProvider extends ExtensionElementProvider<Multiple
switch (name) {
case MultipleAddresses.Address.ELEMENT:
String typeString = parser.getAttributeValue("", "type");
Type type = Type.valueOf(typeString);
MultipleAddresses.Type type = MultipleAddresses.Type.valueOf(typeString);
Jid jid = ParserUtils.getJidAttribute(parser, "jid");
String node = parser.getAttributeValue("", "node");
String desc = parser.getAttributeValue("", "desc");

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
import org.jivesoftware.smackx.blocking.element.BlockListIQ;
@ -97,7 +96,7 @@ public final class BlockingCommandManager extends Manager {
// block IQ handler
connection.registerIQRequestHandler(
new AbstractIqRequestHandler(BlockContactsIQ.ELEMENT, BlockContactsIQ.NAMESPACE, Type.set, Mode.sync) {
new AbstractIqRequestHandler(BlockContactsIQ.ELEMENT, BlockContactsIQ.NAMESPACE, IQ.Type.set, Mode.sync) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
BlockContactsIQ blockContactIQ = (BlockContactsIQ) iqRequest;
@ -119,7 +118,7 @@ public final class BlockingCommandManager extends Manager {
// unblock IQ handler
connection.registerIQRequestHandler(new AbstractIqRequestHandler(UnblockContactsIQ.ELEMENT,
UnblockContactsIQ.NAMESPACE, Type.set, Mode.sync) {
UnblockContactsIQ.NAMESPACE, IQ.Type.set, Mode.sync) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iqRequest;

View file

@ -20,7 +20,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.ParserUtils;
@ -70,7 +70,7 @@ public class BlockListIQProvider extends IQProvider<BlockListIQ> {
}
BlockListIQ blockListIQ = new BlockListIQ(jids);
blockListIQ.setType(Type.result);
blockListIQ.setType(IQ.Type.result);
return blockListIQ;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2016-2020 Fernando Ramirez, Florian Schmaus
* Copyright 2016-2021 Fernando Ramirez, Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,7 +33,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.SHA1;
import org.jivesoftware.smackx.bob.element.BoBIQ;
@ -91,7 +90,7 @@ public final class BoBManager extends Manager {
serviceDiscoveryManager.addFeature(NAMESPACE);
connection.registerIQRequestHandler(
new AbstractIqRequestHandler(BoBIQ.ELEMENT, BoBIQ.NAMESPACE, Type.get, Mode.async) {
new AbstractIqRequestHandler(BoBIQ.ELEMENT, BoBIQ.NAMESPACE, IQ.Type.get, Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
BoBIQ bobIQRequest = (BoBIQ) iqRequest;
@ -105,7 +104,7 @@ public final class BoBManager extends Manager {
BoBData bobData = bobInfo.getData();
BoBIQ responseBoBIQ = new BoBIQ(contentId, bobData);
responseBoBIQ.setType(Type.result);
responseBoBIQ.setType(IQ.Type.result);
responseBoBIQ.setTo(bobIQRequest.getFrom());
return responseBoBIQ;
}
@ -146,7 +145,7 @@ public final class BoBManager extends Manager {
}
BoBIQ requestBoBIQ = new BoBIQ(bobHash);
requestBoBIQ.setType(Type.get);
requestBoBIQ.setType(IQ.Type.get);
requestBoBIQ.setTo(to);
XMPPConnection connection = getAuthenticatedConnectionOrThrow();

View file

@ -441,7 +441,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
protected void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
void replyRejectPacket(IQ request) throws NotConnectedException, InterruptedException {
IQ error = IQ.createErrorResponse(request, StanzaError.Condition.not_acceptable);
connection().sendStanza(error);
}
@ -454,7 +454,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
void replyItemNotFoundPacket(IQ request) throws NotConnectedException, InterruptedException {
IQ error = IQ.createErrorResponse(request, StanzaError.Condition.item_not_found);
connection().sendStanza(error);
}
@ -476,7 +476,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
*
* @return the XMPP connection
*/
protected XMPPConnection getConnection() {
XMPPConnection getConnection() {
return connection();
}
@ -487,7 +487,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
* @param initiator the initiator's JID
* @return the listener
*/
protected BytestreamListener getUserListener(Jid initiator) {
BytestreamListener getUserListener(Jid initiator) {
return this.userListeners.get(initiator);
}
@ -497,7 +497,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
*
* @return list of listeners
*/
protected List<BytestreamListener> getAllRequestListeners() {
List<BytestreamListener> getAllRequestListeners() {
return this.allRequestListeners;
}
@ -506,7 +506,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
*
* @return the sessions map
*/
protected Map<String, InBandBytestreamSession> getSessions() {
Map<String, InBandBytestreamSession> getSessions() {
return sessions;
}
@ -515,7 +515,7 @@ public final class InBandBytestreamManager extends Manager implements Bytestream
*
* @return list of session IDs
*/
protected List<String> getIgnoredBytestreamRequests() {
List<String> getIgnoredBytestreamRequests() {
return ignoredBytestreamRequests;
}

View file

@ -52,7 +52,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
*
* @param manager the SOCKS5 Bytestream manager
*/
protected InitiationListener(Socks5BytestreamManager manager) {
InitiationListener(Socks5BytestreamManager manager) {
super(Bytestream.ELEMENT, Bytestream.NAMESPACE, IQ.Type.set, Mode.async);
this.manager = manager;
initiationListenerExecutor = Executors.newCachedThreadPool();
@ -117,7 +117,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
/**
* Shuts down the listeners executor service.
*/
protected void shutdown() {
void shutdown() {
this.initiationListenerExecutor.shutdownNow();
}

View file

@ -717,7 +717,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
protected void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
void replyRejectPacket(IQ packet) throws NotConnectedException, InterruptedException {
StanzaError xmppError = StanzaError.getBuilder(StanzaError.Condition.not_acceptable).build();
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
connection().sendStanza(errorIQ);
@ -760,7 +760,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*
* @return the XMPP connection
*/
protected XMPPConnection getConnection() {
XMPPConnection getConnection() {
return connection();
}
@ -771,7 +771,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
* @param initiator the initiator's JID
* @return the listener
*/
protected BytestreamListener getUserListener(Jid initiator) {
BytestreamListener getUserListener(Jid initiator) {
return this.userListeners.get(initiator);
}
@ -781,7 +781,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*
* @return list of listeners
*/
protected List<BytestreamListener> getAllRequestListeners() {
List<BytestreamListener> getAllRequestListeners() {
return this.allRequestListeners;
}
@ -790,7 +790,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
*
* @return list of session IDs
*/
protected List<String> getIgnoredBytestreamRequests() {
List<String> getIgnoredBytestreamRequests() {
return ignoredBytestreamRequests;
}

View file

@ -311,7 +311,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
* Cancels the SOCKS5 Bytestream request by sending an error to the initiator and building a
* XMPP exception.
*
* @param streamHosts the stream hosts.
* @param streamHostsExceptions the stream hosts and their exceptions.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
* @throws CouldNotConnectToAnyProvidedSocks5Host as expected result.

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2009 Jonas Ådahl, 2011-2020 Florian Schmaus
* Copyright © 2009 Jonas Ådahl, 2011-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -96,7 +96,7 @@ public final class EntityCapsManager extends Manager {
private static String DEFAULT_ENTITY_NODE = SmackConfiguration.SMACK_URL_STRING;
protected static EntityCapsPersistentCache persistentCache;
static EntityCapsPersistentCache persistentCache;
private static boolean autoEnableEntityCaps = true;
@ -595,7 +595,7 @@ public final class EntityCapsManager extends Manager {
return true;
}
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo) {
static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo) {
return generateVerificationString(discoverInfo, null);
}
@ -611,7 +611,7 @@ public final class EntityCapsManager extends Manager {
* @return The generated verification String or null if the hash is not
* supported
*/
protected static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash) {
static CapsVersionAndHash generateVerificationString(DiscoverInfoView discoverInfo, String hash) {
if (hash == null) {
hash = DEFAULT_HASH;
}

View file

@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@ -520,8 +519,8 @@ public final class AdHocCommandManager extends Manager {
private void sessionSweeper() {
final long currentTime = System.currentTimeMillis();
synchronized (this) {
for (Iterator<Entry<String, LocalCommand>> it = executingCommands.entrySet().iterator(); it.hasNext();) {
Entry<String, LocalCommand> entry = it.next();
for (Iterator<Map.Entry<String, LocalCommand>> it = executingCommands.entrySet().iterator(); it.hasNext();) {
Map.Entry<String, LocalCommand> entry = it.next();
LocalCommand command = entry.getValue();
long creationStamp = command.getCreationDate();
@ -561,7 +560,6 @@ public final class AdHocCommandManager extends Manager {
*
* @param response the response to send.
* @param condition the condition of the error.
* @throws NotConnectedException if the XMPP connection is not connected.
*/
private static IQ respondError(AdHocCommandData response,
StanzaError.Condition condition) {
@ -574,7 +572,6 @@ public final class AdHocCommandManager extends Manager {
* @param response the response to send.
* @param condition the condition of the error.
* @param specificCondition the adhoc command error condition.
* @throws NotConnectedException if the XMPP connection is not connected.
*/
private static IQ respondError(AdHocCommandData response, StanzaError.Condition condition,
AdHocCommand.SpecificErrorCondition specificCondition) {
@ -589,7 +586,6 @@ public final class AdHocCommandManager extends Manager {
*
* @param response the response to send.
* @param error the error to send.
* @throws NotConnectedException if the XMPP connection is not connected.
*/
private static IQ respondError(AdHocCommandData response, StanzaError error) {
response.setType(IQ.Type.error);
@ -608,8 +604,8 @@ public final class AdHocCommandManager extends Manager {
* @throws NoSuchMethodException if no such method is declared
* @throws InvocationTargetException if a reflection-based method or constructor invocation threw.
* @throws IllegalArgumentException if an illegal argument was given.
* @throws IllegalAccessException
* @throws InstantiationException
* @throws IllegalAccessException in case of an illegal access.
* @throws InstantiationException in case of an instantiation error.
*/
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
throws XMPPErrorException, InstantiationException, IllegalAccessException, IllegalArgumentException,

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,10 +17,10 @@
package org.jivesoftware.smackx.delay.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
@ -32,7 +32,7 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
@Override
public final DelayInformation parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,
IOException, SmackTextParseException {
IOException, ParseException {
String stampString = parser.getAttributeValue("", "stamp");
String from = parser.getAttributeValue("", "from");
final String reason;
@ -54,5 +54,5 @@ public abstract class AbstractDelayInformationProvider extends ExtensionElementP
return new DelayInformation(stamp, from, reason);
}
protected abstract Date parseDate(String string) throws SmackTextParseException;
protected abstract Date parseDate(String string) throws ParseException;
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
*/
package org.jivesoftware.smackx.delay.provider;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.util.ParserUtils;
/**
@ -31,7 +31,7 @@ public class DelayInformationProvider extends AbstractDelayInformationProvider {
public static final DelayInformationProvider INSTANCE = new DelayInformationProvider();
@Override
protected Date parseDate(String string) throws SmackTextParseException {
protected Date parseDate(String string) throws ParseException {
return ParserUtils.getDateFromXep82String(string);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2014-2019 Florian Schmaus
* Copyright © 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
*/
package org.jivesoftware.smackx.delay.provider;
import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.util.ParserUtils;
/**
@ -29,7 +29,7 @@ import org.jivesoftware.smack.util.ParserUtils;
public class LegacyDelayInformationProvider extends AbstractDelayInformationProvider {
@Override
protected Date parseDate(String string) throws SmackTextParseException {
protected Date parseDate(String string) throws ParseException {
return ParserUtils.getDateFromString(string);
}

View file

@ -142,7 +142,7 @@ public final class FileTransferManager extends Manager {
* @return The IncomingFileTransfer which manages the download of the file
* from the transfer initiator.
*/
protected IncomingFileTransfer createIncomingFileTransfer(
IncomingFileTransfer createIncomingFileTransfer(
FileTransferRequest request) {
if (request == null) {
throw new NullPointerException("ReceiveRequest cannot be null");
@ -164,7 +164,7 @@ public final class FileTransferManager extends Manager {
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
protected void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException, InterruptedException {
void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException, InterruptedException {
StreamInitiation initiation = request.getStreamInitiation();
// Reject as specified in XEP-95 4.2. Note that this is not to be confused with the Socks 5

View file

@ -65,7 +65,7 @@ public final class FileTransferNegotiator extends Manager {
private static final String STREAM_INIT_PREFIX = "jsi_";
protected static final String STREAM_DATA_FIELD_NAME = "stream-method";
static final String STREAM_DATA_FIELD_NAME = "stream-method";
private static final Random randomGenerator = new Random();

View file

@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.EventManger;
import org.jivesoftware.smack.util.EventManger.Callback;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
import org.jivesoftware.smackx.xdata.FormField;
@ -101,7 +100,7 @@ public abstract class StreamNegotiator extends Manager {
final String eventKey = initiation.getFrom().toString() + '\t' + initiation.getSessionID();
IQ streamMethodInitiation;
try {
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new Callback<NotConnectedException>() {
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getReplyTimeout(), new EventManger.Callback<NotConnectedException>() {
@Override
public void action() throws NotConnectedException {
try {

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2013-2014 Georg Lukas, 2020 Florian Schmaus
* Copyright 2013-2014 Georg Lukas, 2020-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.forward.provider;
import java.io.IOException;
import java.text.ParseException;
import java.util.logging.Logger;
import org.jivesoftware.smack.packet.Message;
@ -45,7 +46,8 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded<?>> {
private static final Logger LOGGER = Logger.getLogger(ForwardedProvider.class.getName());
@Override
public Forwarded<?> parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
public Forwarded<?> parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
DelayInformation di = null;
Stanza packet = null;
@ -90,13 +92,14 @@ public class ForwardedProvider extends ExtensionElementProvider<Forwarded<?>> {
}
public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
return parseForwardedMessage(parser, parser.getDepth(), xmlEnvironment);
}
@SuppressWarnings("unchecked")
public static Forwarded<Message> parseForwardedMessage(XmlPullParser parser, int initialDepth,
XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException {
XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
Forwarded<?> forwarded = INSTANCE.parse(parser, initialDepth, xmlEnvironment);
if (!forwarded.isForwarded(Message.class)) {
throw new SmackParsingException("Expecting a forwarded message, but got " + forwarded);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015-2017 Ishan Khanna, Fernando Ramirez, 2019-2020 Florian Schmaus
* Copyright 2015-2017 Ishan Khanna, Fernando Ramirez, 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,12 +17,12 @@
package org.jivesoftware.smackx.geoloc.provider;
import java.io.IOException;
import java.text.ParseException;
import javax.xml.namespace.QName;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
@ -38,7 +38,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override
public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException,
SmackTextParseException, SmackUriSyntaxParsingException {
SmackUriSyntaxParsingException, ParseException {
GeoLocation.Builder builder = GeoLocation.builder();
@ -153,7 +153,7 @@ public class GeoLocationProvider extends ExtensionElementProvider<GeoLocation> {
@Override
public GeoLocation parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException {
throws XmlPullParserException, IOException, SmackParsingException, ParseException {
return GeoLocationProvider.INSTANCE.parse(parser, initialDepth, xmlEnvironment);
}

View file

@ -32,7 +32,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
@ -164,7 +163,7 @@ public final class LastActivityManager extends Manager {
// Register a listener for a last activity query
connection.registerIQRequestHandler(new AbstractIqRequestHandler(LastActivity.ELEMENT, LastActivity.NAMESPACE,
Type.get, Mode.async) {
IQ.Type.get, Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
if (!enabled)

View file

@ -24,12 +24,10 @@ import java.util.Set;
import java.util.WeakHashMap;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.StanzaCollector;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.StanzaIdFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
@ -355,13 +353,11 @@ public final class AccountManager extends Manager {
/**
* Gets the account registration info from the server.
*
* @throws XMPPErrorException if there was an XMPP error returned.
* @throws NoResponseException if there was no response from the remote entity.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*
* @throws XMPPException if an error occurs.
* @throws SmackException if there was no response from the server.
*/
private synchronized void getRegistrationInfo() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Registration reg = new Registration();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017 Florian Schmaus
* Copyright 2017-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.jingle.element.Jingle;
@ -74,7 +73,7 @@ public final class JingleManager extends Manager {
jutil = new JingleUtil(connection);
connection.registerIQRequestHandler(
new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, Type.set, Mode.async) {
new AbstractIqRequestHandler(Jingle.ELEMENT, Jingle.NAMESPACE, IQ.Type.set, Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
final Jingle jingle = (Jingle) iqRequest;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2020 Florian Schmaus
* Copyright 2017-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -76,7 +76,7 @@ public class JingleReason implements FullyQualifiedElement {
unsupported_transports,
;
protected static final Map<String, Reason> LUT = new HashMap<>(Reason.values().length);
static final Map<String, Reason> LUT = new HashMap<>(Reason.values().length);
static {
for (Reason reason : Reason.values()) {
@ -84,7 +84,7 @@ public class JingleReason implements FullyQualifiedElement {
}
}
protected final String asString;
final String asString;
Reason() {
asString = name().replace('_', '-');

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2019 Florian Schmaus
* Copyright 2017-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.jivesoftware.smackx.jingle.provider;
import java.io.IOException;
import java.text.ParseException;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
@ -30,6 +31,7 @@ public abstract class JingleContentDescriptionProvider<D extends JingleContentDe
extends ExtensionElementProvider<D> {
@Override
public abstract D parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackParsingException;
public abstract D parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException, SmackParsingException, ParseException;
}

View file

@ -51,6 +51,7 @@ public class JivePropertiesExtensionProvider extends ExtensionElementProvider<Ji
* @throws IOException if an I/O error occurred.
* @throws XmlPullParserException if an error in the XML parser occurred.
*/
@SuppressWarnings("BanSerializableRead")
@Override
public JivePropertiesExtension parse(XmlPullParser parser,
int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException,

View file

@ -1,6 +1,6 @@
/**
*
* Copyright © 2018 Paul Schaub, 2019 Florian Schmaus
* Copyright © 2018 Paul Schaub, 2019-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,8 +20,6 @@ import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackTextParseException;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
@ -34,14 +32,9 @@ public class IdleProvider extends ExtensionElementProvider<IdleElement> {
public static final IdleProvider TEST_INSTANCE = new IdleProvider();
@Override
public IdleElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws SmackTextParseException {
public IdleElement parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws ParseException {
String dateString = parser.getAttributeValue(null, IdleElement.ATTR_SINCE);
Date since;
try {
since = XmppDateTime.parseXEP0082Date(dateString);
} catch (ParseException e) {
throw new SmackParsingException.SmackTextParseException(e);
}
Date since = XmppDateTime.parseXEP0082Date(dateString);
return new IdleElement(since);
}
}

View file

@ -1044,8 +1044,8 @@ public class MultiUserChat {
/**
* Fires invitation rejection listeners.
*
* @param invitee the user being invited.
* @param reason the reason for the rejection
* @param message the message.
* @param rejection the information about the rejection.
*/
private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) {
EntityBareJid invitee = rejection.getFrom();

View file

@ -37,7 +37,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.util.ExceptionCallback;
@ -120,7 +119,7 @@ public final class PingManager extends Manager {
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
sdm.addFeature(Ping.NAMESPACE);
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Ping.ELEMENT, Ping.NAMESPACE, Type.get, Mode.async) {
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Ping.ELEMENT, Ping.NAMESPACE, IQ.Type.get, Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
Ping ping = (Ping) iqRequest;

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015 Florian Schmaus
* Copyright 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.jivesoftware.smackx.privacy.filter;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.privacy.packet.Privacy;
@ -30,7 +30,7 @@ public final class SetActiveListFilter extends FlexibleStanzaTypeFilter<Privacy>
@Override
protected boolean acceptSpecific(Privacy privacy) {
if (privacy.getType() != Type.set) {
if (privacy.getType() != IQ.Type.set) {
return false;
}
return privacy.getActiveName() != null || privacy.isDeclineActiveList();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2015 Florian Schmaus
* Copyright 2015-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@
package org.jivesoftware.smackx.privacy.filter;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.privacy.packet.Privacy;
@ -30,7 +30,7 @@ public final class SetDefaultListFilter extends FlexibleStanzaTypeFilter<Privacy
@Override
protected boolean acceptSpecific(Privacy privacy) {
if (privacy.getType() != Type.set) {
if (privacy.getType() != IQ.Type.set) {
return false;
}
return privacy.getDefaultName() != null || privacy.isDeclineDefaultList();

View file

@ -24,7 +24,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
import org.jivesoftware.smackx.pubsub.form.ConfigureForm;
@ -90,7 +90,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public <T extends Item> List<T> getItems(String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId));
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId(), subscriptionId));
return getItems(request);
}
@ -116,7 +116,7 @@ public class LeafNode extends Node {
for (String id : ids) {
itemList.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
PubSub request = createPubsubPacket(IQ.Type.get, new ItemsExtension(ItemsExtension.ItemsElementType.items, getId(), itemList));
return getItems(request);
}
@ -133,7 +133,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public <T extends Item> List<T> getItems(int maxItems) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems));
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId(), maxItems));
return getItems(request);
}
@ -154,7 +154,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public <T extends Item> List<T> getItems(int maxItems, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems));
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId(), subscriptionId, maxItems));
return getItems(request);
}
@ -180,7 +180,7 @@ public class LeafNode extends Node {
public <T extends Item> List<T> getItems(List<ExtensionElement> additionalExtensions,
List<ExtensionElement> returnedExtensions) throws NoResponseException,
XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId()));
PubSub request = createPubsubPacket(IQ.Type.get, new GetItemsRequest(getId()));
request.addExtensions(additionalExtensions);
return getItems(request, returnedExtensions);
}
@ -276,7 +276,7 @@ public class LeafNode extends Node {
*
*/
public void publish() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
PubSub packet = createPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
}
@ -325,7 +325,7 @@ public class LeafNode extends Node {
*
*/
public <T extends Item> void publish(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = createPubsubPacket(Type.set, new PublishItem<>(getId(), items));
PubSub packet = createPubsubPacket(IQ.Type.set, new PublishItem<>(getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
}
@ -341,7 +341,7 @@ public class LeafNode extends Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()));
PubSub request = createPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()));
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
}
@ -376,7 +376,7 @@ public class LeafNode extends Node {
for (String id : itemIds) {
items.add(new Item(id));
}
PubSub request = createPubsubPacket(Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
PubSub request = createPubsubPacket(IQ.Type.set, new ItemsExtension(ItemsExtension.ItemsElementType.retract, getId(), items));
pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow();
}
}

View file

@ -29,7 +29,7 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.filter.FlexibleStanzaTypeFilter;
import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Stanza;
@ -94,7 +94,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(
PubSubElementType.CONFIGURE_OWNER, getId()));
Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
@ -110,7 +110,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public void sendConfigurationForm(FillableConfigureForm configureForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = createPubsubPacket(Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER,
PubSub packet = createPubsubPacket(IQ.Type.set, new FormNode(FormNodeType.CONFIGURE_OWNER,
getId(), configureForm.getDataFormToSubmit()));
pubSubManager.getConnection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
}
@ -218,7 +218,7 @@ public abstract class Node {
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSubElementType pubSubElementType = subscriptionsNamespace.type;
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(pubSubElementType, getId()));
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(pubSubElementType, getId()));
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
@ -251,7 +251,7 @@ public abstract class Node {
public PubSub modifySubscriptionsAsOwner(List<Subscription> changedSubs)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(Type.set,
PubSub pubSub = createPubsubPacket(IQ.Type.set,
new SubscriptionsExtension(SubscriptionsNamespace.owner, getId(), changedSubs));
return sendPubsubPacket(pubSub);
}
@ -337,7 +337,7 @@ public abstract class Node {
NotConnectedException, InterruptedException {
PubSubElementType pubSubElementType = affiliationsNamespace.type;
PubSub pubSub = createPubsubPacket(Type.get, new NodeExtension(pubSubElementType, getId()));
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(pubSubElementType, getId()));
if (additionalExtensions != null) {
for (ExtensionElement pe : additionalExtensions) {
pubSub.addExtension(pe);
@ -375,7 +375,7 @@ public abstract class Node {
}
}
PubSub pubSub = createPubsubPacket(Type.set, new AffiliationsExtension(AffiliationNamespace.owner, affiliations, getId()));
PubSub pubSub = createPubsubPacket(IQ.Type.set, new AffiliationsExtension(AffiliationNamespace.owner, affiliations, getId()));
return sendPubsubPacket(pubSub);
}
@ -398,7 +398,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public Subscription subscribe(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
PubSub pubSub = createPubsubPacket(IQ.Type.set, new SubscribeExtension(jid, getId()));
PubSub reply = sendPubsubPacket(pubSub);
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
}
@ -460,7 +460,7 @@ public abstract class Node {
*/
public Subscription subscribe(Jid jid, FillableSubscribeForm subForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
DataForm submitForm = subForm.getDataFormToSubmit();
PubSub request = createPubsubPacket(Type.set, new SubscribeExtension(jid, getId()));
PubSub request = createPubsubPacket(IQ.Type.set, new SubscribeExtension(jid, getId()));
request.addExtension(new FormNode(FormNodeType.OPTIONS, submitForm));
PubSub reply = sendPubsubPacket(request);
return reply.getExtension(PubSubElementType.SUBSCRIPTION);
@ -529,7 +529,7 @@ public abstract class Node {
* @throws InterruptedException if the calling thread was interrupted.
*/
public void unsubscribe(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
sendPubsubPacket(createPubsubPacket(Type.set, new UnsubscribeExtension(jid, getId(), subscriptionId)));
sendPubsubPacket(createPubsubPacket(IQ.Type.set, new UnsubscribeExtension(jid, getId(), subscriptionId)));
}
/**
@ -563,7 +563,7 @@ public abstract class Node {
*
*/
public SubscribeForm getSubscriptionOptions(String jid, String subscriptionId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub packet = sendPubsubPacket(createPubsubPacket(Type.get, new OptionsExtension(jid, getId(), subscriptionId)));
PubSub packet = sendPubsubPacket(createPubsubPacket(IQ.Type.get, new OptionsExtension(jid, getId(), subscriptionId)));
FormNode ext = packet.getExtension(PubSubElementType.OPTIONS);
return new SubscribeForm(ext.getForm());
}
@ -651,7 +651,7 @@ public abstract class Node {
return super.toString() + " " + getClass().getName() + " id: " + id;
}
protected PubSub createPubsubPacket(Type type, NodeExtension ext) {
protected PubSub createPubsubPacket(IQ.Type type, NodeExtension ext) {
return PubSub.createPubsubPacket(pubSubManager.getServiceJid(), type, ext);
}

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.EmptyResultIQ;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition;
@ -217,7 +216,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted.
*/
public LeafNode createNode() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub reply = sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.CREATE), null);
PubSub reply = sendPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.CREATE), null);
QName qname = new QName(PubSubNamespace.basic.getXmlns(), "create");
NodeExtension elem = (NodeExtension) reply.getExtension(qname);
@ -257,7 +256,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted.
*/
public Node createNode(String nodeId, FillableConfigureForm config) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub request = PubSub.createPubsubPacket(pubSubService, Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId));
PubSub request = PubSub.createPubsubPacket(pubSubService, IQ.Type.set, new NodeExtension(PubSubElementType.CREATE, nodeId));
boolean isLeafNode = true;
if (config != null) {
@ -507,7 +506,7 @@ public final class PubSubManager extends Manager {
* @throws InterruptedException if the calling thread was interrupted.
*/
public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
Stanza reply = sendPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null);
SubscriptionsExtension subElem = (SubscriptionsExtension) reply.getExtensionElement(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns());
return subElem.getSubscriptions();
}
@ -523,7 +522,7 @@ public final class PubSubManager extends Manager {
*
*/
public List<Affiliation> getAffiliations() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null);
PubSub reply = sendPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.AFFILIATIONS), null);
AffiliationsExtension listElem = reply.getExtension(PubSubElementType.AFFILIATIONS);
return listElem.getAffiliations();
}
@ -541,7 +540,7 @@ public final class PubSubManager extends Manager {
public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
boolean res = true;
try {
sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
sendPubsubPacket(IQ.Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace());
} catch (XMPPErrorException e) {
if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) {
res = false;
@ -565,7 +564,7 @@ public final class PubSubManager extends Manager {
public ConfigureForm getDefaultConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// Errors will cause exceptions in getReply, so it only returns
// on success.
PubSub reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace());
PubSub reply = sendPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.DEFAULT), PubSubElementType.DEFAULT.getNamespace());
return NodeUtils.getFormFromPacket(reply, PubSubElementType.DEFAULT);
}
@ -644,7 +643,7 @@ public final class PubSubManager extends Manager {
return true;
}
private PubSub sendPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
private PubSub sendPubsubPacket(IQ.Type type, ExtensionElement ext, PubSubNamespace ns)
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
return sendPubsubPacket(pubSubService, type, Collections.singletonList(ext), ns);
}
@ -653,7 +652,7 @@ public final class PubSubManager extends Manager {
return connection();
}
PubSub sendPubsubPacket(Jid to, Type type, List<ExtensionElement> extList, PubSubNamespace ns)
PubSub sendPubsubPacket(Jid to, IQ.Type type, List<ExtensionElement> extList, PubSubNamespace ns)
throws NoResponseException, XMPPErrorException, NotConnectedException,
InterruptedException {
// CHECKSTYLE:OFF

View file

@ -27,7 +27,6 @@ import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.form.FilledForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
/**
* {@link Form} that contains the software information.
@ -145,7 +144,7 @@ public final class SoftwareInfoForm extends FilledForm {
DataForm.Builder dataFormBuilder;
private Builder() {
dataFormBuilder = DataForm.builder(Type.result);
dataFormBuilder = DataForm.builder(DataForm.Type.result);
TextSingleFormField formField = FormField.buildHiddenFormType(FORM_TYPE);
dataFormBuilder.addField(formField);
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2014 Florian Schmaus
* Copyright 2014-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
@ -72,7 +71,7 @@ public final class EntityTimeManager extends Manager {
if (autoEnable)
enable();
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get,
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, IQ.Type.get,
Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {

View file

@ -28,7 +28,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -612,10 +611,10 @@ public final class VCard extends IQ {
xml.optElement("ORGUNIT", organizationUnit);
xml.closeElement("ORG");
}
for (Entry<String, String> entry : otherSimpleFields.entrySet()) {
for (Map.Entry<String, String> entry : otherSimpleFields.entrySet()) {
xml.optElement(entry.getKey(), entry.getValue());
}
for (Entry<String, String> entry : otherUnescapableFields.entrySet()) {
for (Map.Entry<String, String> entry : otherUnescapableFields.entrySet()) {
final String value = entry.getValue();
if (value == null) {
continue;
@ -646,7 +645,7 @@ public final class VCard extends IQ {
xml.element("USERID", emailHome);
xml.closeElement("EMAIL");
}
for (Entry<String, String> phone : workPhones.entrySet()) {
for (Map.Entry<String, String> phone : workPhones.entrySet()) {
final String number = phone.getValue();
if (number == null) {
continue;
@ -657,7 +656,7 @@ public final class VCard extends IQ {
xml.element("NUMBER", number);
xml.closeElement("TEL");
}
for (Entry<String, String> phone : homePhones.entrySet()) {
for (Map.Entry<String, String> phone : homePhones.entrySet()) {
final String number = phone.getValue();
if (number == null) {
continue;
@ -671,7 +670,7 @@ public final class VCard extends IQ {
if (!workAddr.isEmpty()) {
xml.openElement("ADR");
xml.emptyElement("WORK");
for (Entry<String, String> entry : workAddr.entrySet()) {
for (Map.Entry<String, String> entry : workAddr.entrySet()) {
final String value = entry.getValue();
if (value == null) {
continue;
@ -683,7 +682,7 @@ public final class VCard extends IQ {
if (!homeAddr.isEmpty()) {
xml.openElement("ADR");
xml.emptyElement("HOME");
for (Entry<String, String> entry : homeAddr.entrySet()) {
for (Map.Entry<String, String> entry : homeAddr.entrySet()) {
final String value = entry.getValue();
if (value == null) {
continue;

View file

@ -29,7 +29,6 @@ import java.util.Set;
import org.jivesoftware.smackx.xdata.AbstractMultiFormField;
import org.jivesoftware.smackx.xdata.AbstractSingleStringValueFormField;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormField.Type;
import org.jivesoftware.smackx.xdata.FormFieldChildElement;
import org.jivesoftware.smackx.xdata.packet.DataForm;
@ -202,7 +201,7 @@ public class FillableForm extends FilledForm {
public void setAnswer(String fieldName, boolean answer) {
FormField blankField = getFieldOrThrow(fieldName);
if (blankField.getType() != Type.bool) {
if (blankField.getType() != FormField.Type.bool) {
throw new IllegalArgumentException();
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Florian Schmaus
* Copyright 2020-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
public abstract class FilledForm implements FormReader {
@ -36,7 +35,7 @@ public abstract class FilledForm implements FormReader {
if (StringUtils.isNullOrEmpty(formType)) {
throw new IllegalArgumentException("The provided data form has no hidden FROM_TYPE field.");
}
if (dataForm.getType() == Type.cancel) {
if (dataForm.getType() == DataForm.Type.cancel) {
throw new IllegalArgumentException("Forms of type 'cancel' are not filled nor fillable");
}
formTypeFormField = dataForm.getHiddenFormTypeField();

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2020 Florian Schmaus
* Copyright 2020-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,13 +19,12 @@ package org.jivesoftware.smackx.xdata.form;
import org.jivesoftware.smack.packet.StanzaView;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
public class Form extends FilledForm {
public Form(DataForm dataForm) {
super(dataForm);
if (dataForm.getType() != Type.form) {
if (dataForm.getType() != DataForm.Type.form) {
throw new IllegalArgumentException();
}
}
@ -36,7 +35,7 @@ public class Form extends FilledForm {
public static Form from(StanzaView stanzaView) {
DataForm dataForm = DataForm.from(stanzaView);
if (dataForm == null || dataForm.getType() != Type.form) {
if (dataForm == null || dataForm.getType() != DataForm.Type.form) {
return null;
}
return new Form(dataForm);

View file

@ -112,6 +112,8 @@ public abstract class ValidateElement implements FormFieldChildElement {
}
/**
* Append XML.
*
* @param buf TODO javadoc me please
*/
protected abstract void appendXML(XmlStringBuilder buf);
@ -458,6 +460,8 @@ public abstract class ValidateElement implements FormFieldChildElement {
}
/**
* Check that the field being build is not of type multi (or hidden).
*
* @param formField TODO javadoc me please
* @param method TODO javadoc me please
*/

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smackx.blocking;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -42,7 +41,7 @@ public class GetBlockingListTest {
@Test
public void checkGetBlockingListIQStanza() throws Exception {
BlockListIQ getBlockListIQ = new BlockListIQ(null);
getBlockListIQ.setType(Type.get);
getBlockListIQ.setType(IQ.Type.get);
getBlockListIQ.setStanzaId("blocklist1");
assertEquals(getBlockingListIQExample, getBlockListIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}

View file

@ -20,7 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.charset.StandardCharsets;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StreamOpen;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -46,7 +46,7 @@ public class BoBIQTest extends SmackTestSuite {
BoBIQ createdBoBIQ = new BoBIQ(bobHash);
createdBoBIQ.setStanzaId("sarasa");
createdBoBIQ.setTo(JidCreate.from("ladymacbeth@shakespeare.lit/castle"));
createdBoBIQ.setType(Type.get);
createdBoBIQ.setType(IQ.Type.get);
assertEquals(sampleBoBIQRequest, createdBoBIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString());
}
@ -61,7 +61,7 @@ public class BoBIQTest extends SmackTestSuite {
BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData);
createdBoBIQ.setStanzaId("sarasa");
createdBoBIQ.setTo(JidCreate.from("doctor@shakespeare.lit/pda"));
createdBoBIQ.setType(Type.result);
createdBoBIQ.setType(IQ.Type.result);
assertEquals(bobIQ.getContentId().getHash(), createdBoBIQ.getContentId().getHash());
assertEquals(bobIQ.getContentId().getHashType(), createdBoBIQ.getContentId().getHashType());

View file

@ -237,7 +237,7 @@ public class PingTest extends SmackTestSuite {
/**
* The returned connection won't send replies to IQs
*
* @return
* @return a dummy connection.
* @throws XMPPException if an XMPP protocol error was received.
* @throws IOException if an I/O error occurred.
* @throws SmackException if Smack detected an exceptional situation.

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2017-2020 Florian Schmaus
* Copyright 2017-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.jivesoftware.smackx.pubsub.Affiliation.Type;
import org.jivesoftware.smackx.pubsub.packet.PubSub;
import org.junit.jupiter.api.Test;
@ -35,7 +34,7 @@ public class AffiliationsExtensionTest {
@Test
public void testAffiliationsExtensionToXml() throws SAXException, IOException {
BareJid affiliatedJid = JidTestUtil.BARE_JID_1;
Affiliation affiliation = new Affiliation(affiliatedJid, Type.member);
Affiliation affiliation = new Affiliation(affiliatedJid, Affiliation.Type.member);
List<Affiliation> affiliationsList = new ArrayList<>();
affiliationsList.add(affiliation);

View file

@ -28,7 +28,6 @@ import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.packet.StanzaError.Condition;
import org.jivesoftware.smack.test.util.SmackTestSuite;
@ -63,7 +62,7 @@ public class ConfigureFormTest extends SmackTestSuite {
Node node = mgr.getNode("princely_musings");
PubSub errorIq = new PubSub();
errorIq.setType(Type.error);
errorIq.setType(IQ.Type.error);
errorIq.setFrom(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
StanzaError error = StanzaError.getBuilder(Condition.forbidden).build();
errorIq.setError(error);

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2018 Timothy Pitt, Florian Schmaus
* Copyright 2018 Timothy Pitt, 2018-2021 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.ThreadedDummyConnection;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.TestUtils;
import org.jivesoftware.smack.util.PacketParserUtils;
@ -89,7 +89,7 @@ public class PubSubNodeTest extends SmackTestSuite {
new Affiliation(JidTestUtil.BARE_JID_2, Affiliation.Type.publisher)
);
AffiliationsExtension affiliationsExtension = new AffiliationsExtension(AffiliationNamespace.owner, affiliations);
PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, Type.result, PubSubNamespace.owner);
PubSub response = new PubSub(JidTestUtil.PUBSUB_EXAMPLE_ORG, IQ.Type.result, PubSubNamespace.owner);
response.addExtension(affiliationsExtension);
protocol.addResponse(response);

View file

@ -29,7 +29,6 @@ import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
import org.junit.jupiter.api.Test;
@ -85,21 +84,21 @@ public class SoftwareInfoFormTest extends SmackTestSuite {
@Test
public void faultySoftwareInfoFormsTest() {
DataForm.Builder dataFormbuilder = DataForm.builder(Type.result);
DataForm.Builder dataFormbuilder = DataForm.builder(DataForm.Type.result);
TextSingleFormField formField = FormField.buildHiddenFormType("faulty_formtype");
dataFormbuilder.addField(formField);
assertThrows(IllegalArgumentException.class, () -> {
SoftwareInfoForm.getBuilder().setDataForm(dataFormbuilder.build()).build();
});
DataForm.Builder builderWithoutFormType = DataForm.builder(Type.result);
DataForm.Builder builderWithoutFormType = DataForm.builder(DataForm.Type.result);
assertThrows(IllegalArgumentException.class, () -> {
SoftwareInfoForm.getBuilder().setDataForm(builderWithoutFormType.build()).build();
});
}
public static SoftwareInfoForm createSoftwareInfoFormUsingDataForm() throws URISyntaxException {
DataForm.Builder dataFormBuilder = DataForm.builder(Type.result);
DataForm.Builder dataFormBuilder = DataForm.builder(DataForm.Type.result);
TextSingleFormField formField = FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE);
dataFormBuilder.addField(formField);

View file

@ -30,7 +30,6 @@ import org.jivesoftware.smackx.mediaelement.element.MediaElement;
import org.jivesoftware.smackx.softwareinfo.form.SoftwareInfoForm;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;
import org.jivesoftware.util.ConnectionUtils;
import org.jivesoftware.util.Protocol;
@ -70,7 +69,7 @@ public class SoftwareInfoManagerTest {
}
public static SoftwareInfoForm buildSoftwareInfoFromDataForm() throws URISyntaxException {
DataForm.Builder dataFormBuilder = DataForm.builder(Type.result);
DataForm.Builder dataFormBuilder = DataForm.builder(DataForm.Type.result);
dataFormBuilder.addField(FormField.buildHiddenFormType(SoftwareInfoForm.FORM_TYPE));
dataFormBuilder.addField(FormField.builder("icon")
.addFormFieldChildElement(createMediaElement())

View file

@ -25,7 +25,6 @@ import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormField.Type;
import org.jivesoftware.smackx.xdata.provider.DataFormProvider;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref;
@ -151,6 +150,6 @@ public class DataFormTest extends SmackTestSuite {
public void testFixedField() throws Exception {
final String formWithFixedField = "<x xmlns='jabber:x:data' type='form'><instructions>InstructionTest1</instructions><field type='fixed'><value>Fixed field value</value></field></x>";
DataForm df = pr.parse(PacketParserUtils.getParserFor(formWithFixedField));
assertEquals(Type.fixed, df.getFields().get(0).getType());
assertEquals(FormField.Type.fixed, df.getFields().get(0).getType());
}
}

View file

@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.provider.AbstractProvider;
import org.jivesoftware.smack.test.util.SmackTestSuite;
import org.jivesoftware.smack.test.util.SmackTestUtil;
import org.jivesoftware.smack.xml.XmlPullParserException;
@ -145,7 +146,7 @@ public class DataValidationTest extends SmackTestSuite {
@ParameterizedTest
@EnumSource(SmackTestUtil.XmlPullParserKind.class)
public void testRangeFailure(SmackTestUtil.XmlPullParserKind parserKind) throws IOException, XmlPullParserException {
assertThrows(NumberFormatException.class,
assertThrows(AbstractProvider.NumberFormatParseException.class,
() -> SmackTestUtil.parse(TEST_OUTPUT_FAIL, DataValidationProvider.class, parserKind));
}

View file

@ -39,7 +39,6 @@ import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.StanzaFilter;
import org.jivesoftware.smack.filter.ThreadFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.StringUtils;
@ -110,7 +109,7 @@ public final class ChatManager extends Manager{
@Override
protected boolean acceptSpecific(Message message) {
return normalIncluded ? message.getType() == Type.normal : false;
return normalIncluded ? message.getType() == Message.Type.normal : false;
}
});

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2003-2007 Jive Software, 2016-2019 Florian Schmaus.
* Copyright 2003-2007 Jive Software, 2016-2021 Florian Schmaus.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
@ -54,7 +53,6 @@ import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.filter.ToMatchesFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.PresenceBuilder;
import org.jivesoftware.smack.packet.Stanza;
@ -151,7 +149,17 @@ public final class Roster extends Manager {
private static int defaultNonRosterPresenceMapMaxSize = INITIAL_DEFAULT_NON_ROSTER_PRESENCE_MAP_SIZE;
private RosterStore rosterStore;
private final Map<String, RosterGroup> groups = new ConcurrentHashMap<>();
/**
* The groups of this roster.
* <p>
* Note that we use {@link ConcurrentHashMap} also as static type of this field, since we use the fact that the same
* thread can modify this collection, e.g. remove items, while iterating over it. This is done, for example in
* {@link #deleteEntry(Collection, RosterEntry)}. If we do not denote the static type to ConcurrentHashMap, but
* {@link Map} instead, then error prone would report a ModifyCollectionInEnhancedForLoop but.
* </p>
*/
private final ConcurrentHashMap<String, RosterGroup> groups = new ConcurrentHashMap<>();
/**
* Concurrent hash map from JID to its roster entry.
@ -508,7 +516,7 @@ public final class Roster extends Manager {
return true;
}
protected boolean waitUntilLoaded() throws InterruptedException {
boolean waitUntilLoaded() throws InterruptedException {
long waitTime = connection().getReplyTimeout();
long start = System.currentTimeMillis();
while (!isLoaded()) {
@ -1416,7 +1424,7 @@ public final class Roster extends Manager {
move(user, presenceMap, nonRosterPresenceMap);
deletedEntries.add(user);
for (Entry<String, RosterGroup> e : groups.entrySet()) {
for (Map.Entry<String, RosterGroup> e : groups.entrySet()) {
RosterGroup group = e.getValue();
group.removeEntryLocal(entry);
if (group.getEntryCount() == 0) {
@ -1787,7 +1795,7 @@ public final class Roster extends Manager {
private final class RosterPushListener extends AbstractIqRequestHandler {
private RosterPushListener() {
super(RosterPacket.ELEMENT, RosterPacket.NAMESPACE, Type.set, Mode.sync);
super(RosterPacket.ELEMENT, RosterPacket.NAMESPACE, IQ.Type.set, Mode.sync);
}
@Override

View file

@ -29,7 +29,6 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
import org.jivesoftware.smack.roster.packet.RosterPacket;
import org.jivesoftware.smack.util.EqualsUtil;
@ -221,7 +220,7 @@ public final class RosterEntry extends Manager {
XMPPConnection connection = connection();
Presence unsubscribed = connection.getStanzaFactory().buildPresenceStanza()
.to(item.getJid())
.ofType(Type.unsubscribed)
.ofType(Presence.Type.unsubscribed)
.build();
connection.sendStanza(unsubscribed);
}

View file

@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.MessageBuilder;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaBuilder;
@ -92,7 +91,7 @@ public class ChatConnectionTest {
@Test
public void validateMessageTypeWithDefaults1() {
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.chat);
incomingChat.ofType(Message.Type.chat);
processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat());
}
@ -100,14 +99,14 @@ public class ChatConnectionTest {
@Test
public void validateMessageTypeWithDefaults2() {
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.normal);
incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat());
}
@Test
public void validateMessageTypeWithDefaults3() {
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.groupchat);
incomingChat.ofType(Message.Type.groupchat);
processServerMessage(incomingChat.build());
assertNull(listener.getNewChat());
}
@ -115,7 +114,7 @@ public class ChatConnectionTest {
@Test
public void validateMessageTypeWithDefaults4() {
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.headline);
incomingChat.ofType(Message.Type.headline);
assertNull(listener.getNewChat());
}
@ -123,7 +122,7 @@ public class ChatConnectionTest {
public void validateMessageTypeWithNoNormal1() {
cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.chat);
incomingChat.ofType(Message.Type.chat);
processServerMessage(incomingChat.build());
assertNotNull(listener.getNewChat());
}
@ -132,7 +131,7 @@ public class ChatConnectionTest {
public void validateMessageTypeWithNoNormal2() {
cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket("134", true);
incomingChat.ofType(Type.normal);
incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build());
assertNull(listener.getNewChat());
}
@ -318,7 +317,7 @@ public class ChatConnectionTest {
cm.setNormalIncluded(false);
MessageBuilder incomingChat = createChatPacket(null, false);
incomingChat.ofType(Type.normal);
incomingChat.ofType(Message.Type.normal);
processServerMessage(incomingChat.build());
assertNull(listener.getNewChat());

View file

@ -35,7 +35,6 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.im.InitSmackIm;
import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError.Condition;
@ -385,7 +384,7 @@ public class RosterTest extends InitSmackIm {
public void testIgnoreInvalidFrom() throws XmppStringprepException {
final BareJid spammerJid = JidCreate.entityBareFrom("spam@example.com");
RosterPacket packet = new RosterPacket();
packet.setType(Type.set);
packet.setType(IQ.Type.set);
packet.setTo(connection.getUser());
packet.setFrom(JidCreate.entityBareFrom("mallory@example.com"));
packet.addRosterItem(new Item(spammerJid, "Cool products!"));
@ -530,7 +529,7 @@ public class RosterTest extends InitSmackIm {
for (RosterEntry entry : roster.getEntries()) {
// prepare the roster push packet
final RosterPacket rosterPush = new RosterPacket();
rosterPush.setType(Type.set);
rosterPush.setType(IQ.Type.set);
rosterPush.setTo(connection.getUser());
// prepare the buddy's item entry which should be removed
@ -555,7 +554,7 @@ public class RosterTest extends InitSmackIm {
roster.reload();
while (true) {
final Stanza sentPacket = connection.getSentPacket();
if (sentPacket instanceof RosterPacket && ((IQ) sentPacket).getType() == Type.get) {
if (sentPacket instanceof RosterPacket && ((IQ) sentPacket).getType() == IQ.Type.get) {
// setup the roster get request
final RosterPacket rosterRequest = (RosterPacket) sentPacket;
assertSame("The <query/> element MUST NOT contain any <item/> child elements!",
@ -565,7 +564,7 @@ public class RosterTest extends InitSmackIm {
// prepare the roster result
final RosterPacket rosterResult = new RosterPacket();
rosterResult.setTo(connection.getUser());
rosterResult.setType(Type.result);
rosterResult.setType(IQ.Type.result);
rosterResult.setStanzaId(rosterRequest.getStanzaId());
// prepare romeo's roster entry
@ -674,7 +673,7 @@ public class RosterTest extends InitSmackIm {
try {
while (true) {
final Stanza packet = connection.getSentPacket();
if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.set) {
if (packet instanceof RosterPacket && ((IQ) packet).getType() == IQ.Type.set) {
final RosterPacket rosterRequest = (RosterPacket) packet;
// Prepare and process the roster push
@ -683,7 +682,7 @@ public class RosterTest extends InitSmackIm {
if (item.getItemType() != ItemType.remove) {
item.setItemType(ItemType.none);
}
rosterPush.setType(Type.set);
rosterPush.setType(IQ.Type.set);
rosterPush.setTo(connection.getUser());
rosterPush.addRosterItem(item);
connection.processStanza(rosterPush);

View file

@ -30,7 +30,6 @@ import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.RosterTest.TestRosterListener;
import org.jivesoftware.smack.roster.packet.RosterPacket;
@ -146,7 +145,7 @@ public class RosterVersioningTest {
RosterPacket sentRP = (RosterPacket) sentPacket;
RosterPacket answer = new RosterPacket();
answer.setStanzaId(sentRP.getStanzaId());
answer.setType(Type.result);
answer.setType(IQ.Type.result);
answer.setTo(sentRP.getFrom());
answer.setVersion("newVersion");
@ -188,7 +187,7 @@ public class RosterVersioningTest {
{
RosterPacket rosterPush = new RosterPacket();
rosterPush.setTo(JidCreate.from("rostertest@example.com/home"));
rosterPush.setType(Type.set);
rosterPush.setType(IQ.Type.set);
rosterPush.setVersion("v97");
Item pushedItem = vaglafItem();
@ -214,7 +213,7 @@ public class RosterVersioningTest {
{
RosterPacket rosterPush = new RosterPacket();
rosterPush.setTo(JidCreate.from("rostertest@example.com/home"));
rosterPush.setType(Type.set);
rosterPush.setType(IQ.Type.set);
rosterPush.setVersion("v98");
Item item = new Item(JidCreate.entityBareFrom("vaglaf@example.com"), "vaglaf the only");

View file

@ -26,7 +26,6 @@ import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
import org.jivesoftware.smack.im.InitSmackIm;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.RosterTest.TestRosterListener;
@ -161,7 +160,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
try {
while (true) {
final Stanza packet = connection.getSentPacket();
if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.set) {
if (packet instanceof RosterPacket && ((IQ) packet).getType() == IQ.Type.set) {
final RosterPacket rosterRequest = (RosterPacket) packet;
// Prepare and process the roster push
@ -170,7 +169,7 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
if (item.getItemType() != ItemType.remove) {
item.setItemType(ItemType.none);
}
rosterPush.setType(Type.set);
rosterPush.setType(IQ.Type.set);
rosterPush.setTo(connection.getUser());
rosterPush.addRosterItem(item);
connection.processStanza(rosterPush);

View file

@ -24,7 +24,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Logger;
@ -447,7 +447,7 @@ public final class Configuration {
// Properties set via the system override the file properties
Properties systemProperties = System.getProperties();
for (Entry<Object, Object> entry : systemProperties.entrySet()) {
for (Map.Entry<Object, Object> entry : systemProperties.entrySet()) {
String key = (String) entry.getKey();
if (!key.startsWith(SINTTEST)) {
continue;

Some files were not shown because too many files have changed in this diff Show more