List of usage examples for java.io InvalidObjectException InvalidObjectException
public InvalidObjectException(String reason)
InvalidObjectException
. From source file:org.protempa.proposition.TemporalProposition.java
/** * Called while deserializing a temporal proposition. * /*w w w . j av a2s . c o m*/ * @param s * an {@link ObjectInputStream}. * @throws IOException * input/output error during deserialization. * @throws ClassNotFoundException * class of a serialized object cannot be found. */ protected void readTemporalProposition(ObjectInputStream s) throws IOException, ClassNotFoundException { int mode = s.readChar(); try { switch (mode) { case 0: setInterval(INTERVAL_FACTORY.getInstance(s.readLong(), (Granularity) s.readObject())); break; case 1: setInterval(INTERVAL_FACTORY.getInstance(s.readLong(), (Granularity) s.readObject(), s.readLong(), (Granularity) s.readObject())); break; case 2: setInterval(INTERVAL_FACTORY.getInstance((Long) s.readObject(), (Long) s.readObject(), (Granularity) s.readObject(), (Long) s.readObject(), (Long) s.readObject(), (Granularity) s.readObject())); break; default: throw new InvalidObjectException("Can't restore. Invalid mode: " + mode); } } catch (IllegalArgumentException iae) { throw new InvalidObjectException("Can't restore: " + iae.getMessage()); } }
From source file:org.protempa.proposition.AbstractProposition.java
protected void readAbstractProposition(ObjectInputStream s) throws IOException, ClassNotFoundException { String tempId = (String) s.readObject(); UniqueId tempUniqueId = (UniqueId) s.readObject(); if (tempUniqueId == null) { throw new InvalidObjectException("Can't restore. All propositions must have an unique id"); }// www .j a v a2s .c o m initializeAbstractProposition(tempId, tempUniqueId); int numProperties = s.readInt(); if (numProperties < 0) { throw new InvalidObjectException("Negative properties count. Can't restore"); } if (numProperties > 0) { for (int i = 0; i < numProperties; i++) { String propertyName = (String) s.readObject(); Value val = (Value) s.readObject(); if (val != null) { val = val.replace(); } setProperty(propertyName, val); } } int numRefs = s.readInt(); if (numRefs < 0) { throw new InvalidObjectException("Negative reference count. Can't restore"); } if (numRefs > 0) { for (int i = 0; i < numRefs; i++) { String refName = (String) s.readObject(); int numUids = s.readInt(); if (numUids < 0) { throw new InvalidObjectException("Negative unique identifier count. Can't restore"); } List<UniqueId> uids = new ArrayList<>(numUids); for (int j = 0; j < numUids; j++) { uids.add((UniqueId) s.readObject()); } setReferences(refName, uids); } } setSourceSystem((SourceSystem) s.readObject()); this.changes = (PropertyChangeSupport) s.readObject(); }
From source file:com.microsoft.azure.management.datalake.store.uploader.UploadMetadata.java
/** * Deletes the metadata file from disk./* w w w . java 2 s . c o m*/ * * @throws InvalidObjectException Thrown if the metadata file path has not yet been set. */ public void deleteFile() throws InvalidObjectException { if (this.metadataFilePath == null || StringUtils.isEmpty(this.metadataFilePath)) { throw new InvalidObjectException( "Null or empty metadataFilePath. Cannot delete metadata until this property is set."); } File curMetadata = new File(this.metadataFilePath); if (curMetadata.exists()) { curMetadata.delete(); } }
From source file:com.phoenixst.plexus.DefaultGraph.java
/** * Deserialize this <code>DefaultGraph</code>. * * @serialData the number of nodes (int), all the nodes, the * number of edges (int), all the edges. *///ww w . j av a 2 s . com private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { in.defaultReadObject(); observableDelegate = new ObservableGraphDelegate(this, EVENT_LOGGER); int nodeSize = in.readInt(); if (nodeSize < 0) { throw new InvalidObjectException("Node size is less than 0: " + nodeSize); } nodeMap = new HashMap(nodeSize); if (LOGGER.isInfoEnabled()) { LOGGER.info("Deserializing " + instanceString); } for (int i = 0; i < nodeSize; i++) { Object node = in.readObject(); if (nodeMap.containsKey(node)) { throw new InvalidObjectException("Duplicate node: " + node); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + " deserialization: Adding node " + node); } nodeMap.put(node, new AdjacencyList(node)); } edgeSize = in.readInt(); if (edgeSize < 0) { throw new InvalidObjectException("Edge size is less than 0: " + edgeSize); } for (int i = 0; i < edgeSize; i++) { Graph.Edge edge = (Graph.Edge) in.readObject(); AdjacencyList tailAdj = (AdjacencyList) nodeMap.get(edge.getTail()); if (tailAdj == null) { throw new InvalidObjectException("Graph.Edge tail is not a node: " + edge.getTail()); } if (tailAdj.contains(edge)) { throw new InvalidObjectException("Duplicate edge: " + edge); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(" " + instanceString + " deserialization: Adding edge " + edge); } tailAdj.edges.add(edge); if (!GraphUtils.equals(edge.getTail(), edge.getHead())) { AdjacencyList headAdj = (AdjacencyList) nodeMap.get(edge.getHead()); if (headAdj == null) { throw new InvalidObjectException("Graph.Edge head is not a node: " + edge.getHead()); } headAdj.edges.add(edge); } } }
From source file:org.protempa.CompoundLowLevelAbstractionDefinition.java
@SuppressWarnings("unchecked") private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject();/*from w w w . ja va 2 s . c om*/ if (this.minimumNumberOfValues < 1) { throw new InvalidObjectException("minimumNumberOfValues must be > 0"); } initInstance(); int numValueClassifications = s.readInt(); for (int i = 0; i < numValueClassifications; i++) { ValueClassification vc = (ValueClassification) s.readObject(); if (vc != null) { addValueClassification(vc); } else { throw new InvalidObjectException("null ValueClassification"); } } }
From source file:com.daskiworks.ghwatch.backend.RemoteSystemClient.java
protected static void processStandardHttpResponseCodes(HttpResponse httpResponse) throws AuthenticationException, IOException { int code = httpResponse.getStatusLine().getStatusCode(); Log.d(TAG, "Response http code: " + code); if (code >= 200 && code <= 299) return;// w w w .jav a 2 s .c om if (code == HttpStatus.SC_UNAUTHORIZED || code == HttpStatus.SC_FORBIDDEN) { String OTP = getHeaderValue(httpResponse.getFirstHeader("X-GitHub-OTP")); if (code == HttpStatus.SC_UNAUTHORIZED && OTP != null && OTP.contains("required")) { throw new OTPAuthenticationException(Utils.trimToNull(OTP.replace("required;", ""))); } throw new AuthenticationException( "Authentication problem: " + getResponseContentAsString(httpResponse)); } else if (code == HttpStatus.SC_BAD_REQUEST || code == HttpStatus.SC_NOT_FOUND) { throw new InvalidObjectException( "HttpCode=" + code + " message: " + getResponseContentAsString(httpResponse)); } else { throw new IOException("HttpCode=" + code + " message: " + getResponseContentAsString(httpResponse)); } }
From source file:com.healthmarketscience.rmiio.DirectRemoteInputStream.java
/** * Throws an InvalidObjectException if the given chunkSize is invalid. *//*w ww.j a v a2 s . co m*/ private static void checkChunkSize(int chunkSize) throws IOException { if (chunkSize <= 0) { throw new InvalidObjectException("invalid chunk size " + chunkSize); } }
From source file:com.healthmarketscience.rmiio.DirectRemoteInputStream.java
/** * Copies the given number of bytes from the given InputStream to the given * OutputStream using the given buffer for transfer. The given InputStream * is expected to have at least this many bytes left to read, otherwise an * InvalidObjectException will be thrown. */// w ww.ja va 2s .c o m private static void copy(InputStream in, OutputStream out, byte[] buffer, int length) throws IOException { while (length > 0) { int readLen = in.read(buffer, 0, Math.min(buffer.length, length)); if (readLen < 0) { throw new InvalidObjectException("input stream data truncated"); } out.write(buffer, 0, readLen); length -= readLen; } }
From source file:com.google.cloud.dataflow.sdk.io.AvroSource.java
@SuppressWarnings("unused") private Object readResolve() throws ObjectStreamException { switch (getMode()) { case SINGLE_FILE_OR_SUBRANGE: return new AvroSource<>(getFileOrPatternSpec(), getMinBundleSize(), getStartOffset(), getEndOffset(), readSchemaString, type, codec, syncMarker, fileSchemaString); case FILEPATTERN: return new AvroSource<>(getFileOrPatternSpec(), getMinBundleSize(), readSchemaString, type, codec, syncMarker);//from w ww .j a va 2 s . c o m default: throw new InvalidObjectException(String.format("Unknown mode %s for AvroSource %s", getMode(), this)); } }
From source file:org.apache.beam.sdk.io.AvroSource.java
@SuppressWarnings("unused") private Object readResolve() throws ObjectStreamException { switch (getMode()) { case SINGLE_FILE_OR_SUBRANGE: return new AvroSource<>(getSingleFileMetadata(), getMinBundleSize(), getStartOffset(), getEndOffset(), readSchemaString, type, codec, syncMarker, fileSchemaString); case FILEPATTERN: return new AvroSource<>(getFileOrPatternSpec(), getMinBundleSize(), readSchemaString, type, codec, syncMarker);/*from ww w .j a v a2 s . c o m*/ default: throw new InvalidObjectException(String.format("Unknown mode %s for AvroSource %s", getMode(), this)); } }