Exemplo n.º 1
0
/** Settings related to content management. */
public class ContentSettings extends LimeProps {
  private ContentSettings() {}

  /** The list of default content authorities. */
  public static final StringArraySetting AUTHORITIES =
      FACTORY.createRemoteStringArraySetting(
          "CONTENT_AUTHORITIES", new String[0], "content.authorities");

  /** Whether or not we want to use content management. */
  public static final BooleanSetting CONTENT_MANAGEMENT_ACTIVE =
      FACTORY.createRemoteBooleanSetting(
          "CONTENT_MANAGEMENT_ACTIVE", true, "content.managementActive");

  /**
   * Whether or not the user is enabling management. Both this & the above must be on for management
   * to be active.
   */
  public static final BooleanSetting USER_WANTS_MANAGEMENTS =
      FACTORY.createBooleanSetting("USER_WANTS_MANAGEMENTS", true);

  /**
   * Returns true if content management is active.
   *
   * @return
   */
  public static boolean isManagementActive() {
    return CONTENT_MANAGEMENT_ACTIVE.getValue() && USER_WANTS_MANAGEMENTS.getValue();
  }
}
  @Override
  public void validate(
      final Processor<FullData, FullData> processor,
      final ProcessingReport report,
      final MessageBundle bundle,
      final FullData data)
      throws ProcessingException {
    final SchemaTree tree = data.getSchema();
    final JsonPointer schemaPointer = tree.getPointer();
    final JsonNode schemas = tree.getNode().get(keyword);
    final int size = schemas.size();
    final ObjectNode fullReport = FACTORY.objectNode();

    int nrSuccess = 0;
    ListProcessingReport subReport;
    JsonPointer ptr;
    FullData newData;

    for (int index = 0; index < size; index++) {
      subReport = new ListProcessingReport(report.getLogLevel(), LogLevel.FATAL);
      ptr = schemaPointer.append(JsonPointer.of(keyword, index));
      newData = data.withSchema(tree.setPointer(ptr));
      processor.process(subReport, newData);
      fullReport.put(ptr.toString(), subReport.asJson());
      if (subReport.isSuccess()) nrSuccess++;
    }

    if (nrSuccess == 0)
      report.error(
          newMsg(data, bundle, "err.common.schema.noMatch")
              .putArgument("nrSchemas", size)
              .put("reports", fullReport));
  }
 @Override
 protected JsonNode loadSample() {
   final int index = RND.nextInt(SAMPLE_DATA_SIZE);
   final JsonNode sample = SAMPLE_DATA.get(index);
   final ObjectNode ret = FACTORY.objectNode();
   ret.put(ResponseFields.INPUT, JacksonUtils.prettyPrint(sample));
   return ret;
 }
  @Override
  public JsonNode digest(final JsonNode schema) {
    // TODO: return an array directly (same for "required" in v4)
    final ObjectNode ret = FACTORY.objectNode();
    final ArrayNode required = FACTORY.arrayNode();
    ret.put("required", required);

    final JsonNode node = schema.get(keyword);
    final List<String> list = Lists.newArrayList(node.fieldNames());

    Collections.sort(list);

    for (final String field : list)
      if (node.get(field).path("required").asBoolean(false)) required.add(field);

    return ret;
  }
/** Settings for iTunes */
public class iTunesSettings extends LimeProps {

  private iTunesSettings() {}

  /** Whether or not player should be enabled. */
  public static BooleanSetting ITUNES_SUPPORT_ENABLED =
      FACTORY.createBooleanSetting("ITUNES_SUPPORT_ENABLED", true);

  /** The name of the Playlist where songs shall be imported */
  public static StringSetting ITUNES_PLAYLIST =
      FACTORY.createStringSetting("ITUNES_PLAYLIST", "LimeWire");

