コード例 #1
0
ファイル: WithAttributes.java プロジェクト: jawohl/josm
 /**
  * Add a key / value pair that is not part of the GPX schema as an extension.
  *
  * @param key the key
  * @param value the value
  */
 @Override
 public void addExtension(String key, String value) {
   if (!attr.containsKey(META_EXTENSIONS)) {
     attr.put(META_EXTENSIONS, new Extensions());
   }
   Extensions ext = (Extensions) attr.get(META_EXTENSIONS);
   ext.put(key, value);
 }
コード例 #2
0
  private AttributeCertificateInfo(ASN1Sequence seq) {
    if (seq.size() < 6 || seq.size() > 9) {
      throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }

    int start;
    if (seq.getObjectAt(0) instanceof ASN1Integer) // in version 1 certs version is DEFAULT  v1(0)
    {
      this.version = ASN1Integer.getInstance(seq.getObjectAt(0));
      start = 1;
    } else {
      this.version = new ASN1Integer(0);
      start = 0;
    }

    this.holder = Holder.getInstance(seq.getObjectAt(start));
    this.issuer = AttCertIssuer.getInstance(seq.getObjectAt(start + 1));
    this.signature = AlgorithmIdentifier.getInstance(seq.getObjectAt(start + 2));
    this.serialNumber = ASN1Integer.getInstance(seq.getObjectAt(start + 3));
    this.attrCertValidityPeriod = AttCertValidityPeriod.getInstance(seq.getObjectAt(start + 4));
    this.attributes = ASN1Sequence.getInstance(seq.getObjectAt(start + 5));

    for (int i = start + 6; i < seq.size(); i++) {
      ASN1Encodable obj = seq.getObjectAt(i);

      if (obj instanceof DERBitString) {
        this.issuerUniqueID = DERBitString.getInstance(seq.getObjectAt(i));
      } else if (obj instanceof ASN1Sequence || obj instanceof Extensions) {
        this.extensions = Extensions.getInstance(seq.getObjectAt(i));
      }
    }
  }
コード例 #3
0
  /*
  public int[] getGlobalIndices(List<? extends BaseDataContract> instances) {
  	int[] result = new int[instances.size()];

  	for (int i = 0; i < instances.size(); i++) {
  		result[i] = Integer.parseInt(instances.get(i).id);
  		usedComponentIds.add(result[i]);
  	}

  	return result;
  }

  public Set<Integer> getUsedComponentIds() {
  	return usedComponentIds;
  }
  */
  public <TDataContract> int getMaxEnsembleCount(
      EdlDocument edlDocument, EnsembleDefinition ensembleDefinition) {
    int result = Integer.MAX_VALUE;

    // TODO Extend to int ranges
    if (Extensions.hasDataContractBoundId(ensembleDefinition)) {
      QualifiedName idType = ensembleDefinition.getId().getType();
      result = components.get(idType.getName()).length;
    } else {
      for (DataContractDefinition contract : edlDocument.getDataContracts()) {
        int maxEnsembleCount = getMaxEnsembleCount(contract.getName(), ensembleDefinition);
        if (maxEnsembleCount < result) {
          result = maxEnsembleCount;
        }
      }
    }

    return result;
  }
コード例 #4
0
 public String getVersion() {
   return ext.getValue("4");
 }
コード例 #5
0
 public String getArchitecture() {
   return ext.getValue("3");
 }
コード例 #6
0
 public String getVariant() {
   return ext.getValue("2");
 }
コード例 #7
0
 public String getName() {
   // hack. remove junk characters at the beginning of the name
   return ext.getValue("1").substring(4);
 }
