Package com.cedarsoft.couchdb

Examples of com.cedarsoft.couchdb.UniqueId


   *
   * @noinspection NullableProblems
   */
  @Nonnull
  public UniqueId getCurrent() throws IllegalStateException {
    @Nullable final UniqueId copy = current;
    if ( copy == null ) {
      throw new IllegalStateException( "No current id available" );
    }
    return copy;
  }
View Full Code Here


    wrapper.nextFieldValue( "_id" );
    final DocId id = new DocId( wrapper.getText() );
    wrapper.nextFieldValue( "_rev" );
    final Revision revision = new Revision( wrapper.getText() );

    current = new UniqueId( id, revision );
  }
View Full Code Here

  public ActionResponse deserialize( @Nonnull ClientResponse response ) throws VersionException {
    if ( !MediaType.APPLICATION_JSON_TYPE.equals( response.getType() ) ) {
      throw new IllegalStateException( "Invalid media type: " + response.getType() );
    }

    UniqueId uniqueId = deserialize( response.getEntityInputStream() );

    return new ActionResponse( uniqueId, response.getStatus(), response.getLocation() );
  }
View Full Code Here

      JsonFactory jsonFactory = JacksonSupport.getJsonFactory();

      JsonParser parser = jsonFactory.createJsonParser( in );
      AbstractJacksonSerializer.nextToken( parser, JsonToken.START_OBJECT );

      UniqueId deserialized = deserialize( parser );

      AbstractJacksonSerializer.ensureParserClosedObject( parser );

      return deserialized;
    } catch ( IOException e ) {
View Full Code Here

    AbstractJacksonSerializer.nextFieldValue( deserializeFrom, PROPERTY_ID );
    String id = deserializeFrom.getText();
    AbstractJacksonSerializer.nextFieldValue( deserializeFrom, PROPERTY_REV );
    String rev = deserializeFrom.getText();
    AbstractJacksonSerializer.closeObject( deserializeFrom );
    return new UniqueId( new DocId( id ), new Revision( rev ) );

    //    AbstractJacksonSerializer.nextToken( deserializeFrom, JsonToken.FIELD_NAME );
    //    if ( deserializeFrom.getCurrentName().equals( PROPERTY_OK ) ) {
    //    } else {
    //      AbstractJacksonSerializer.nextToken( deserializeFrom, JsonToken.VALUE_STRING );
View Full Code Here

    delegate.serialize( serializeTo, object, formatVersion );
  }

  @Override
  protected void beforeTypeAndVersion( @Nonnull T object, @Nonnull JsonGenerator serializeTo ) throws IOException {
    UniqueId uniqueId = getUniqueId();

    serializeTo.writeStringField( "_id", uniqueId.getId().asString() );
    serializeTo.writeStringField( "_rev", uniqueId.getRevision().asString() );
    super.beforeTypeAndVersion( object, serializeTo );
  }
View Full Code Here

   * @param id       the document id
   * @param revision the revision
   * @noinspection MethodOverloadsMethodOfSuperclass
   */
  public void serialize( @Nonnull T object, @WillNotClose @Nonnull OutputStream out, @Nonnull DocId id, @Nonnull Revision revision ) throws IOException {
    storeUniqueId( new UniqueId( id, revision ) );
    super.serialize( object, out );
  }
View Full Code Here

    uniqueIdThreadLocal.set( uniqueId );
  }

  @Nonnull
  private static UniqueId getUniqueId() {
    @Nullable UniqueId resolved = uniqueIdThreadLocal.get();
    if ( resolved == null ) {
      throw new IllegalStateException( "No unique id found" );
    }

    uniqueIdThreadLocal.remove();
View Full Code Here

    wrapper.nextFieldValue( "_id" );
    final DocId id = new DocId( wrapper.getText() );
    wrapper.nextFieldValue( "_rev" );
    final Revision revision = new Revision( wrapper.getText() );

    current = new UniqueId( id, revision );
  }
View Full Code Here

   *
   * @noinspection NullableProblems
   */
  @Nonnull
  public UniqueId getCurrent() throws IllegalStateException {
    @Nullable final UniqueId copy = current;
    if ( copy == null ) {
      throw new IllegalStateException( "No current id available" );
    }
    return copy;
  }
View Full Code Here

TOP

Related Classes of com.cedarsoft.couchdb.UniqueId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.