  /** Supported file types */
  public static StringArraySetting ITUNES_SUPPORTED_FILE_TYPES =
      FACTORY.createStringArraySetting(
          "ITUNES_SUPPORTED_FILE_TYPES",
          new String[] {
            ".mp3", ".aif", ".aiff", ".wav", ".mp2", ".mp4", ".aac", ".mid", ".m4a", ".m4p", ".ogg"
          });
}
Exemplo n.º 6
0
/** Various Mojito security Settings */
public class SecuritySettings extends MojitoProps {

  private SecuritySettings() {}

  /**
   * Settings for whether not the Port number should be substituted in the {@link SecurityToken} and
   * {@link TokenData} if a Node says it's firewalled. Some NAT boxes keep changing the Port number
   * with each outgoing UDP packet and break therefore the whole thing. See {@link
   * SecurityTokenHelper} for more info!
   */
  public static final BooleanSetting SUBSTITUTE_TOKEN_PORT =
      FACTORY.createRemoteBooleanSetting(
          "SUBSTITUTE_TOKEN_PORT", true, "Mojito.SubstituteTokenPort");
}
  @Override
  public JsonNode digest(final JsonNode schema) {
    final ObjectNode ret = FACTORY.objectNode();
    final ArrayNode simpleTypes = FACTORY.arrayNode();
    ret.put(keyword, simpleTypes);
    final ArrayNode schemas = FACTORY.arrayNode();
    ret.put("schemas", schemas);

    final JsonNode node = schema.get(keyword);

    final EnumSet<NodeType> set = EnumSet.noneOf(NodeType.class);

    if (node.isTextual()) // Single type
    putType(set, node.textValue());
    else { // More than one type, and possibly schemas
      final int size = node.size();
      JsonNode element;
      for (int index = 0; index < size; index++) {
        element = node.get(index);
        if (element.isTextual()) putType(set, element.textValue());
        else schemas.add(index);
      }
    }

    /*
     * If all types are there, no need to collect schemas
     */
    if (EnumSet.complementOf(set).isEmpty()) schemas.removeAll();

    /*
     * Note that as this is an enumset, order is guaranteed
     */
    for (final NodeType type : set) simpleTypes.add(type.toString());

    return ret;
  }
  @Override
  protected EObject addListItem(EObject object, EStructuralFeature feature) {
    InputSet inputSet = throwEvent.getInputSet();
    if (inputSet == null) {
      inputSet = FACTORY.createInputSet();
      throwEvent.setInputSet(inputSet);
      ModelUtil.setID(inputSet);
    }
    // generate a unique parameter name
    String base = "inParam";
    int suffix = 1;
    String name = base + suffix;
    for (; ; ) {
      boolean found = false;
      for (DataInput p : inputSet.getDataInputRefs()) {
        if (name.equals(p.getName())) {
          found = true;
          break;
        }
      }
      if (!found) break;
      name = base + ++suffix;
    }

    DataInput param = (DataInput) super.addListItem(object, feature);
    // add the new parameter to the InputSet
    (param).setName(name);
    inputSet.getDataInputRefs().add(param);

    // create a DataInputAssociation
    DataInputAssociation inputAssociation = FACTORY.createDataInputAssociation();
    throwEvent.getDataInputAssociation().add(inputAssociation);
    inputAssociation.setTargetRef((DataInput) param);
    ModelUtil.setID(inputAssociation);
    return param;
  }
 public Category getCategory() {
   return FACTORY.getCategory();
 }
Exemplo n.º 10
0
/**
 * Term constants for the DC music ontology
 *
 * @author Michael Grove
 * @since 0.1
 */
public class MusicOntology extends Vocabulary {
  public static final String ONT_URI = "http://purl.org/ontology/mo/";

  private static MusicOntology INSTANCE = null;

  private MusicOntology() {
    super(ONT_URI);
  }

  public static MusicOntology ontology() {
    if (INSTANCE == null) {
      INSTANCE = new MusicOntology();
    }

    return INSTANCE;
  }