コード例 #8
0
  private void UpdateOptions() {
    getCompulsoryActions().clear();
    getOptionalActions().clear();

    if (getEntity() != null) {
      storage_pool dataCenter = null;
      if (getEntity().getstorage_pool_id() != null) {
        dataCenter = DataProvider.GetDataCenterById(getEntity().getstorage_pool_id().getValue());
      }
      if (dataCenter == null || dataCenter.getstorage_pool_type() != StorageType.LOCALFS) {
        // Add host action.
        UICommand addHostAction = new UICommand("AddHost", this);

        // 				var hosts = DataProvider.GetHostListByCluster(Entity.name)
        // 					.Skip(1)
        // 					.ToList();
        java.util.ArrayList<VDS> hosts = DataProvider.GetHostListByCluster(getEntity().getname());
        if (hosts.size() > 1) {
          hosts.remove(0);
        }

        if (hosts.isEmpty()) {
          addHostAction.setTitle(ClusterConfigureHostsAction);
          getCompulsoryActions().add(addHostAction);
        } else {
          addHostAction.setTitle(ClusterAddAnotherHostAction);
          getOptionalActions().add(addHostAction);
        }
        if (getEntity().getstorage_pool_id() == null) {
          addHostAction.setIsExecutionAllowed(false);
          addHostAction
              .getExecuteProhibitionReasons()
              .add("The Cluster isn't attached to a Data Center");
          return;
        }
        java.util.ArrayList<VDSGroup> clusters =
            DataProvider.GetClusterList((Guid) getEntity().getstorage_pool_id());
        Version minimalClusterVersion = Linq.GetMinVersionByClusters(clusters);
        java.util.ArrayList<VDS> availableHosts = new java.util.ArrayList<VDS>();
        for (VDS vds : DataProvider.GetHostList()) {
          if ((!Linq.IsHostBelongsToAnyOfClusters(clusters, vds))
              && (vds.getstatus() == VDSStatus.Maintenance
                  || vds.getstatus() == VDSStatus.PendingApproval)
              && (vds.getVersion().getFullVersion() == null
                  || Extensions.GetFriendlyVersion(vds.getVersion().getFullVersion())
                          .compareTo(minimalClusterVersion)
                      >= 0)) {
            availableHosts.add(vds);
          }
        }
        // Select host action.
        UICommand selectHostAction = new UICommand("SelectHost", this);

        if (availableHosts.size() > 0 && clusters.size() > 0) {
          if (hosts.isEmpty()) {
            selectHostAction.setTitle(SelectHostsAction);
            getCompulsoryActions().add(selectHostAction);
          } else {
            selectHostAction.setTitle(SelectHostsAction);
            getOptionalActions().add(selectHostAction);
          }
        }
      } else {
        UICommand tempVar = new UICommand("AddHost", this);
        tempVar.setTitle(ClusterAddAnotherHostAction);
        UICommand addHostAction = tempVar;
        UICommand tempVar2 = new UICommand("SelectHost", this);
        tempVar2.setTitle(SelectHostsAction);
        UICommand selectHost = tempVar2;
        VDS host = DataProvider.GetLocalStorageHost(dataCenter.getname());
        if (host != null) {
          addHostAction.setIsExecutionAllowed(false);
          selectHost.setIsExecutionAllowed(false);
          String hasHostReason =
              "This Cluster belongs to a Local Data Center which already contain a Host";
          addHostAction.getExecuteProhibitionReasons().add(hasHostReason);
          selectHost.getExecuteProhibitionReasons().add(hasHostReason);
        }
        getCompulsoryActions().add(addHostAction);
        getOptionalActions().add(selectHost);
      }
    }
  }
コード例 #9
0
 public static SubjectKeyIdentifier fromExtensions(Extensions extensions) {
   return SubjectKeyIdentifier.getInstance(
       extensions.getExtensionParsedValue(Extension.subjectKeyIdentifier));
 }
コード例 #10
0
 public String getScope() {
   if (parameter == null) return null;
   QName qName = Extensions.getQName(SCOPE);
   return parameter.getOtherAttributes().get(qName);
 }
コード例 #11
0
 public void setScope(String scope) {
   if (parameter == null || scope == null) return;
   QName qName = Extensions.getQName(SCOPE);
   parameter.getOtherAttributes().put(qName, scope);
 }
コード例 #12
0
 public static BasicConstraints fromExtensions(Extensions extensions) {
   return BasicConstraints.getInstance(
       extensions.getExtensionParsedValue(Extension.basicConstraints));
 }
