Examples of CapabilityStorageItem


Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

  {
    final Map<String, String> oldProps = Maps.newHashMap();
    oldProps.put("p1", "v1");
    oldProps.put("p2", "v2");

    final CapabilityStorageItem item = new CapabilityStorageItem(
        0, CAPABILITY_TYPE.toString(), true, null, oldProps
    );
    when(capabilityStorage.getAll()).thenReturn(ImmutableMap.of(capabilityIdentity("foo"), item));

    final CapabilityDescriptor descriptor = mock(CapabilityDescriptor.class);
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

  {
    final Map<String, String> oldProps = Maps.newHashMap();
    oldProps.put("p1", "v1");
    oldProps.put("p2", "v2");

    final CapabilityStorageItem item = new CapabilityStorageItem(
        0, CAPABILITY_TYPE.toString(), true, null, oldProps
    );
    when(capabilityStorage.getAll()).thenReturn(ImmutableMap.of(capabilityIdentity("foo"), item));

    final CapabilityDescriptor descriptor = mock(CapabilityDescriptor.class);
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

  {
    final Map<String, String> oldProps = Maps.newHashMap();
    oldProps.put("p1", "v1");
    oldProps.put("p2", "v2");

    final CapabilityStorageItem item = new CapabilityStorageItem(
        0, CAPABILITY_TYPE.toString(), true, null, oldProps
    );
    when(capabilityStorage.getAll()).thenReturn(ImmutableMap.of(capabilityIdentity("foo"), item));

    final CapabilityDescriptor descriptor = mock(CapabilityDescriptor.class);
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

   */
  @Test
  public void loadWhenTypeIsUnknown()
      throws Exception
  {
    final CapabilityStorageItem item = new CapabilityStorageItem(
        0, CAPABILITY_TYPE.toString(), true, null, null
    );
    when(capabilityStorage.getAll()).thenReturn(ImmutableMap.of(capabilityIdentity("foo"), item));

    when(capabilityDescriptorRegistry.get(CAPABILITY_TYPE)).thenReturn(null);
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

    underTest.add(CAPABILITY_TYPE, true, null, properties);

    ArgumentCaptor<CapabilityStorageItem> csiRec = ArgumentCaptor.forClass(CapabilityStorageItem.class);

    verify(capabilityStorage).add(csiRec.capture());
    CapabilityStorageItem item = csiRec.getValue();
    assertThat(item, is(notNullValue()));
    String fooValue = item.getProperties().get("foo");
    assertThat(fooValue, not(is("bar")));
    assertThat(passwordHelper.decrypt(fooValue), is("bar"));
  }
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

      throws Exception
  {
    Map<String, String> properties = Maps.newHashMap();
    properties.put("foo", passwordHelper.encrypt("bar"));

    final CapabilityStorageItem item = new CapabilityStorageItem(
        0, CAPABILITY_TYPE.toString(), true, null, properties
    );
    when(capabilityStorage.getAll()).thenReturn(ImmutableMap.of(capabilityIdentity("foo"), item));

    final CapabilityDescriptor descriptor = mock(CapabilityDescriptor.class);
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

      final CapabilityDescriptor descriptor = capabilityDescriptorRegistry.get(type);

      final Map<String, String> encryptedProps = encryptValuesIfNeeded(descriptor, props);

      final CapabilityIdentity generatedId = capabilityStorage.add(new CapabilityStorageItem(
          descriptor.version(), type.toString(), enabled, notes, encryptedProps
      ));

      log.debug("Added capability '{}' of type '{}' with properties '{}'", generatedId, type, encryptedProps);
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

      final DefaultCapabilityReference reference = get(id);

      final Map<String, String> encryptedProps = encryptValuesIfNeeded(reference.descriptor(), props);

      capabilityStorage.update(id, new CapabilityStorageItem(
          reference.descriptor().version(), reference.type().toString(), enabled, notes, encryptedProps)
      );

      log.debug(
          "Updated capability '{}' of type '{}' with properties '{}'", id, reference.type(), encryptedProps
View Full Code Here

Examples of org.sonatype.nexus.capability.internal.storage.CapabilityStorageItem

      throws IOException
  {
    final Map<CapabilityIdentity, CapabilityStorageItem> items = capabilityStorage.getAll();
    for (final Map.Entry<CapabilityIdentity, CapabilityStorageItem> entry : items.entrySet()) {
      CapabilityIdentity id = entry.getKey();
      CapabilityStorageItem item = entry.getValue();

      log.debug(
          "Loading capability '{}' of type '{}' with properties '{}'",
          id, item.getType(), item.getProperties()
      );

      final CapabilityDescriptor descriptor = capabilityDescriptorRegistry.get(capabilityType(item.getType()));

      if (descriptor == null) {
        log.warn(
            "Capabilities persistent storage (capabilities.xml?) contains an capability of unknown type {} with"
                + " id {}. This capability will not be loaded", item.getType(), id
        );
        continue;
      }

      Map<String, String> properties = decryptValuesIfNeeded(descriptor, item.getProperties());
      if (descriptor.version() != item.getVersion()) {
        log.debug(
            "Converting capability '{}' properties from version '{}' to version '{}'",
            id, item.getVersion(), descriptor.version()
        );
        try {
          properties = descriptor.convert(properties, item.getVersion());
          if (properties == null) {
            properties = Collections.emptyMap();
          }
          if (log.isDebugEnabled()) {
            log.debug(
                "Converted capability '{}' properties '{}' (version '{}') to '{}' (version '{}')",
                id, item.getProperties(), item.getVersion(),
                encryptValuesIfNeeded(descriptor, properties), descriptor.version()
            );
          }
        }
        catch (Exception e) {
          log.error(
              "Failed converting capability '{}' properties '{}' from version '{}' to version '{}'."
                  + " Capability will not be loaded",
              id, item.getProperties(), item.getVersion(), descriptor.version(), e
          );
          continue;
        }
        capabilityStorage.update(id, new CapabilityStorageItem(
            descriptor.version(), item.getType(), item.isEnabled(), item.getNotes(), properties)
        );
      }

      final DefaultCapabilityReference reference = create(id, capabilityType(item.getType()), descriptor);

      reference.setNotes(item.getNotes());
      reference.load(properties);
      if (item.isEnabled()) {
        reference.enable();
        reference.activate();
      }
    }
    eventBus.post(new AfterLoad(this));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.