  // properties
  public final URI track = term("track");
  public final URI release_type = term("release_type");
  public final URI release_status = term("release_status");
  public final URI track_number = term("track_number");
  public final URI length = term("length");
  public final URI made = term("made");
  public final URI musicbrainz = term("musicbrainz");
  public final URI olga = term("olga");
  public final URI genre = term("genre");
  public final URI sample_rate = term("sample_rate");
  public final URI bitsPerSample = term("bitsPerSample");

  // cp properties
  public final URI rating = term("rating");
  public final URI albumRating = term("albumRating");
  public final URI year = term("year");
  public final URI location = term("location");

  // classes
  public final URI Genre = term("Genre");
  public final URI Record = term("Record");
  public final URI Track = term("Track");
  public final URI MusicArtist = term("MusicArtist");
  public final URI MusicGroup = term("MusicGroup");

  // individuals
  public final URI Metal = FACTORY.createURI(Genre.stringValue() + "/Metal");
  public final URI Rock = FACTORY.createURI(Genre.stringValue() + "/Rock");
  public final URI Alternative = FACTORY.createURI(Genre.stringValue() + "/Alternative");
  public final URI Pop = FACTORY.createURI(Genre.stringValue() + "/Pop");
  public final URI Punk = FACTORY.createURI(Genre.stringValue() + "/Punk");
  public final URI Funk = FACTORY.createURI(Genre.stringValue() + "/Funk");
  public final URI Soundtrack = FACTORY.createURI(Genre.stringValue() + "/Soundtrack");
  public final URI Blues = FACTORY.createURI(Genre.stringValue() + "/Blues");
  public final URI Jazz = FACTORY.createURI(Genre.stringValue() + "/Jazz");
  public final URI Vocal = FACTORY.createURI(Genre.stringValue() + "/Vocal");
  public final URI Country = FACTORY.createURI(Genre.stringValue() + "/Country");

  public final URI album = term("album");
  public final URI official = term("official");
}
Exemplo n.º 11
0
 public String getSummaryStatisticDescription() {
   return FACTORY.getSummaryStatisticDescription();
 }
Exemplo n.º 12
0
 public SummaryStatisticDescription.Category getCategory() {
   return FACTORY.getCategory();
 }
Exemplo n.º 13
0
/** Settings for Ultrapeers. */
public final class UltrapeerSettings extends LimeProps {

  private UltrapeerSettings() {}

  /** Setting for whether or not we've ever been Ultrapeer capable. */
  public static final BooleanSetting EVER_ULTRAPEER_CAPABLE =
      FACTORY.createExpirableBooleanSetting("EVER_SUPERNODE_CAPABLE", false);

  /** Setting for whether or not to force Ultrapeer mode. */
  public static final BooleanSetting FORCE_ULTRAPEER_MODE =
      FACTORY.createBooleanSetting("FORCE_SUPERNODE_MODE", false);

  /** Setting for whether or not to disable Ultrapeer mode. */
  public static final BooleanSetting DISABLE_ULTRAPEER_MODE =
      FACTORY.createBooleanSetting("DISABLE_SUPERNODE_MODE", false);

  /** Setting for the maximum leaf connections. */
  public static final IntSetting MAX_LEAVES =
      FACTORY.createRemoteIntSetting("MAX_LEAVES", 30, "UltrapeerSettings.maxLeavesV2", 16, 96);

  /**
   * The minimum number of upstream kbytes per second that a node must be able to transfer in order
   * to qualify as a ultrapeer.
   */
  public static final IntSetting MIN_UPSTREAM_REQUIRED =
      FACTORY.createRemoteIntSetting(
          "MIN_UPSTREAM_REQUIRED", 10, "UltrapeerSettings.MinUpstream", 8, 32);

  /**
   * The minimum number of downlstream kbytes per second that a node must be able to transfer in
   * order to qualify as a ultrapeer.
   */
  public static final IntSetting MIN_DOWNSTREAM_REQUIRED =
      FACTORY.createRemoteIntSetting(
          "MIN_DOWNSTREAM_REQUIRED", 20, "UltrapeerSettings.MinDownstream", 16, 64);

