Package com.opengamma.master.config

Examples of com.opengamma.master.config.ConfigDocument


  //-------------------------------------------------------------------------
  @DELETE
  @Produces(MediaType.TEXT_HTML)
  public Response deleteHTML() {
    final ConfigDocument doc = data().getConfig();
    if (doc.isLatest() == false) {
      return Response.status(Status.FORBIDDEN).entity(getHTML()).build();
    }
    data().getConfigMaster().remove(doc.getUniqueId());
    final URI uri = WebConfigsResource.uri(data());
    return Response.seeOther(uri).build();
  }
View Full Code Here


  }

  @DELETE
  @Produces(MediaType.APPLICATION_JSON)
  public Response deleteJSON() {
    final ConfigDocument doc = data().getConfig();
    if (doc.isLatest()) {
      data().getConfigMaster().remove(doc.getUniqueId());
    }
    return Response.ok().build();
  }
View Full Code Here

   * @return the output root data, not null
   */
  @Override
  protected FlexiBean createRootData() {
    final FlexiBean out = super.createRootData();
    final ConfigDocument doc = data().getConfig();
    out.put("configDoc", doc);
    out.put("config", doc.getConfig().getValue());
    out.put("configDescription", getConfigTypesProvider().getDescription(doc.getConfig().getType()));
    out.put("deleted", !doc.isLatest());
    return out;
  }
View Full Code Here

    final ConfigItem<BloombergSecurityTypeDefinition> configItem = ConfigItem.of(DEFAULT_CONFIG, _configName);

    final ConfigSearchRequest<BloombergSecurityTypeDefinition> req = new ConfigSearchRequest<BloombergSecurityTypeDefinition>();
    req.setType(BloombergSecurityTypeDefinition.class);
    req.setName(configItem.getName());
    final ConfigDocument configDocument = new ConfigDocument(configItem);
    final ConfigSearchResult<BloombergSecurityTypeDefinition> res = getConfigMaster().search(req);
    if (res.getDocuments().isEmpty()) {
      getConfigMaster().add(configDocument);
    } else {
      configDocument.setUniqueId(res.getDocuments().get(0).getUniqueId());
      getConfigMaster().update(configDocument);
    }
  }
View Full Code Here

  }

  @POST
  @Path("configs")
  public Response add(@Context UriInfo uriInfo, ConfigDocument request) {
    ConfigDocument result = getConfigMaster().add(request);
    URI createdUri = DataConfigResource.uriVersion(uriInfo.getBaseUri(), result.getUniqueId());
    return responseCreatedFudge(createdUri, result);
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Override
  public ConfigDocument get(final ObjectIdentifiable objectId, final VersionCorrection versionCorrection) {
    ArgumentChecker.notNull(objectId, "objectId");
    ArgumentChecker.notNull(versionCorrection, "versionCorrection");
    final ConfigDocument document = _store.get(objectId.getObjectId());
    if (document == null) {
      throw new DataNotFoundException("Config not found: " + objectId);
    }
    return document;
  }
View Full Code Here

    final ObjectId objectId = _objectIdSupplier.get();
    final UniqueId uniqueId = objectId.atVersion(Long.toString(_versions.incrementAndGet()));
    final Instant now = Instant.now();
    item.setUniqueId(uniqueId);
    IdUtils.setInto(item.getValue(), uniqueId);
    final ConfigDocument doc = new ConfigDocument(item);
    doc.setConfig(document.getConfig());
    doc.setUniqueId(uniqueId);
    doc.setVersionFromInstant(now);
    _store.put(objectId, doc);
    _changeManager.entityChanged(ChangeType.ADDED, objectId, doc.getVersionFromInstant(), doc.getVersionToInstant(), now);
    return doc;
  }
View Full Code Here

    ArgumentChecker.notNull(document.getConfig(), "document.object");
    ArgumentChecker.notNull(document.getConfig().getValue(), "document.object.value");

    UniqueId uniqueId = document.getUniqueId();
    final Instant now = Instant.now();
    final ConfigDocument storedDocument = _store.get(uniqueId.getObjectId());
    if (storedDocument == null) {
      throw new DataNotFoundException("Config not found: " + uniqueId);
    }
    document.setVersionFromInstant(now);
    document.setVersionToInstant(null);
View Full Code Here

  //-------------------------------------------------------------------------
  @Override
  public ConfigDocument get(final UniqueId uniqueId) {
    ArgumentChecker.notNull(uniqueId, "document.uniqueId");
    final ConfigDocument document = _store.get(uniqueId.getObjectId());
    if (document == null) {
      throw new DataNotFoundException("Config not found: " + uniqueId.getObjectId());
    }
    return document;
  }
View Full Code Here

      validateDocument(replacementDocument);
    }
    final Instant now = Instant.now();
    ArgumentChecker.isTrue(MasterUtils.checkUniqueVersionsFrom(replacementDocuments), "No two versioned documents may have the same \"version from\" instant");

    final ConfigDocument storedDocument = _store.get(objectId.getObjectId());
    if (storedDocument == null) {
      throw new DataNotFoundException("Document not found: " + objectId.getObjectId());
    }

    if (replacementDocuments.isEmpty()) {
      _store.remove(objectId.getObjectId());
      _changeManager.entityChanged(ChangeType.REMOVED, objectId.getObjectId(), null, null, now);
      return Collections.emptyList();
    } else {
      final Instant storedVersionFrom = storedDocument.getVersionFromInstant();
      final Instant storedVersionTo = storedDocument.getVersionToInstant();

      final List<ConfigDocument> orderedReplacementDocuments = MasterUtils.adjustVersionInstants(now, storedVersionFrom, storedVersionTo, replacementDocuments);

      final ConfigDocument lastReplacementDocument = orderedReplacementDocuments.get(orderedReplacementDocuments.size() - 1);

      if (_store.replace(objectId.getObjectId(), storedDocument, lastReplacementDocument) == false) {
        throw new IllegalArgumentException("Concurrent modification");
      }
      return ImmutableList.of(lastReplacementDocument.getUniqueId());
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.master.config.ConfigDocument

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.