コード例 #1
0
  private void convertToKazuki(final File configFile) throws Exception {
    try (Reader r = new FileReader(configFile);
        FileInputStream is = new FileInputStream(configFile);
        Reader fr = new InputStreamReader(is)) {

      Xpp3DomBuilder.build(r);
      Configuration configuration = new NexusCapabilitiesConfigurationXpp3Reader().read(fr);
      List<CCapability> capabilities = configuration.getCapabilities();

      if (capabilities != null) {
        for (final CCapability c : capabilities) {

          // NEXUS-6349: do not convert outreach related capabilities and let outreach plugin
          // recreate them
          if ("OutreachMarkerCapability".equals(c.getTypeId())
              || "OutreachManagementCapability".equals(c.getTypeId())) {
            continue;
          }

          Map<String, String> properties = Maps.newHashMap();
          if (c.getProperties() != null) {
            for (final CCapabilityProperty property : c.getProperties()) {
              properties.put(property.getKey(), property.getValue());
            }
          }

          capabilityStorage.add(
              new CapabilityStorageItem(
                  c.getVersion(), c.getTypeId(), c.isEnabled(), c.getNotes(), properties));
        }
        log.info("Converted {} capabilities from capabilities.xml to Kazuki", capabilities.size());
      }
    }
  }
コード例 #2
0
 public Configuration convertFromKazuki() throws IOException {
   Map<CapabilityIdentity, CapabilityStorageItem> capabilities = capabilityStorage.getAll();
   Configuration configuration = new Configuration();
   for (Entry<CapabilityIdentity, CapabilityStorageItem> entry : capabilities.entrySet()) {
     configuration.addCapability(asCCapability(entry.getKey().toString(), entry.getValue()));
   }
   return configuration;
 }
  @SuppressWarnings("unchecked")
  public ValidationResponse validateModel(final ValidationRequest request) {
    final ValidationResponse response = new ValidationResponse();

    final Configuration configuration = (Configuration) request.getConfiguration();

    if (configuration == null) {
      final ValidationMessage msg =
          new ValidationMessage("*", "No configuration available to validate");

      response.addValidationError(msg);
    } else {
      for (final CCapability capability : configuration.getCapabilities()) {
        response.append(validate(capability, false));
      }
    }

    return response;
  }