  /**
   * The minimum average uptime in seconds that a node must have to qualify for ultrapeer status.
   */
  public static final IntSetting MIN_AVG_UPTIME =
      FACTORY.createRemoteIntSetting(
          "MIN_AVG_UPTIME", 3600, "UltrapeerSettings.MinAvgUptime", 3600, 48 * 3600);

  /** Setting for whether or not the MIN_CONNECT_TIME is required. */
  public static final BooleanSetting NEED_MIN_CONNECT_TIME =
      FACTORY.createBooleanSetting("NEED_MIN_CONNECT_TIME", true);

  /**
   * The minimum time in seconds that a node must have tried to connect before it can qualify for
   * Ultrapeer status.
   */
  public static final IntSetting MIN_CONNECT_TIME =
      FACTORY.createRemoteIntSetting(
          "MIN_CONNECT_TIME", 10, "UltrapeerSettings.MinConnectTime", 0, 30);

  /**
   * The minimum current uptime in seconds that a node must have to qualify for Ultrapeer status.
   */
  public static final IntSetting MIN_INITIAL_UPTIME =
      FACTORY.createRemoteIntSetting(
          "MIN_INITIAL_UPTIME",
          120 * 60,
          "UltrapeerSettings.MinInitialUptime",
          120 * 60,
          48 * 3600);

  /** The amount of time to wait between attempts to become an Ultrapeer, in milliseconds. */
  public static final IntSetting UP_RETRY_TIME =
      FACTORY.createRemoteIntSetting(
          "UP_RETRY_TIME",
          180 * 60 * 1000,
          "UltrapeerSettings.UpRetryTime",
          180 * 60 * 1000,
          24 * 3600 * 1000);
}
Exemplo n.º 14
0
/** Settings to deal with UI. */
public final class UISettings extends LimeProps {

  private UISettings() {}

  /** Setting for autocompletion */
  public static final BooleanSetting AUTOCOMPLETE_ENABLED =
      FACTORY.createBooleanSetting("AUTOCOMPLETE_ENABLED", true);

  /** Setting for search-result filters. */
  public static final BooleanSetting SEARCH_RESULT_FILTERS =
      FACTORY.createBooleanSetting("SEARCH_RESULT_FILTERS", true);

  /** Setting for the magnetmix button. */
  public static final BooleanSetting MAGNETMIX_BUTTON =
      FACTORY.createBooleanSetting(
          "SEARCH_MAGNETMIX_BUTTON", !CommonUtils.isPro() && !isResolutionLow());

  /** Setting for using small icons. */
  public static final BooleanSetting SMALL_ICONS =
      FACTORY.createBooleanSetting("UI_SMALL_ICONS", isResolutionLow());

  /** Setting for displaying text under icons. */
  public static final BooleanSetting TEXT_WITH_ICONS =
      FACTORY.createBooleanSetting("UI_TEXT_WITH_ICONS", true);

  /** Setting for not grouping search results in GUI */
  public static final BooleanSetting UI_GROUP_RESULTS =
      FACTORY.createBooleanSetting("UI_GROUP_RESULTS", true);

  /** Setting to allow ignoring of alt-locs in replies. */
  public static final BooleanSetting UI_ADD_REPLY_ALT_LOCS =
      FACTORY.createBooleanSetting("UI_ADD_REPLY_ALT_LOCS", true);

  /** For people with bad eyes. */
  private static boolean isResolutionLow() {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    return screenSize.width <= 800 || screenSize.height <= 600;
  }

  /** Setting to persist monitor check box state. */
  public static final BooleanSetting UI_MONITOR_SHOW_INCOMING_SEARCHES =
      FACTORY.createBooleanSetting("UI_MONITOR_SHOW_INCOMING_SEARCHES", false);