コード例 #13
0
 static void configureExtensions() {
   Extensions.setLogProvider(new IdeaLogProvider());
   Extensions.registerAreaClass(ExtensionAreas.IDEA_PROJECT, null);
   Extensions.registerAreaClass(ExtensionAreas.IDEA_MODULE, ExtensionAreas.IDEA_PROJECT);
 }
コード例 #14
0
  static void initializePlugins(@Nullable StartupProgress progress) {
    configureExtensions();

    final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors(progress);

    final Class callerClass = ReflectionUtil.findCallerClass(1);
    assert callerClass != null;
    final ClassLoader parentLoader = callerClass.getClassLoader();

    final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();
    final HashMap<String, String> disabledPluginNames = new HashMap<String, String>();
    for (IdeaPluginDescriptorImpl descriptor : pluginDescriptors) {
      if (descriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)) {
        final List<String> modules = descriptor.getModules();
        if (modules != null) {
          ourAvailableModules.addAll(modules);
        }
      }

      if (!shouldSkipPlugin(descriptor, pluginDescriptors)) {
        result.add(descriptor);
      } else {
        descriptor.setEnabled(false);
        disabledPluginNames.put(descriptor.getPluginId().getIdString(), descriptor.getName());
        initClassLoader(parentLoader, descriptor);
      }
    }

    prepareLoadingPluginsErrorMessage(filterBadPlugins(result, disabledPluginNames));

    final Map<PluginId, IdeaPluginDescriptorImpl> idToDescriptorMap =
        new HashMap<PluginId, IdeaPluginDescriptorImpl>();
    for (final IdeaPluginDescriptorImpl descriptor : result) {
      idToDescriptorMap.put(descriptor.getPluginId(), descriptor);
    }

    final IdeaPluginDescriptor corePluginDescriptor =
        idToDescriptorMap.get(PluginId.getId(CORE_PLUGIN_ID));
    assert corePluginDescriptor != null
        : CORE_PLUGIN_ID
            + " not found; platform prefix is "
            + System.getProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY);
    for (IdeaPluginDescriptorImpl descriptor : result) {
      if (descriptor != corePluginDescriptor) {
        descriptor.insertDependency(corePluginDescriptor);
      }
    }

    mergeOptionalConfigs(idToDescriptorMap);

    // sort descriptors according to plugin dependencies
    Collections.sort(result, getPluginDescriptorComparator(idToDescriptorMap));

    for (int i = 0; i < result.size(); i++) {
      ourId2Index.put(result.get(i).getPluginId(), i);
    }

    int i = 0;
    for (final IdeaPluginDescriptorImpl pluginDescriptor : result) {
      if (pluginDescriptor.getPluginId().getIdString().equals(CORE_PLUGIN_ID)
          || pluginDescriptor.isUseCoreClassLoader()) {
        pluginDescriptor.setLoader(parentLoader);
      } else {
        final List<File> classPath = pluginDescriptor.getClassPath();
        final PluginId[] dependentPluginIds = pluginDescriptor.getDependentPluginIds();
        final ClassLoader[] parentLoaders = getParentLoaders(idToDescriptorMap, dependentPluginIds);

        final ClassLoader pluginClassLoader =
            createPluginClassLoader(
                classPath.toArray(new File[classPath.size()]),
                parentLoaders.length > 0 ? parentLoaders : new ClassLoader[] {parentLoader},
                pluginDescriptor);
        pluginDescriptor.setLoader(pluginClassLoader);
      }

      if (progress != null) {
        progress.showProgress(
            "", PLUGINS_PROGRESS_MAX_VALUE + (i++ / (float) result.size()) * 0.35f);
      }
    }

    registerExtensionPointsAndExtensions(Extensions.getRootArea(), result);
    Extensions.getRootArea()
        .getExtensionPoint(Extensions.AREA_LISTENER_EXTENSION_POINT)
        .registerExtension(
            new AreaListener() {
              @Override
              public void areaCreated(
                  @NotNull String areaClass, @NotNull AreaInstance areaInstance) {
                registerExtensionPointsAndExtensions(Extensions.getArea(areaInstance), result);
              }

              @Override
              public void areaDisposing(
                  @NotNull String areaClass, @NotNull AreaInstance areaInstance) {}
            });

    ourPlugins = pluginDescriptors;
  }