Java Code Examples for com.google.ipc.invalidation.external.client.types.ErrorInfo#newInstance()
The following examples show how to use
com.google.ipc.invalidation.external.client.types.ErrorInfo#newInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvalidationClientCore.java From 365browser with Apache License 2.0 | 5 votes |
/** Handles an error message. */ private void handleErrorMessage(ServerMessageHeader header, int code, String description) { Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread"); // If it is an auth failure, we shut down the ticl. logger.severe("Received error message: %s, %s, %s", header, code, description); // Translate the code to error reason. int reason; switch (code) { case ErrorMessage.Code.AUTH_FAILURE: reason = ErrorInfo.ErrorReason.AUTH_FAILURE; break; case ErrorMessage.Code.UNKNOWN_FAILURE: default: reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE; break; } // Issue an informError to the application. ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null); listener.informError(this, errorInfo); // If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing. if (code != ErrorMessage.Code.AUTH_FAILURE) { return; } // If there are any registrations, remove them and issue registration failure. Collection<ObjectIdP> desiredRegistrations = registrationManager.removeRegisteredObjects(); logger.warning("Issuing failure for %s objects", desiredRegistrations.size()); for (ObjectIdP objectId : desiredRegistrations) { listener.informRegistrationFailure(this, ProtoWrapperConverter.convertFromObjectIdProto(objectId), false, "Auth error: " + description); } }
Example 2
Source File: ParcelableErrorInfo.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a new ErrorInfo wrapper by reading data from a parcel. */ public ParcelableErrorInfo(Parcel in) { int reason = in.readInt(); boolean isTransient = in.createBooleanArray()[0]; String message = in.readString(); this.errorInfo = ErrorInfo.newInstance(reason, isTransient, message, null); }
Example 3
Source File: ParcelableErrorInfo.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a new ErrorInfo wrapper by reading data from a parcel. */ public ParcelableErrorInfo(Parcel in) { int reason = in.readInt(); boolean isTransient = in.createBooleanArray()[0]; String message = in.readString(); this.errorInfo = ErrorInfo.newInstance(reason, isTransient, message, null); }
Example 4
Source File: AndroidInvalidationListenerIntentMapper.java From 365browser with Apache License 2.0 | 4 votes |
/** * Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching * to the appropriate method on the {@link #listener}. */ public void handleIntent(Intent intent) { // TODO: use wakelocks // Unmarshall the arguments from the Intent and make the appropriate call on the listener. ListenerUpcall upcall = tryParseIntent(intent); if (upcall == null) { return; } if (upcall.hasReady()) { listener.ready(client); } else if (upcall.getNullableInvalidate() != null) { // Handle all invalidation-related upcalls on a common path, since they require creating // an AckHandleP. onInvalidateUpcall(upcall.getNullableInvalidate(), listener); } else if (upcall.getNullableRegistrationStatus() != null) { RegistrationStatusUpcall regStatus = upcall.getNullableRegistrationStatus(); listener.informRegistrationStatus(client, ProtoWrapperConverter.convertFromObjectIdProto(regStatus.getObjectId()), regStatus.getIsRegistered() ? RegistrationState.REGISTERED : RegistrationState.UNREGISTERED); } else if (upcall.getNullableRegistrationFailure() != null) { RegistrationFailureUpcall failure = upcall.getNullableRegistrationFailure(); listener.informRegistrationFailure(client, ProtoWrapperConverter.convertFromObjectIdProto(failure.getObjectId()), failure.getTransient(), failure.getMessage()); } else if (upcall.getNullableReissueRegistrations() != null) { ReissueRegistrationsUpcall reissueRegs = upcall.getNullableReissueRegistrations(); listener.reissueRegistrations(client, reissueRegs.getPrefix().getByteArray(), reissueRegs.getLength()); } else if (upcall.getNullableError() != null) { ErrorUpcall error = upcall.getNullableError(); ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(), error.getErrorMessage(), null); listener.informError(client, errorInfo); } else { logger.warning("Dropping listener Intent with unknown call: %s", upcall); } }
Example 5
Source File: TiclService.java From 365browser with Apache License 2.0 | 4 votes |
/** Informs the listener of a non-retryable {@code error}. */ private void informListenerOfPermanentError(final String error) { ErrorInfo errorInfo = ErrorInfo.newInstance(0, false, error, null); Intent errorIntent = ProtocolIntents.ListenerUpcalls.newErrorIntent(errorInfo); IntentForwardingListener.issueIntent(this, errorIntent); }
Example 6
Source File: AndroidInvalidationListenerIntentMapper.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching * to the appropriate method on the {@link #listener}. */ public void handleIntent(Intent intent) { // TODO: use wakelocks // Unmarshall the arguments from the Intent and make the appropriate call on the listener. ListenerUpcall upcall = tryParseIntent(intent); if (upcall == null) { return; } if (upcall.hasReady()) { listener.ready(client); } else if (upcall.hasInvalidate()) { // Handle all invalidation-related upcalls on a common path, since they require creating // an AckHandleP. onInvalidateUpcall(upcall, listener); } else if (upcall.hasRegistrationStatus()) { RegistrationStatusUpcall regStatus = upcall.getRegistrationStatus(); listener.informRegistrationStatus(client, ProtoConverter.convertFromObjectIdProto(regStatus.getObjectId()), regStatus.getIsRegistered() ? RegistrationState.REGISTERED : RegistrationState.UNREGISTERED); } else if (upcall.hasRegistrationFailure()) { RegistrationFailureUpcall failure = upcall.getRegistrationFailure(); listener.informRegistrationFailure(client, ProtoConverter.convertFromObjectIdProto(failure.getObjectId()), failure.getTransient(), failure.getMessage()); } else if (upcall.hasReissueRegistrations()) { ReissueRegistrationsUpcall reissueRegs = upcall.getReissueRegistrations(); listener.reissueRegistrations(client, reissueRegs.getPrefix().toByteArray(), reissueRegs.getLength()); } else if (upcall.hasError()) { ErrorUpcall error = upcall.getError(); ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(), error.getErrorMessage(), null); listener.informError(client, errorInfo); } else { logger.warning("Dropping listener Intent with unknown call: %s", upcall); } }
Example 7
Source File: TiclService.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Informs the listener of a non-retryable {@code error}. */ private void informListenerOfPermanentError(final String error) { ErrorInfo errorInfo = ErrorInfo.newInstance(0, false, error, null); Intent errorIntent = ProtocolIntents.ListenerUpcalls.newErrorIntent(errorInfo); IntentForwardingListener.issueIntent(this, errorIntent); }
Example 8
Source File: InvalidationClientCore.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Handles an error message. */ private void handleErrorMessage(ServerMessageHeader header, ErrorMessage.Code code, String description) { Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread"); // If it is an auth failure, we shut down the ticl. logger.severe("Received error message: %s, %s, %s", header, code, description); // Translate the code to error reason. int reason; switch (code) { case AUTH_FAILURE: reason = ErrorInfo.ErrorReason.AUTH_FAILURE; break; case UNKNOWN_FAILURE: reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE; break; default: reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE; break; } // Issue an informError to the application. ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null); listener.informError(this, errorInfo); // If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing. if (code != ErrorMessage.Code.AUTH_FAILURE) { return; } // If there are any registrations, remove them and issue registration failure. Collection<ProtoWrapper<ObjectIdP>> desiredRegistrations = registrationManager.removeRegisteredObjects(); logger.warning("Issuing failure for %s objects", desiredRegistrations.size()); for (ProtoWrapper<ObjectIdP> objectIdWrapper : desiredRegistrations) { ObjectIdP objectId = objectIdWrapper.getProto(); listener.informRegistrationFailure(this, ProtoConverter.convertFromObjectIdProto(objectId), false, "Auth error: " + description); } }
Example 9
Source File: AndroidInvalidationListenerIntentMapper.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Handles a listener upcall by decoding the protocol buffer in {@code intent} and dispatching * to the appropriate method on the {@link #listener}. */ public void handleIntent(Intent intent) { // TODO: use wakelocks // Unmarshall the arguments from the Intent and make the appropriate call on the listener. ListenerUpcall upcall = tryParseIntent(intent); if (upcall == null) { return; } if (upcall.hasReady()) { listener.ready(client); } else if (upcall.hasInvalidate()) { // Handle all invalidation-related upcalls on a common path, since they require creating // an AckHandleP. onInvalidateUpcall(upcall, listener); } else if (upcall.hasRegistrationStatus()) { RegistrationStatusUpcall regStatus = upcall.getRegistrationStatus(); listener.informRegistrationStatus(client, ProtoConverter.convertFromObjectIdProto(regStatus.getObjectId()), regStatus.getIsRegistered() ? RegistrationState.REGISTERED : RegistrationState.UNREGISTERED); } else if (upcall.hasRegistrationFailure()) { RegistrationFailureUpcall failure = upcall.getRegistrationFailure(); listener.informRegistrationFailure(client, ProtoConverter.convertFromObjectIdProto(failure.getObjectId()), failure.getTransient(), failure.getMessage()); } else if (upcall.hasReissueRegistrations()) { ReissueRegistrationsUpcall reissueRegs = upcall.getReissueRegistrations(); listener.reissueRegistrations(client, reissueRegs.getPrefix().toByteArray(), reissueRegs.getLength()); } else if (upcall.hasError()) { ErrorUpcall error = upcall.getError(); ErrorInfo errorInfo = ErrorInfo.newInstance(error.getErrorCode(), error.getIsTransient(), error.getErrorMessage(), null); listener.informError(client, errorInfo); } else { logger.warning("Dropping listener Intent with unknown call: %s", upcall); } }
Example 10
Source File: TiclService.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Informs the listener of a non-retryable {@code error}. */ private void informListenerOfPermanentError(final String error) { ErrorInfo errorInfo = ErrorInfo.newInstance(0, false, error, null); Intent errorIntent = ProtocolIntents.ListenerUpcalls.newErrorIntent(errorInfo); IntentForwardingListener.issueIntent(this, errorIntent); }
Example 11
Source File: InvalidationClientCore.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** Handles an error message. */ private void handleErrorMessage(ServerMessageHeader header, ErrorMessage.Code code, String description) { Preconditions.checkState(internalScheduler.isRunningOnThread(), "Not on internal thread"); // If it is an auth failure, we shut down the ticl. logger.severe("Received error message: %s, %s, %s", header, code, description); // Translate the code to error reason. int reason; switch (code) { case AUTH_FAILURE: reason = ErrorInfo.ErrorReason.AUTH_FAILURE; break; case UNKNOWN_FAILURE: reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE; break; default: reason = ErrorInfo.ErrorReason.UNKNOWN_FAILURE; break; } // Issue an informError to the application. ErrorInfo errorInfo = ErrorInfo.newInstance(reason, false, description, null); listener.informError(this, errorInfo); // If this is an auth failure, remove registrations and stop the Ticl. Otherwise do nothing. if (code != ErrorMessage.Code.AUTH_FAILURE) { return; } // If there are any registrations, remove them and issue registration failure. Collection<ProtoWrapper<ObjectIdP>> desiredRegistrations = registrationManager.removeRegisteredObjects(); logger.warning("Issuing failure for %s objects", desiredRegistrations.size()); for (ProtoWrapper<ObjectIdP> objectIdWrapper : desiredRegistrations) { ObjectIdP objectId = objectIdWrapper.getProto(); listener.informRegistrationFailure(this, ProtoConverter.convertFromObjectIdProto(objectId), false, "Auth error: " + description); } }