  /** Setting for the divider location between library tree and table. */
  public static final IntSetting UI_LIBRARY_TREE_DIVIDER_LOCATION =
      FACTORY.createIntSetting("UI_LIBRARY_TREE_DIVIDER_LOCATION", -1);

  /** Setting for the divider location between library and playlist. */
  public static final IntSetting UI_LIBRARY_PLAY_LIST_TAB_DIVIDER_LOCATION =
      FACTORY.createIntSetting("UI_LIBRARY_PLAY_LIST_TAB_DIVIDER_LOCATION", 300);

  /** Setting for the divider location between incoming query monitors and upload panel. */
  public static final IntSetting UI_MONITOR_UPLOAD_TAB_DIVIDER_LOCATION =
      FACTORY.createIntSetting("UI_MONITOR_UPLOAD_TAB_DIVIDER_LOCATION", 300);
}
Exemplo n.º 15
0
 public String getSummaryStatisticName() {
   return FACTORY.getSummaryStatisticName();
 }
 public String getSummaryStatisticReference() {
   return FACTORY.getSummaryStatisticReference();
 }
 public boolean allowsUnrootedTrees() {
   return FACTORY.allowsUnrootedTrees();
 }
 public boolean allowsNonultrametricTrees() {
   return FACTORY.allowsNonultrametricTrees();
 }
 public boolean allowsPolytomies() {
   return FACTORY.allowsPolytomies();
 }
Exemplo n.º 20
0
 /**
  * Returns a constant function of specified value.
  *
  * @param value the value returned by this function.
  * @return the corresponding constant function.
  */
 @SuppressWarnings("unchecked")
 public static <R extends Ring<R>> Constant<R> valueOf(R value) {
   Constant<R> cst = FACTORY.object();
   cst._termToCoef.put(Term.ONE, value);
   return cst;
 }
Exemplo n.º 21
0
/** Settings for filters */
public class FilterSettings extends LimeProps {

  private FilterSettings() {}

  public static final BooleanSetting USE_NETWORK_FILTER =
      FACTORY.createBooleanSetting("USE_NETWORK_FILTER", true);

  /**
   * Sets whether or not search results including "adult content" are banned in What's New queries.
   */
  public static final BooleanSetting FILTER_WHATS_NEW_ADULT =
      FACTORY.createBooleanSetting("FILTER_WHATS_NEW_ADULT", true);

  /** Sets whether or not search results including "adult content" are banned. */
  public static final BooleanSetting FILTER_ADULT =
      FACTORY.createBooleanSetting("FILTER_ADULT", false);

  /** Sets whether or not known spam and malware URNs are banned. */
  public static final BooleanSetting FILTER_URNS =
      FACTORY.createBooleanSetting("FILTER_URNS", true);

  /** An array of URNs that should not be displayed (local setting). */
  public static final StringArraySetting FILTERED_URNS_LOCAL =
      FACTORY.createStringArraySetting("FILTERED_URNS_LOCAL", new String[0]);

  /** An array of URNs that should not be displayed (remote setting). */
  public static final StringArraySetting FILTERED_URNS_REMOTE =
      FACTORY.createRemoteStringArraySetting(
          "FILTERED_URNS_REMOTE", new String[0], "FilterSettings.filteredUrnsRemote");

  /** Sets whether or not results with filtered URNs are considered spam. */
  public static final BooleanSetting FILTERED_URNS_ARE_SPAM =
      FACTORY.createRemoteBooleanSetting(
          "FILTERED_URNS_ARE_SPAM", true, "FilterSettings.filteredUrnsAreSpam");
  /** Sets whether or not duplicate search results are banned. */
  public static final BooleanSetting FILTER_DUPLICATES =
      FACTORY.createBooleanSetting("FILTER_DUPLICATES", true);

  /** Sets whether or not greedy queries a filtered. */
  public static final BooleanSetting FILTER_GREEDY_QUERIES =
      FACTORY.createBooleanSetting("FILTER_GREEDY_QUERIES", true);

  /** Sets whether or not anomalous queries are filtered. */
  public static final BooleanSetting FILTER_ANOMALOUS_QUERIES =
      FACTORY.createRemoteBooleanSetting(
          "FILTER_ANOMALOUS_QUERIES", true, "FilterSettings.filterAnomalousQueries");

  /** An array of ip addresses that the user has banned. */
  @InspectablePrimitive("blacklisted hosts")
  public static final StringArraySetting BLACK_LISTED_IP_ADDRESSES =
      FACTORY.createStringArraySetting("BLACK_LISTED_IP_ADDRESSES", new String[0]);

  /** An array of ip addresses that the user has allowed. (Array of String!) */
  public static final StringArraySetting WHITE_LISTED_IP_ADDRESSES =
      FACTORY.createStringArraySetting("WHITE_LISTED_IP_ADDRESSES", new String[0]);

  /** An array of words that the user has banned from appearing in search results. */
  public static final StringArraySetting BANNED_WORDS =
      FACTORY.createStringArraySetting("BANNED_WORDS", new String[0]);

  /** An array of extensions that the user has banned from appearing in search results. */
  public static final StringArraySetting BANNED_EXTENSIONS =
      FACTORY.createStringArraySetting(
          "BANNED_EXTENSIONS",
          new String[] {".vbs", ".asf", ".asx", ".wm", ".wma", ".wmv", ".htm", ".html"});

  /** Whether to filter queries containing hashes. TODO: naming convention for SIMPP keys? */
  public static final BooleanSetting FILTER_HASH_QUERIES =
      FACTORY.createRemoteBooleanSetting("FILTER_HASH_QUERIES", false, "filter_hash");

  public static final IntSetting MIN_MATCHING_WORDS =
      FACTORY.createRemoteIntSetting(
          "MIN_MATCHING_WORDS", 0, "FilterSettings.minMatchingWords", 0, 30);

  /** An array of ip addresses that LimeWire will respond to. */
  public static final StringArraySetting CRAWLER_IP_ADDRESSES =
      FACTORY.createRemoteStringArraySetting(
          "CRAWLER_IPS", new String[] {"*.*.*.*"}, "FilterSettings.crawlerIps");

  /** An array of ip addresses that LimeWire will respond to with inspection responses. */
  public static final StringArraySetting INSPECTOR_IP_ADDRESSES =
      FACTORY.createRemoteStringArraySetting(
          "INSPECTOR_IPS", new String[0], "FilterSettings.inspectorIps");

  /** An array of hostile ip addresses. */
  public static final StringArraySetting HOSTILE_IPS =
      FACTORY.createRemoteStringArraySetting(
          "HOSTILE_IPS", new String[0], "FilterSettings.hostileIps");

  /** How many alts to allow per response. */
  public static final IntSetting MAX_ALTS_PER_RESPONSE =
      FACTORY.createRemoteIntSetting(
          "MAX_ALTS_PER_RESPONSE", 50, "FilterSettings.maxAltsPerResponse", 10, 100);

  /** How many responses to allow per QueryReply message. */
  public static final IntSetting MAX_RESPONSES_PER_REPLY =
      FACTORY.createRemoteIntSetting(
          "MAX_RESPONSES_PER_REPLY", 10, "FilterSettings.maxResponsesPerReply", 10, 256);

  /**
   * Base32-encoded, deflated, bencoded description of dangerous file types. See
   * DangerousFileTypeEncoder.
   */
  public static final StringSetting DANGEROUS_FILE_TYPES =
      FACTORY.createRemoteStringSetting(
          "DANGEROUS_FILE_TYPES",
          "PCOEWMNUJLG4SMNWJIWE4M5SFLHTKBXCIQIFDFU2NJUJLG3DNBTGLIFWVG2C73N44CZJWDFLDCJM5ZNEUYBABWCDCMGA",
          "FilterSettings.DangerousFileTypes");
}