text:
/*
 * DO NOT EDIT.  THIS FILE IS GENERATED FROM ../../../dist/idl\nsISocketProvider.idl
 */

#ifndef __gen_nsISocketProvider_h__
#define __gen_nsISocketProvider_h__

#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif

/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif

/* starting interface:    nsISocketProvider */
#define NS_ISOCKETPROVIDER_IID_STR "00b3df92-e830-11d8-d48e-0004e22243f8"

#define NS_ISOCKETPROVIDER_IID \
  {0x00b3df92, 0xe830, 0x11d8, \
    { 0xd4, 0x8e, 0x00, 0x04, 0xe2, 0x22, 0x43, 0xf8 }}

class NS_NO_VTABLE nsISocketProvider : public nsISupports {
 public:

  NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISOCKETPROVIDER_IID)

  /* [noscript] void newSocket (in long aFamily, in string aHost, in long aPort, in string aProxyHost, in long aProxyPort, in unsigned long aFlags, out PRFileDescStar aFileDesc, out nsISupports aSecurityInfo); */
  NS_IMETHOD NewSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc **aFileDesc, nsISupports * *aSecurityInfo) = 0;

  /* [noscript] void addToSocket (in long aFamily, in string aHost, in long aPort, in string aProxyHost, in long aProxyPort, in unsigned long aFlags, in PRFileDescStar aFileDesc, out nsISupports aSecurityInfo); */
  NS_IMETHOD AddToSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc *aFileDesc, nsISupports * *aSecurityInfo) = 0;

  enum {
    PROXY_RESOLVES_HOST = 1,
    ANONYMOUS_CONNECT = 2,
    NO_PERMANENT_STORAGE = 4U,
    MITM_OK = 8U
  };

};

  NS_DEFINE_STATIC_IID_ACCESSOR(nsISocketProvider, NS_ISOCKETPROVIDER_IID)

/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSISOCKETPROVIDER \
  NS_IMETHOD NewSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc **aFileDesc, nsISupports * *aSecurityInfo) override; \
  NS_IMETHOD AddToSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc *aFileDesc, nsISupports * *aSecurityInfo) override; \

/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSISOCKETPROVIDER(_to) \
  NS_IMETHOD NewSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc **aFileDesc, nsISupports * *aSecurityInfo) override { return _to NewSocket(aFamily, aHost, aPort, aProxyHost, aProxyPort, aFlags, aFileDesc, aSecurityInfo); } \
  NS_IMETHOD AddToSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc *aFileDesc, nsISupports * *aSecurityInfo) override { return _to AddToSocket(aFamily, aHost, aPort, aProxyHost, aProxyPort, aFlags, aFileDesc, aSecurityInfo); } \

/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSISOCKETPROVIDER(_to) \
  NS_IMETHOD NewSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc **aFileDesc, nsISupports * *aSecurityInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->NewSocket(aFamily, aHost, aPort, aProxyHost, aProxyPort, aFlags, aFileDesc, aSecurityInfo); } \
  NS_IMETHOD AddToSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc *aFileDesc, nsISupports * *aSecurityInfo) override { return !_to ? NS_ERROR_NULL_POINTER : _to->AddToSocket(aFamily, aHost, aPort, aProxyHost, aProxyPort, aFlags, aFileDesc, aSecurityInfo); } \

#if 0
/* Use the code below as a template for the implementation class for this interface. */

/* Header file */
class nsSocketProvider : public nsISocketProvider
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSISOCKETPROVIDER

  nsSocketProvider();

private:
  ~nsSocketProvider();

protected:
  /* additional members */
};

/* Implementation file */
NS_IMPL_ISUPPORTS(nsSocketProvider, nsISocketProvider)

nsSocketProvider::nsSocketProvider()
{
  /* member initializers and constructor code */
}

nsSocketProvider::~nsSocketProvider()
{
  /* destructor code */
}

/* [noscript] void newSocket (in long aFamily, in string aHost, in long aPort, in string aProxyHost, in long aProxyPort, in unsigned long aFlags, out PRFileDescStar aFileDesc, out nsISupports aSecurityInfo); */
NS_IMETHODIMP nsSocketProvider::NewSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc **aFileDesc, nsISupports * *aSecurityInfo)
{
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* [noscript] void addToSocket (in long aFamily, in string aHost, in long aPort, in string aProxyHost, in long aProxyPort, in unsigned long aFlags, in PRFileDescStar aFileDesc, out nsISupports aSecurityInfo); */
NS_IMETHODIMP nsSocketProvider::AddToSocket(int32_t aFamily, const char * aHost, int32_t aPort, const char * aProxyHost, int32_t aProxyPort, uint32_t aFlags, struct PRFileDesc *aFileDesc, nsISupports * *aSecurityInfo)
{
    return NS_ERROR_NOT_IMPLEMENTED;
}

/* End of implementation class template. */
#endif

/**
 * nsISocketProvider implementations should be registered with XPCOM under a
 * contract ID of the form: "@mozilla.org/network/socket;2?type=foo"
 */
#define NS_NETWORK_SOCKET_CONTRACTID_PREFIX \
    "@mozilla.org/network/socket;2?type="

#endif /* __gen_nsISocketProvider_h__ */

redpajama_set_name: RedPajamaGithub


text:
require 'travis/model'
require 'active_support/core_ext/hash/deep_dup'
require 'travis/model/build/config/language'

# Job models a unit of work that is run on a remote worker.
#
# There currently only one job type:
#
#  * Job::Test belongs to a Build (one or many Job::Test instances make up a
#    build matrix) and executes a test suite with parameters defined in the
#    configuration.
class Job < Travis::Model
  require 'travis/model/job/queue'
  require 'travis/model/job/test'
  require 'travis/model/env_helpers'

  class << self
    # what we return from the json api
    def queued(queue = nil)
      scope = where(state: [:created, :queued])
      scope = scope.where(queue: queue) if queue
      scope
    end

    # what needs to be queued up
    def queueable(queue = nil)
      scope = where(state: :created).order('jobs.id')
      scope = scope.where(queue: queue) if queue
      scope
    end

    # what already is queued or started
    def running(queue = nil)
      scope = where(state: [:queued, :received, :started]).order('jobs.id')
      scope = scope.where(queue: queue) if queue
      scope
    end

    def unfinished
      # TODO conflate Job and Job::Test and use States::FINISHED_STATES
      where('state NOT IN (?)', [:finished, :passed, :failed, :errored, :canceled])
    end

    def owned_by(owner)
      where(owner_id: owner.id, owner_type: owner.class.to_s)
    end
  end

  include Travis::Model::EnvHelpers

  has_one    :log, dependent: :destroy
  has_many   :events, as: :source
  has_many   :annotations, dependent: :destroy

  belongs_to :repository
  belongs_to :commit
  belongs_to :source, polymorphic: true, autosave: true
  belongs_to :owner, polymorphic: true

  validates :repository_id, :commit_id, :source_id, :source_type, :owner_id, :owner_type, presence: true

  serialize :config, JSON

  delegate :request_id, to: :source # TODO denormalize
  delegate :pull_request?, to: :commit
  delegate :secure_env_enabled?, :addons_enabled?, to: :source

  after_initialize do
    self.config = {} if config.nil? rescue nil
  end

  before_create do
    build_log
    self.state = :created if self.state.nil?
    self.queue = Queue.for(self).name
  end

  after_commit on: :create do
    notify(:create)
  end

  def config
    @config ||= (super || {}).deep_symbolize_keys
  end

  def propagate(name, *args)
    # if we propagate cancel, we can't send it as "cancel", because
    # it would trigger cancelling the entire matrix
    if name == :cancel
      name = :cancel_job
    end
    Metriks.timer("job.propagate.#{name}").time do
      source.send(name, *args)
    end
    true
  end

  def duration
    started_at && finished_at ? finished_at - started_at : nil
  end

  def ssh_key
    config[:source_key]
  end

  def config=(config)
    @config = nil
    super normalize_config(config)
  end

  def obfuscated_config
    normalize_config(config).deep_dup.tap do |config|
      delete_addons(config)
      config.delete(:source_key)
      if config[:env]
        obfuscated_env = process_env(config[:env]) { |env| obfuscate_env(env) }
        config[:env] = obfuscated_env ? obfuscated_env.join(' ') : nil
      end
      if config[:global_env]
        obfuscated_env = process_env(config[:global_env]) { |env| obfuscate_env(env) }
        config[:global_env] = obfuscated_env ? obfuscated_env.join(' ') : nil
      end
    end
  end

  def decrypted_config
    normalize_config(self.config).deep_dup.tap do |config|
      config[:env] = process_env(config[:env]) { |env| decrypt_env(env) } if config[:env]
      config[:global_env] = process_env(config[:global_env]) { |env| decrypt_env(env) } if config[:global_env]
      if config[:addons]
        if addons_enabled?
          config[:addons] = decrypt_addons(config[:addons])
        else
          delete_addons(config)
        end
      end
    end
  rescue => e
    logger.warn "[job id:#{id}] Config could not be decrypted due to #{e.message}"
    {}
  end

  def matches_config?(other)
    config = self.config.slice(*other.keys)
    config = config.merge(branch: commit.branch) if other.key?(:branch) # TODO test this
    return false if config.size == 0
    config.all? { |key, value| value == other[key] || commit.branch == other[key] }
  end

  def log_content=(content)
    create_log! unless log
    log.update_attributes!(content: content, aggregated_at: Time.now)
  end

  # compatibility, we still use result in webhooks
  def result
    state.try(:to_sym) == :passed ? 0 : 1
  end

  private

    def whitelisted_addons
      [:apt_packages, :firefox, :hosts, :postgresql, :ssh_known_hosts]
    end

    def delete_addons(config)
      if config[:addons].is_a?(Hash)
        config[:addons].keep_if { |key, value| whitelisted_addons.include? key.to_sym }
      else
        config.delete(:addons)
      end
    end

    def normalize_config(config)
      config = config ? config.deep_symbolize_keys : {}

      if config[:deploy]
        config[:addons] ||= {}
        config[:addons][:deploy] = config.delete(:deploy)
      end

      config
    end

    def process_env(env)
      env = [env] unless env.is_a?(Array)
      env = normalize_env(env)
      env = if secure_env_enabled?
        yield(env)
      else
        remove_encrypted_env_vars(env)
      end
      env.compact.presence
    end

    def remove_encrypted_env_vars(env)
      env.reject do |var|
        var.is_a?(Hash) && var.has_key?(:secure)
      end
    end

    def normalize_env(env)
      env.map do |line|
        if line.is_a?(Hash) && !line.has_key?(:secure)
          line.map { |k, v| "#{k}=#{v}" }.join(' ')
        else
          line
        end
      end
    end

    def decrypt_addons(addons)
      decrypt(addons)
    end

    def decrypt_env(env)
      env.map do |var|
        decrypt(var) do |var|
          var.dup.insert(0, 'SECURE ') unless var.include?('SECURE ')
        end
      end
    rescue
      {}
    end

    def decrypt(v, &block)
      repository.key.secure.decrypt(v, &block)
    end
end


text:
function fnSelectNS() {
	var strDNS = ""
	if (document.form1.UseNameserver.value == "custom") {
		for (var i=0; i < document.form1.length; i++) {
			strDNS = document.form1.elements[i].id
			if (strDNS.indexOf("dns") != -1) {
				document.form1.elements[i].disabled = false;
				KillClass(document.form1.elements[i],'disabledInput');
			}
		}
		document.form1.dns[1].focus()
	} else {
		for (var i=0; i < document.form1.length; i++) {
			strDNS = document.form1.elements[i].id
			if (strDNS.indexOf("dns") != -1) {
				document.form1.elements[i].disabled = true;
				document.form1.elements[i].value = "";
				AddClass(document.form1.elements[i],'disabledInput');
			}
		}
	}
	return true
}


text:
git-pages
=========

Simple and robust GitHub Pages realisation for on-premise or in-cloud usage.

## Features

* compatible service hook
  * GitHub
  * GitLab
* fetches/updates only gh-pages branch
* custom domains support (fully GitHub Pages compatible)
* static file serving

## Installation and configuration
To be written...

## ToDo

* better logging
* custom 404 support
* write documentation
* mercurial support

## License
The MIT License (MIT)

Copyright (c) 2013 [Se7enSky studio](http://github.com/Se7enSky)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


text:
<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you under the Apache License, Version 2.0 (the
  ~ "License"); you may not use this file except in compliance
  ~ with the License.  You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.atlas</groupId>
        <artifactId>apache-atlas</artifactId>
        <version>0.8-graphdb-SNAPSHOT</version>
    </parent>
    <artifactId>atlas-webapp</artifactId>
    <description>Apache Atlas Web Application</description>
    <name>Apache Atlas Web Application</name>
    <packaging>war</packaging>

    <properties>
        <projectBaseDir>${project.basedir}/..</projectBaseDir>
        <debug.jetty.daemon>true</debug.jetty.daemon>
        <packages.to.exclude />
    </properties>

    <profiles>
        <profile>
            <id>jdk7</id>
            <activation>
                <jdk>[1.7,1.8)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.enunciate</groupId>
                        <artifactId>maven-enunciate-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>docs</goal>
                                </goals>
                                <phase>site</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- the directory where to put the docs -->
                            <docsDir>${project.build.directory}/apidocs</docsDir>
                            <configFile>${basedir}/../src/build/enunciate.xml</configFile>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- default profile is for external HBase and Solr - hence not packaging those jars -->
            <id>dist</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>WEB-INF/lib/titan-berkeleyje-${titan.version}.jar,WEB-INF/lib/je-*.jar,WEB-INF/lib/titan-es-${titan.version}.jar,WEB-INF/lib/elasticsearch-*.jar</packages.to.exclude>
            </properties>
        </profile>

        <profile>
            <id>berkeley-elasticsearch</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <packages.to.exclude>WEB-INF/lib/je-*.jar</packages.to.exclude>
            </properties>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-common</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-typesystem</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-repository</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-client</artifactId>
        </dependency>

	    <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-authorization</artifactId>
	    <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-notification</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-common</artifactId>
        </dependency>

       <!-- <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-auth</artifactId>
        </dependency> -->

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-minikdc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.hadoop</groupId>
            <artifactId>hadoop-hdfs</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-catalog</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-graphdb-impls</artifactId>
	    <type>pom</type>
        </dependency>

        <!-- supports simple auth handler -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-servlet</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-guice</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-jsp</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.el</artifactId>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-core</artifactId>
                <version>${spring.security.version}</version>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-web</artifactId>
                <version>${spring.security.version}</version>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-config</artifactId>
                <version>${spring.security.version}</version>
        </dependency>

        <dependency>
                <groupId>org.springframework.security</groupId>
                <artifactId>spring-security-ldap</artifactId>
                <version>${spring.security.version}</version>
        </dependency>
        <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>${javax.servlet.version}</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.ldap</groupId>
                <artifactId>spring-ldap-core</artifactId>
                <version>${spring-ldap-core.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-dashboardv2</artifactId>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.4</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.atlas</groupId>
            <artifactId>atlas-typesystem</artifactId>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <attachClasses>true</attachClasses>
                    <overlays>
                        <overlay>
                            <groupId>org.apache.atlas</groupId>
                            <artifactId>atlas-dashboardv2</artifactId>
                        </overlay>
		        <overlay>
		             <!-- empty groupId/artifactId represents the current build -->
            		</overlay>
                    </overlays>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                    <packagingExcludes>
                        ${packages.to.exclude}
                    </packagingExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>keytool-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>clean</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>generateKeyPair</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>generateKeyPair</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <dname>cn=atlas.incubator.apache.org</dname>
                    <keystore>${project.build.directory}/atlas.keystore</keystore>
                    <keypass>keypass</keypass>
                    <storepass>keypass</storepass>
                    <alias>atlas</alias>
                    <keyalg>RSA</keyalg>
                    <validity>100000</validity>
                </configuration>
            </plugin>

            <!-- Running unit tests in pre-integration-test phase after war is built -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <user.dir>${project.basedir}</user.dir>
                        <projectBaseDir>${project.basedir}/..</projectBaseDir>
                    </systemProperties>
                    <!--<skipTests>true</skipTests>-->
                    <forkMode>always</forkMode>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <argLine>-Djava.awt.headless=true -Dproject.version=${project.version}
                        -Dhadoop.tmp.dir=${project.build.directory}/tmp-hadoop-${user.name}
                        -Xmx1024m -XX:MaxPermSize=512m
                    </argLine>
                    <excludes>
                        <exclude>**/*Base*</exclude>
                    </excludes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-testng</artifactId>
                        <version>2.18.1</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <configuration>
                    <skip>${skipTests}</skip>
                    <!--only skip int tests -->
                    <httpConnector>
                        <port>31000</port>
                        <idleTimeout>60000</idleTimeout>
                    </httpConnector>
                    <war>${project.build.directory}/atlas-webapp-${project.version}.war</war>
                    <daemon>true</daemon>
                    <webAppSourceDirectory>webapp/src/test/webapp</webAppSourceDirectory>
                    <webApp>
                        <contextPath>/</contextPath>
                        <descriptor>${project.basedir}/src/test/webapp/WEB-INF/web.xml</descriptor>
                        <!-- ${project.build.directory}/atlas-webapp-${project.version} -->
                        <extraClasspath>${project.build.directory}/../../webapp/target/test-classes/</extraClasspath>
                    </webApp>
                    <useTestScope>true</useTestScope>
                    <systemProperties>
                        <systemProperty>
                            <name>log4j.configuration</name>
                            <value>file://${project.build.directory}/../../distro/src/conf/atlas-log4j.xml</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.log.file</name>
                            <value>application.log</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.log.dir</name>
                            <value>${project.build.directory}/logs</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.graphdb.backend</name>
                            <value>${plugin.class}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>keystore.file</name>
                            <value>${project.build.directory}/../../webapp/target/atlas.keystore
                            </value>
                        </systemProperty>
                        <systemProperty>
                            <name>truststore.file</name>
                            <value>${project.build.directory}/../../webapp/target/atlas.keystore</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.home</name>
                            <value>${project.build.directory}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.data</name>
                            <value>${project.build.directory}/data</value>
                        </systemProperty>
                        <systemProperty>
                            <name>atlas.graphdb.backend</name>
                            <value>${plugin.class}</value>
                        </systemProperty>
                        <systemProperty>
                            <key>atlas.conf</key>
                            <value>${project.build.directory}/../../typesystem/target/test-classes</value>
                        </systemProperty>
                    </systemProperties>
                    <stopKey>atlas-stop</stopKey>
                    <stopPort>31001</stopPort>
                    <stopWait>${jetty-maven-plugin.stopWait}</stopWait>
                    <daemon>${debug.jetty.daemon}</daemon>
                    <testClassesDirectory>${project.build.directory}/../../webapp/target/test-classes/</testClassesDirectory>
                    <useTestClasspath>true</useTestClasspath>
                </configuration>
                <executions>
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>deploy-war</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>


text:
var _ = require('underscore');
var $ = require('jquery'),
	Backbone = require('backbone'),
	projectIndexTemplate = require('../templates/projectIndex.tpl'),
	projectBarTemplate = require('../templates/_barProject.tpl'),
	Project = require('../models/Project');
var config = require('../conf');

Backbone.$ = $;

exports = module.exports = Backbone.View.extend({

	el: '#content',

	events: {
		'click .toggle-project': 'closeOrOpen',
	},

	initialize: function(options) {
		this.pid = options.pid;
		this.account = options.account;
		this.model = new Project();
		this.model.url = config.api.host + '/projects/' + options.pid;
		this.model.on('change', this.render, this);
		this.on('load', this.load, this);
	},

	load: function() {
		var that = this;
		this.model.fetch({
			xhrFields: {
				withCredentials: true
			},
			success: function(model) {
				var createby = model.get('createby') || {};
				if (that.account.id == createby.uid) {
					model.set('isOwner', true);
				}
			}
		});
	},

	closeOrOpen: function() {
		var that = this;
		var closed = this.model.get('closed');
		if (closed) {
			if (confirm('你确定要打开项目吗?')) {
				that.model.set('closed', false);
				that.render();
				$.ajax({
					url: config.api.host + '/projects/' + this.model.get('_id') + '/open',
					xhrFields: {
						withCredentials: true
					},
					data: {

					}
				}).done(function() {

				}).fail(function() {

				});
			}
		} else {
			if (confirm('你确定要关闭项目吗?')) {
				that.model.set('closed', true);
				that.render();
				$.ajax({
					url: config.api.host + '/projects/' + this.model.get('_id') + '/close',
					xhrFields: {
						withCredentials: true
					},
					data: {

					}
				}).done(function() {

				}).fail(function() {

				});
			}
		}
		return false;
	},

	render: function() {
		//增加 bottom Bar
		if ($('.navbar-absolute-bottom').length == 0) {
			var bottomBarHtml = projectBarTemplate({
				id: this.pid
			});
			$('.app').prepend('
' + bottomBarHtml + '
');
			if (!$('body').hasClass('has-navbar-bottom')) {
				$('body').addClass('has-navbar-bottom');
			}
		}
		this.$el.html(projectIndexTemplate({
			project: this.model.toJSON(),
			friends_num: this.model.get('friends') ? this.model.get('friends').length : 0
		}));
		return this;
	}
});


text:
namespace extensions {
namespace {

void BindRequestDisplayInfoResult(DisplayInfo* target, bool success) {
  ASSERT_TRUE(success);
  *target = DisplayInfoProvider::Get()->display_info();
}

void BindSetDisplayUnitInfoResult(bool* success,
                                  std::string* error,
                                  bool success_in,
                                  const std::string& error_in) {
  *success = success_in;
  *error = error_in;
}

class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase {
 public:
  DisplayInfoProviderChromeosTest() {}

  virtual ~DisplayInfoProviderChromeosTest() {}

 protected:
  void CallRequestDisplayInfo(DisplayInfo* result) {
    DisplayInfoProvider::Get()->RequestInfo(
        base::Bind(&BindRequestDisplayInfoResult, result));
    RunAllPendingInMessageLoop();
  }

  void CallSetDisplayUnitInfo(
      const std::string& display_id,
      const api::system_display::DisplayProperties& info,
      bool* success,
      std::string* error) {
    DisplayInfoProvider::Get()->SetInfo(display_id, info,
        base::Bind(&BindSetDisplayUnitInfoResult, success, error));
    RunAllPendingInMessageLoop();
  }

  bool DisplayExists(int64 display_id) const {
    const gfx::Display& display =
        GetDisplayManager()->GetDisplayForId(display_id);
    return display.id() != gfx::Display::kInvalidDisplayID;
  }

  ash::internal::DisplayManager* GetDisplayManager() const {
    return ash::Shell::GetInstance()->display_manager();
  }

  ash::DisplayController* GetDisplayController() const {
    return ash::Shell::GetInstance()->display_controller();
  }

  std::string SystemInfoDisplayInsetsToString(
      const api::system_display::Insets& insets) const {
    // Order to match gfx::Insets::ToString().
    return base::StringPrintf("%d,%d,%d,%d",
        insets.top,  insets.left, insets.bottom, insets.right);
  }

  std::string SystemInfoDisplayBoundsToString(
      const api::system_display::Bounds& bounds) const {
    // Order to match gfx::Rect::ToString().
    return base::StringPrintf("%d,%d %dx%d",
        bounds.left,  bounds.top, bounds.width, bounds.height);
  }

  DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest);
};

TEST_F(DisplayInfoProviderChromeosTest, GetBasic) {
  UpdateDisplay("500x600,400x520");
  DisplayInfo result;
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  int64 display_id;
  ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id))
      << "Display id must be convertable to integer: " << result[0]->id;

  ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
  EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan));
  EXPECT_EQ(0, result[0]->rotation);
  EXPECT_TRUE(result[0]->is_primary);
  EXPECT_EQ(96, result[0]->dpi_x);
  EXPECT_EQ(96, result[0]->dpi_y);
  EXPECT_TRUE(result[0]->mirroring_source_id.empty());
  EXPECT_TRUE(result[0]->is_enabled);

  ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id))
      << "Display id must be convertable to integer: " << result[0]->id;

  ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
  EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
            result[1]->name);
  // The second display is positioned left of the primary display, whose width
  // is 500.
  EXPECT_EQ("500,0 400x520",
            SystemInfoDisplayBoundsToString(result[1]->bounds));
  EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1]->overscan));
  EXPECT_EQ(0, result[1]->rotation);
  EXPECT_FALSE(result[1]->is_primary);
  EXPECT_EQ(96, result[1]->dpi_x);
  EXPECT_EQ(96, result[1]->dpi_y);
  EXPECT_TRUE(result[1]->mirroring_source_id.empty());
  EXPECT_TRUE(result[1]->is_enabled);
}

TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
  UpdateDisplay("500x600/r");
  DisplayInfo result;
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(1u, result.size());

  int64 display_id;
  ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id))
      << "Display id must be convertable to integer: " << result[0]->id;

  ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
  EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ(90, result[0]->rotation);

  GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270);

  CallRequestDisplayInfo(&result);

  ASSERT_EQ(1u, result.size());

  EXPECT_EQ(base::Int64ToString(display_id), result[0]->id);
  EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ(270, result[0]->rotation);

  GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180);

  CallRequestDisplayInfo(&result);

  ASSERT_EQ(1u, result.size());

  EXPECT_EQ(base::Int64ToString(display_id), result[0]->id);
  EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ(180, result[0]->rotation);

  GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0);

  CallRequestDisplayInfo(&result);

  ASSERT_EQ(1u, result.size());

  EXPECT_EQ(base::Int64ToString(display_id), result[0]->id);
  EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ(0, result[0]->rotation);
}

TEST_F(DisplayInfoProviderChromeosTest, GetHiDPI) {
  UpdateDisplay("500x600,400x520*2");
  DisplayInfo result;
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ(96, result[0]->dpi_x);
  EXPECT_EQ(96, result[0]->dpi_y);

  EXPECT_EQ("500,0 200x260",
            SystemInfoDisplayBoundsToString(result[1]->bounds));
  EXPECT_EQ(2 * 96, result[1]->dpi_x);
  EXPECT_EQ(2 * 96, result[1]->dpi_y);

  GetDisplayController()->SwapPrimaryDisplay();

  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  EXPECT_EQ("-500,0 500x600",
            SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ(96, result[0]->dpi_x);
  EXPECT_EQ(96, result[0]->dpi_y);

  EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1]->bounds));
  EXPECT_EQ(2 * 96, result[1]->dpi_x);
  EXPECT_EQ(2 * 96, result[1]->dpi_y);
}

TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
  UpdateDisplay("640x720*2/o, 400x520/o");
  DisplayInfo result;
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  int64 display_id;
  ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id))
      << "Display id must be convertable to integer: " << result[1]->id;
  ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";

  // Default overscan is 5%.
  EXPECT_EQ("304,0 380x494",
            SystemInfoDisplayBoundsToString(result[1]->bounds));
  EXPECT_EQ("13,10,13,10",
            SystemInfoDisplayInsetsToString(result[1]->overscan));

  GetDisplayManager()->SetOverscanInsets(display_id,
                                         gfx::Insets(20, 30, 50, 60));
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  EXPECT_EQ(base::Int64ToString(display_id), result[1]->id);
  EXPECT_EQ("304,0 310x450",
            SystemInfoDisplayBoundsToString(result[1]->bounds));
  EXPECT_EQ("20,30,50,60",
            SystemInfoDisplayInsetsToString(result[1]->overscan));

  // Set insets for the primary screen. Note that it has 2x scale.
  ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id))
      << "Display id must be convertable to integer: " << result[0]->id;
  ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";

  EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0]->overscan));

  GetDisplayManager()->SetOverscanInsets(display_id,
                                         gfx::Insets(10, 20, 30, 40));
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  EXPECT_EQ(base::Int64ToString(display_id), result[0]->id);
  EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ("10,20,30,40",
            SystemInfoDisplayInsetsToString(result[0]->overscan));
}

TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) {
  UpdateDisplay("600x600, 400x520/o");
  DisplayInfo result;
  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());

  int64 display_id_primary;
  ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id_primary))
      << "Display id must be convertable to integer: " << result[0]->id;
  ASSERT_TRUE(DisplayExists(display_id_primary))
      << display_id_primary << " not found";

  int64 display_id_secondary;
  ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id_secondary))
      << "Display id must be convertable to integer: " << result[1]->id;
  ASSERT_TRUE(DisplayExists(display_id_secondary))
      << display_id_secondary << " not found";

  ASSERT_FALSE(GetDisplayManager()->IsMirrored());
  EXPECT_TRUE(result[0]->mirroring_source_id.empty());
  EXPECT_TRUE(result[1]->mirroring_source_id.empty());

  GetDisplayManager()->SetMirrorMode(true);
  ASSERT_TRUE(GetDisplayManager()->IsMirrored());

  CallRequestDisplayInfo(&result);

  ASSERT_EQ(1u, result.size());
  EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id);
  EXPECT_EQ(base::Int64ToString(display_id_secondary),
            result[0]->mirroring_source_id);

  GetDisplayManager()->SetMirrorMode(false);
  ASSERT_FALSE(GetDisplayManager()->IsMirrored());

  CallRequestDisplayInfo(&result);

  ASSERT_EQ(2u, result.size());
  EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id);
  EXPECT_TRUE(result[0]->mirroring_source_id.empty());
  EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1]->id);
  EXPECT_TRUE(result[1]->mirroring_source_id.empty());
}

TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
  UpdateDisplay("600x600, 400x520");
  GetDisplayController()->SetLayoutForCurrentDisplays(
      ash::DisplayLayout::FromInts(ash::DisplayLayout::LEFT, -40));

  DisplayInfo result;
  CallRequestDisplayInfo(&result);
  ASSERT_EQ(2u, result.size());
  EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ("-400,-40 400x520",
            SystemInfoDisplayBoundsToString(result[1]->bounds));

  GetDisplayController()->SetLayoutForCurrentDisplays(
      ash::DisplayLayout::FromInts(ash::DisplayLayout::TOP, 40));

  CallRequestDisplayInfo(&result);
  ASSERT_EQ(2u, result.size());
  EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ("40,-520 400x520",
            SystemInfoDisplayBoundsToString(result[1]->bounds));

  GetDisplayController()->SetLayoutForCurrentDisplays(
      ash::DisplayLayout::FromInts(ash::DisplayLayout::BOTTOM, 80));

  CallRequestDisplayInfo(&result);
  ASSERT_EQ(2u, result.size());
  EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds));
  EXPECT_EQ("80,600 400x520",
            SystemInfoDisplayBoundsToString(result[1]->bounds));
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(-520));
  info.bounds_origin_y.reset(new int(50));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(1200));
  info.bounds_origin_y.reset(new int(100));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(1100));
  info.bounds_origin_y.reset(new int(-400));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(-350));
  info.bounds_origin_y.reset(new int(600));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(340));
  info.bounds_origin_y.reset(new int(100));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(-1040));
  info.bounds_origin_y.reset(new int(100));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) {
  UpdateDisplay("1200x600,520x400");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(-360));
  info.bounds_origin_y.reset(new int(-301));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest,
       SetBoundsOriginLeftButSharesBottomSide) {
  UpdateDisplay("1200x600,1000x100");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(-650));
  info.bounds_origin_y.reset(new int(700));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest,
       SetBoundsOriginRightButSharesTopSide) {
  UpdateDisplay("1200x600,1000x100");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(850));
  info.bounds_origin_y.reset(new int(-150));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest,
       SetBoundsOriginTopButSharesLeftSide) {
  UpdateDisplay("1200x600,1000x100/l");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(-150));
  info.bounds_origin_y.reset(new int(-650));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest,
       SetBoundsOriginBottomButSharesRightSide) {
  UpdateDisplay("1200x600,1000x100/l");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(1350));
  info.bounds_origin_y.reset(new int(450));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) {
  UpdateDisplay("1200x600*2,500x500");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(250));
  info.bounds_origin_y.reset(new int(-100));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(450));
  info.bounds_origin_y.reset(new int(-100));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  ASSERT_TRUE(error.empty());

  EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(0x200001));
  info.bounds_origin_y.reset(new int(-100));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  ASSERT_EQ("Bounds origin x out of bounds.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(300));
  info.bounds_origin_y.reset(new int(-0x200001));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  ASSERT_EQ("Bounds origin y out of bounds.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) {
  UpdateDisplay("1200x4600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(200000));
  info.bounds_origin_y.reset(new int(10));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(300));
  info.is_primary.reset(new bool(true));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  ASSERT_EQ("Bounds origin not allowed for the primary display.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());
  // The operation failed because the primary property would be set before
  // setting bounds. The primary display shouldn't have been changed, though.
  EXPECT_NE(ash::DisplayController::GetPrimaryDisplay().id(), secondary.id());
}

TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  const gfx::Display& primary = GetDisplayController()->GetPrimaryDisplay();

  api::system_display::DisplayProperties info;
  info.bounds_origin_x.reset(new int(300));
  info.mirroring_source_id.reset(
      new std::string(base::Int64ToString(primary.id())));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.",
            error);
}

TEST_F(DisplayInfoProviderChromeosTest, SetRotation) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.rotation.reset(new int(90));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("1200,0 500x300", secondary.bounds().ToString());
  EXPECT_EQ(gfx::Display::ROTATE_90, secondary.rotation());

  info.rotation.reset(new int(270));
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("1200,0 500x300", secondary.bounds().ToString());
  EXPECT_EQ(gfx::Display::ROTATE_270, secondary.rotation());

  info.rotation.reset(new int(180));
  // Switch primary display.
  info.is_primary.reset(new bool(true));
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("0,0 300x500", secondary.bounds().ToString());
  EXPECT_EQ(gfx::Display::ROTATE_180, secondary.rotation());
  EXPECT_EQ(ash::DisplayController::GetPrimaryDisplay().id(), secondary.id());

  info.rotation.reset(new int(0));
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("0,0 300x500", secondary.bounds().ToString());
  EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation());
  EXPECT_EQ(ash::DisplayController::GetPrimaryDisplay().id(), secondary.id());
}

TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.rotation.reset(new int(91));

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Invalid rotation.", error);
}

TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.overscan.reset(new api::system_display::Insets);
  info.overscan->left= -10;

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Negative overscan not allowed.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());

  info.overscan->left= 0;
  info.overscan->right = -200;

  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Negative overscan not allowed.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());

  info.overscan->right= 0;
  info.overscan->top = -300;

  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Negative overscan not allowed.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());

  info.overscan->right= 0;
  info.overscan->top = -1000;

  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Negative overscan not allowed.", error);

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());

  info.overscan->right= 0;
  info.overscan->top = 0;

  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString());
}

TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.overscan.reset(new api::system_display::Insets);
  // Horizontal overscan is 151, which would make the bounds width 149.
  info.overscan->left= 50;
  info.overscan->top = 10;
  info.overscan->right = 101;
  info.overscan->bottom = 20;

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Horizontal overscan is more than half of the screen width.",
            error);
}

TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) {
  UpdateDisplay("1200x600,600x1000");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.overscan.reset(new api::system_display::Insets);
  // Vertical overscan is 501, which would make the bounds height 499.
  info.overscan->left= 20;
  info.overscan->top = 250;
  info.overscan->right = 101;
  info.overscan->bottom = 251;

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Vertical overscan is more than half of the screen height.",
            error);
}

TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) {
  UpdateDisplay("1200x600,600x1000*2");

  const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay();
  api::system_display::DisplayProperties info;
  info.overscan.reset(new api::system_display::Insets);
  info.overscan->left= 20;
  info.overscan->top = 199;
  info.overscan->right = 130;
  info.overscan->bottom = 51;

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info,
      &success, &error);

  ASSERT_TRUE(success);
  EXPECT_TRUE(error.empty());

  EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString());
  const gfx::Insets overscan =
      GetDisplayManager()->GetOverscanInsets(secondary.id());

  EXPECT_EQ(20, overscan.left());
  EXPECT_EQ(199, overscan.top());
  EXPECT_EQ(130, overscan.right());
  EXPECT_EQ(51, overscan.bottom());
}

TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) {
  UpdateDisplay("1200x600,600x1000*2");
  const int64 internal_display_id =
      ash::test::DisplayManagerTestApi(GetDisplayManager()).
      SetFirstDisplayAsInternalDisplay();

  api::system_display::DisplayProperties info;
  info.overscan.reset(new api::system_display::Insets);
  // Vertical overscan is 501, which would make the bounds height 499.
  info.overscan->left= 20;
  info.overscan->top = 20;
  info.overscan->right = 20;
  info.overscan->bottom = 20;

  bool success = false;
  std::string error;
  CallSetDisplayUnitInfo(base::Int64ToString(internal_display_id), info,
      &success, &error);

  ASSERT_FALSE(success);
  EXPECT_EQ("Overscan changes not allowed for the internal monitor.",
            error);
}

}  // namespace
}  // namespace extensions


text:
package io.crate.replication.logical.action;

import io.crate.replication.logical.metadata.ConnectionInfo;
import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;

import java.io.IOException;
import java.util.List;

public class CreateSubscriptionRequest extends AcknowledgedRequest<CreateSubscriptionRequest> {

    private final String owner;
    private final String name;
    private final ConnectionInfo connectionInfo;
    private final List<String> publications;
    private final Settings settings;

    public CreateSubscriptionRequest(String owner,
                                     String name,
                                     ConnectionInfo connectionInfo,
                                     List<String> publications,
                                     Settings settings) {
        this.owner = owner;
        this.name = name;
        this.connectionInfo = connectionInfo;
        this.publications = publications;
        this.settings = settings;
    }

    public CreateSubscriptionRequest(StreamInput in) throws IOException {
        super(in);
        this.owner = in.readString();
        this.name = in.readString();
        connectionInfo = new ConnectionInfo(in);
        this.publications = List.of(in.readStringArray());
        settings = Settings.readSettingsFromStream(in);
    }

    public String owner() {
        return owner;
    }

    public String name() {
        return name;
    }

    public ConnectionInfo connectionInfo() {
        return connectionInfo;
    }

    public List<String> publications() {
        return publications;
    }

    public Settings settings() {
        return settings;
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        super.writeTo(out);
        out.writeString(owner);
        out.writeString(name);
        connectionInfo.writeTo(out);
        out.writeStringArray(publications.toArray(new String[0]));
        Settings.writeSettingsToStream(settings, out);
    }
}


text:
package org.switchyard.component.common.knowledge.transaction;

import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;

import org.hibernate.HibernateException;
import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform;

/**
 * KnowledgeJtaPlatform.
 *
 * @author David Ward <dward@jboss.org> © 2012 Red Hat Inc.
 */
@SuppressWarnings("serial")
public class KnowledgeJtaPlatform extends AbstractJtaPlatform {

    /**
     * {@inheritDoc}
     */
    @Override
    protected TransactionManager locateTransactionManager() {
        try {
            return TransactionManagerLocator.INSTANCE.getTransactionManager();
        } catch (Exception e) {
            throw new HibernateException(e);
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected UserTransaction locateUserTransaction() {
        try {
            return TransactionManagerLocator.INSTANCE.getUserTransaction();
        } catch (Exception e) {
            throw new HibernateException(e);
        }
    }

}


text:
::
:: Microsoft Azure SDK for Net - Generate library code
:: Copyright (C) Microsoft Corporation. All Rights Reserved.
::

@echo off
if  "%1" == "" (
    set specFile="https://raw.githubusercontent.com/Azure/azure-rest-api-specs/4b0aa25e9a1def98a8427cd27cc8ccbf80fa2c89/arm-sql/compositeSql.json"
) else (
    set specFile="%1"
)
set repoRoot=%~dp0..\..\..\..
set generateFolder=%~dp0Generated

if exist %generateFolder% rd /S /Q  %generateFolder%

autorest --latest -Modeler CompositeSwagger -CodeGenerator Azure.CSharp -Namespace Microsoft.Azure.Management.Sql -Input %specFile% -outputDirectory %generateFolder% -Header MICROSOFT_MIT %~5


text:
package com.reyun.presto.kudu.pool;

import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.PooledObjectFactory;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.kudu.client.KuduClient;
import org.apache.kudu.client.KuduException;

/**
 * PoolableObjectFactory custom impl.
 */
class KuduClientFactory
        implements PooledObjectFactory<KuduClient>
{
    private final String masterAddresses;

    public KuduClientFactory(final String masterAddresses)
    {
        this.masterAddresses = masterAddresses;
    }

    @Override
    public void activateObject(PooledObject<KuduClient> pooledKuduClient)
            throws Exception
    {
        // TODO active kudu client.
    }

    @Override
    public void destroyObject(PooledObject<KuduClient> pooledKuduClient)
            throws Exception
    {
        final KuduClient kuduClient = pooledKuduClient.getObject();
        kuduClient.close();
    }

    @Override
    public PooledObject<KuduClient> makeObject()
            throws Exception
    {
        KuduClient kuduClient = null;

        try {
            kuduClient = new KuduClient.KuduClientBuilder(masterAddresses).build();
        }
        catch (Exception e) {
            throw new KuduClientPoolException(e);
        }

        return new DefaultPooledObject<KuduClient>(kuduClient);
    }

    @Override
    public void passivateObject(PooledObject<KuduClient> pooledKuduClient)
            throws Exception
    {
        // TODO Not sure right now.
    }

    @Override
    public boolean validateObject(PooledObject<KuduClient> pooledKuduClient)
    {
        final KuduClient kuduClient = pooledKuduClient.getObject();
        try {
            kuduClient.listTabletServers();
            return true;
        }
        catch (KuduException e) {
            return false;
        }
    }
}


text:
"""MediaPipe Model Maker Python Public API For Image Classifier."""

from mediapipe.model_maker.python.vision.image_classifier import dataset
from mediapipe.model_maker.python.vision.image_classifier import hyperparameters
from mediapipe.model_maker.python.vision.image_classifier import image_classifier
from mediapipe.model_maker.python.vision.image_classifier import image_classifier_options
from mediapipe.model_maker.python.vision.image_classifier import model_options
from mediapipe.model_maker.python.vision.image_classifier import model_spec

ImageClassifier = image_classifier.ImageClassifier
HParams = hyperparameters.HParams
Dataset = dataset.Dataset
ModelOptions = model_options.ImageClassifierModelOptions
ModelSpec = model_spec.ModelSpec
SupportedModels = model_spec.SupportedModels
ImageClassifierOptions = image_classifier_options.ImageClassifierOptions


text:
package com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.converters;

import static java.util.Collections.emptyMap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.netflix.spinnaker.clouddriver.cloudfoundry.cache.CacheRepository;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.CloudFoundryClient;
import com.netflix.spinnaker.clouddriver.cloudfoundry.client.MockCloudFoundryClient;
import com.netflix.spinnaker.clouddriver.cloudfoundry.config.CloudFoundryConfigurationProperties;
import com.netflix.spinnaker.clouddriver.cloudfoundry.deploy.description.DeleteCloudFoundryServiceKeyDescription;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundryOrganization;
import com.netflix.spinnaker.clouddriver.cloudfoundry.model.CloudFoundrySpace;
import com.netflix.spinnaker.clouddriver.cloudfoundry.provider.CloudFoundryProvider;
import com.netflix.spinnaker.clouddriver.cloudfoundry.security.CloudFoundryCredentials;
import com.netflix.spinnaker.credentials.CredentialsRepository;
import com.netflix.spinnaker.credentials.MapBackedCredentialsRepository;
import io.vavr.collection.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ForkJoinPool;
import okhttp3.OkHttpClient;
import org.junit.jupiter.api.Test;

class DeleteCloudFoundryServiceKeyAtomicOperationConverterTest {
  private final CloudFoundryClient cloudFoundryClient = new MockCloudFoundryClient();
  private final CacheRepository cacheRepository = mock(CacheRepository.class);

  private CloudFoundryOrganization cloudFoundryOrganization =
      CloudFoundryOrganization.builder().id("org-guid").name("org").build();

  private CloudFoundrySpace cloudFoundrySpace =
      CloudFoundrySpace.builder()
          .id("space-guid")
          .name("space")
          .organization(cloudFoundryOrganization)
          .build();

  {
    when(cloudFoundryClient.getOrganizations().findByName(any()))
        .thenReturn(Optional.of(cloudFoundryOrganization));
    when(cloudFoundryClient.getSpaces().findSpaceByRegion(any()))
        .thenReturn(Optional.of(cloudFoundrySpace));
  }

  private final CloudFoundryCredentials cloudFoundryCredentials =
      new CloudFoundryCredentials(
          "my-account",
          "managerUri",
          "metricsUri",
          "apiHost",
          "username",
          "password",
          "environment",
          false,
          false,
          500,
          cacheRepository,
          null,
          ForkJoinPool.commonPool(),
          emptyMap(),
          new OkHttpClient(),
          new CloudFoundryConfigurationProperties.ClientConfig(),
          new CloudFoundryConfigurationProperties.LocalCacheConfig()) {
        public CloudFoundryClient getClient() {
          return cloudFoundryClient;
        }
      };

  private final CredentialsRepository<CloudFoundryCredentials> credentialsRepository =
      new MapBackedCredentialsRepository<>(CloudFoundryProvider.PROVIDER_ID, null);

  {
    credentialsRepository.save(cloudFoundryCredentials);
  }

  @Test
  void convertDescriptionSucceeds() {
    DeleteCloudFoundryServiceKeyAtomicOperationConverter converter =
        new DeleteCloudFoundryServiceKeyAtomicOperationConverter();
    converter.setCredentialsRepository(credentialsRepository);

    String serviceKeyName = "service-key-name";
    String serviceInstanceName = "service-instance-name";
    String region = "org > space";
    Map input =
        HashMap.of(
                "credentials", cloudFoundryCredentials.getName(),
                "region", region,
                "serviceInstanceName", serviceInstanceName,
                "serviceKeyName", serviceKeyName)
            .toJavaMap();

    DeleteCloudFoundryServiceKeyDescription expectedResult =
        (DeleteCloudFoundryServiceKeyDescription)
            new DeleteCloudFoundryServiceKeyDescription()
                .setServiceKeyName(serviceKeyName)
                .setServiceInstanceName(serviceInstanceName)
                .setSpace(cloudFoundrySpace)
                .setRegion(region)
                .setClient(cloudFoundryClient)
                .setCredentials(cloudFoundryCredentials);

    DeleteCloudFoundryServiceKeyDescription result = converter.convertDescription(input);

    assertThat(result).isEqualToComparingFieldByFieldRecursively(expectedResult);
  }
}


text:
package org.lorislab.barn.api.model;

import java.util.Map;

/**
 * The configuration model.
 *
 * @author Andrej Petras
 */
public interface Config {

    public void setType(String type);

    public String getType();

    public Map<String, ? extends Attribute> getAttributes();

}


text:
// DataImageCtrlMarkerDlg.cpp : implementation file
//

#include "stdafx.h"
#include "../Resource.h"
#include "DataImageCtrlMarkerDlg.h"

// CDataImageCtrlMarkerDlg dialog

IMPLEMENT_DYNAMIC(CDataImageCtrlMarkerDlg, CDialog)
CDataImageCtrlMarkerDlg::CDataImageCtrlMarkerDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDataImageCtrlMarkerDlg::IDD, pParent)
	, mMarker(0)
	, mMarkerDiameter(0)
{
}

CDataImageCtrlMarkerDlg::~CDataImageCtrlMarkerDlg()
{
}

void CDataImageCtrlMarkerDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_MARKER, mMarker);
	DDX_Text(pDX, IDC_MARKER_DIAMETER, mMarkerDiameter);
}

BEGIN_MESSAGE_MAP(CDataImageCtrlMarkerDlg, CDialog)
END_MESSAGE_MAP()

// CDataImageCtrlMarkerDlg message handlers


text:
RSpec.describe RuboCop::Cop::Rails::FindEach do
  subject(:cop) { described_class.new }

  shared_examples 'register_offense' do |scope|
    it "registers an offense when using #{scope}.each" do
      inspect_source("User.#{scope}.each { |u| u.something }")

      expect(cop.messages).to eq(['Use `find_each` instead of `each`.'])
    end

    it "does not register an offense when using #{scope}.order(...).each" do
      expect_no_offenses("User.#{scope}.order(:name).each { |u| u.something }")
    end

    it "does not register an offense when using #{scope}.limit(...).each" do
      expect_no_offenses("User.#{scope}.limit(10).each { |u| u.something }")
    end

    it "does not register an offense when using #{scope}.select(...).each" do
      expect_no_offenses("User.#{scope}.select(:name, :age).each " \
                          '{ |u| u.something }')
    end
  end

  it_behaves_like('register_offense', 'all')
  it_behaves_like('register_offense', 'eager_load(:association_name)')
  it_behaves_like('register_offense', 'includes(:association_name)')
  it_behaves_like('register_offense', 'joins(:association_name)')
  it_behaves_like('register_offense', 'left_joins(:association_name)')
  it_behaves_like('register_offense', 'left_outer_joins(:association_name)')
  it_behaves_like('register_offense', 'preload(:association_name)')
  it_behaves_like('register_offense', 'references(:association_name)')
  it_behaves_like('register_offense', 'unscoped')
  it_behaves_like('register_offense', 'where(name: name)')
  it_behaves_like('register_offense', 'where.not(name: name)')

  it 'does not register an offense when called on a constant' do
    expect_no_offenses('FOO.each { |u| u.x }')
  end

  it 'does not register an offense when using find_by' do
    expect_no_offenses('User.all.find_each { |u| u.x }')
  end

  it 'auto-corrects each to find_each' do
    expect_offense(<<~RUBY)
      User.all.each { |u| u.x }
               ^^^^ Use `find_each` instead of `each`.
    RUBY

    expect_correction(<<~RUBY)
      User.all.find_each { |u| u.x }
    RUBY
  end

  it 'registers an offense with non-send ancestors' do
    expect_offense(<<~RUBY)
      class C; User.all.each { |u| u.x }; end
                        ^^^^ Use `find_each` instead of `each`.
    RUBY

    expect_correction(<<~RUBY)
      class C; User.all.find_each { |u| u.x }; end
    RUBY
  end

  it 'does not register an offense when using order(...) earlier' do
    expect_no_offenses('User.order(:name).all.each { |u| u.something }')
  end
end


text:
import * as React from "react";
import { ComponentClass } from "react-redux";

import { Item, CarouselItem } from './CarouselItem';

/* eslint-disable import/no-unassigned-import, import/no-internal-modules */
import '../styles/carousel.css'
/* eslint-enable import/no-unassigned-import, import/no-internal-modules */

interface CarouselProps {
    title?: string;
    titleIcon?: string;
    titleDecoration?: JSX.Element;
    items: Item[];
    selectedItem?: string;
    itemClassName?: string;
    itemTemplate?: ((props: Item) => JSX.Element) | ComponentClass<any>;
    onItemSelect?: (id: string) => void;
    prependChildren?: JSX.Element[];
    appendChildren?: JSX.Element[];
}

interface CarouselState {
    showLeft: boolean;
    showRight: boolean;
}

export class Carousel extends React.Component<CarouselProps, CarouselState> {
    protected scrollMargin = 5;
    protected carouselRef: any;
    constructor(props: CarouselProps) {
        super(props);

        this.state = { showLeft: false, showRight: true };
    }

    componentDidMount() {
        this.handleScroll();
        window.addEventListener("resize", this.handleScroll);
    }

    componentWillUnmount() {
        window.removeEventListener("resize", this.handleScroll);
    }

    scrollTo = (left: number) => {
        this.carouselRef.scrollTo(left, 0);
    }

    protected handleLeftArrowClick = () => {
        this.carouselRef.scrollBy({ left: - (window.innerWidth / 2) });
    }

    protected handleRightArrowClick = () => {
        this.carouselRef.scrollBy({ left: window.innerWidth / 2 });
    }

    protected handleScroll = () => {
        const scrollLeft = this.carouselRef.scrollLeft;
        this.setState({
            showLeft: scrollLeft > this.scrollMargin,
            showRight: ((this.carouselRef.scrollWidth - this.carouselRef.clientWidth) - scrollLeft) > this.scrollMargin
        });
    }

    protected handleRef = (el: HTMLDivElement | null) => {
        this.carouselRef = el
    }

    render() {
        const {
            title,
            items,
            selectedItem,
            itemTemplate,
            itemClassName,
            onItemSelect,
            prependChildren,
            appendChildren,
            titleIcon,
            titleDecoration
        } = this.props;
        const { showLeft, showRight } = this.state;

        return

            {title &&

                {titleIcon && }
                {title}
                {titleDecoration && {titleDecoration}}

}
            {showLeft &&

}

                    {prependChildren}
                    {items.map((el, i) => {
                        return <CarouselItem key={i} className={itemClassName} item={el} itemTemplate={itemTemplate} selected={selectedItem === el.id} onSelect={onItemSelect} />
                    })}
                    {appendChildren}

            {showRight &&

}

    }
}


text:
Search
======

This module aim to provide all search options available in IMAP protocoles without having to read the entire IMAP RFC.

For now, you can do following searches

* Simple listing of all mails
* Search by tag
* Search by flag
* Search full text in mails body
* search by subject
* search by mail adresse, in *bcc*, *cc*, *from* or *to* header fields
* search by date, *before*, *after* or *on* a particular date
* search by header, given a pair of haeder name and header value to search
* search by size, *larger* or *smaller* than given value

Moreover, a few logical combination of the above

* Not
* Or

.. automodule:: imap_cli.search
    :members:


text:
Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

exports['default'] = createMountWrapper;

var _object = require('object.assign');

var _object2 = _interopRequireDefault(_object);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

/* eslint react/forbid-prop-types: 0 */

/**
 * This is a utility component to wrap around the nodes we are
 * passing in to `mount()`. Theoretically, you could do everything
 * we are doing without this, but this makes it easier since
 * `renderIntoDocument()` doesn't really pass back a reference to
 * the DOM node it rendered to, so we can't really "re-render" to
 * pass new props in.
 */
function createMountWrapper(node) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

  var WrapperComponent = function (_React$Component) {
    _inherits(WrapperComponent, _React$Component);

    function WrapperComponent() {
      var _ref;

      _classCallCheck(this, WrapperComponent);

      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }

      var _this = _possibleConstructorReturn(this, (_ref = WrapperComponent.__proto__ || Object.getPrototypeOf(WrapperComponent)).call.apply(_ref, [this].concat(args)));

      _this.state = {
        mount: true,
        props: _this.props.props,
        context: _this.props.context
      };
      return _this;
    }

    _createClass(WrapperComponent, [{
      key: 'setChildProps',
      value: function () {
        function setChildProps(newProps, newContext) {
          var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;

          var props = (0, _object2['default'])({}, this.state.props, newProps);
          var context = (0, _object2['default'])({}, this.state.context, newContext);
          this.setState({ props: props, context: context }, callback);
        }

        return setChildProps;
      }()
    }, {
      key: 'getInstance',
      value: function () {
        function getInstance() {
          var component = this._reactInternalInstance._renderedComponent;
          var inst = component.getPublicInstance();
          if (inst === null) {
            return component._instance;
          }
          return inst;
        }

        return getInstance;
      }()
    }, {
      key: 'getWrappedComponent',
      value: function () {
        function getWrappedComponent() {
          var component = this._reactInternalInstance._renderedComponent;
          var inst = component.getPublicInstance();
          if (inst === null) {
            return component._instance;
          }
          return inst;
        }

        return getWrappedComponent;
      }()
    }, {
      key: 'setChildContext',
      value: function () {
        function setChildContext(context) {
          var _this2 = this;

          return new Promise(function (resolve) {
            return _this2.setState({ context: context }, resolve);
          });
        }

        return setChildContext;
      }()
    }, {
      key: 'render',
      value: function () {
        function render() {
          var Component = this.props.Component;
          var _state = this.state,
              mount = _state.mount,
              props = _state.props;

          if (!mount) return null;
          return _react2['default'].createElement(Component, props);
        }

        return render;
      }()
    }]);

    return WrapperComponent;
  }(_react2['default'].Component);

  WrapperComponent.propTypes = {
    Component: _propTypes2['default'].oneOfType([_propTypes2['default'].func, _propTypes2['default'].string]).isRequired,
    props: _propTypes2['default'].object.isRequired,
    context: _propTypes2['default'].object
  };
  WrapperComponent.defaultProps = {
    context: null
  };

  if (options.context && (node.type.contextTypes || options.childContextTypes)) {
    // For full rendering, we are using this wrapper component to provide context if it is
    // specified in both the options AND the child component defines `contextTypes` statically
    // OR the merged context types for all children (the node component or deeper children) are
    // specified in options parameter under childContextTypes.
    // In that case, we define both a `getChildContext()` function and a `childContextTypes` prop.
    var childContextTypes = (0, _object2['default'])({}, node.type.contextTypes, options.childContextTypes);

    WrapperComponent.prototype.getChildContext = function () {
      function getChildContext() {
        return this.state.context;
      }

      return getChildContext;
    }();
    WrapperComponent.childContextTypes = childContextTypes;
  }
  return WrapperComponent;
}


text:
import ReactDOM from 'react-dom'
import promiseFinally from 'promise.prototype.finally'
import React from 'react'
// import {useStrict} from 'mobx'
import App from './containers/App'
import 'styles/main.css'
import 'utils/globalThemeSkin'

promiseFinally.shim()
// useStrict(true)

ReactDOM.render(<App />, document.getElementById('container'))


text:
<?php

declare(strict_types=1);

/*
 * This file is part of the SkeletonDancer package.
 *
 * (c) Sebastiaan Stok <s.stok@rollerscapes.net>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace SkeletonDancer;

use Pimple\Container as ServiceLocator;
use SkeletonDancer\Service\DanceAware;
use SkeletonDancer\Service\LazyService;

final class ClassInitializer
{
    /**
     * @var ServiceLocator
     */
    private $container;

    public function __construct(ServiceLocator $container)
    {
        $this->container = $container;
    }

    public function getNewInstanceFor(Dance $dance, string $className, string $expectedInterfaceType = null): object
    {
        $this->loadClass($className, $dance->directory);

        $r = new \ReflectionClass($className);

        if ($r->hasMethod('__construct')) {
            $methodReflection = $r->getMethod('__construct')->getParameters();
            $instanceArguments = [];

            foreach ($methodReflection as $parameter) {
                $instanceArguments[] = $this->resolveArgument($parameter, $dance);
            }

            $instance = new $className(...$instanceArguments);
        } else {
            $instance = new $className();
        }

        if (null !== $expectedInterfaceType && !$instance instanceof $expectedInterfaceType) {
            throw new \InvalidArgumentException(sprintf('Class "%s" is expected to implement "%s".', $className, $expectedInterfaceType));
        }

        return $instance;
    }

    private function loadClass(string $className, string $directory): void
    {
        $classParts = explode('\\', $className);

        if ('Dance' !== array_shift($classParts)) {
            throw new \InvalidArgumentException(sprintf('Dance provided classes are expected to begin with `Dance` for class "%s".', $className));
        }

        if (class_exists($className)) {
            return;
        }

        $expectedFilename = implode('/', $classParts).'.php';

        if (!file_exists($directory.'/'.$expectedFilename)) {
            throw new \InvalidArgumentException(sprintf('Unable to locate file %s in directory %s.', $expectedFilename, $directory));
        }

        require $directory.'/'.$expectedFilename;

        if (!class_exists($className, false)) {
            throw new \InvalidArgumentException(sprintf('Class %s was expected to be defined in %s', $className, $directory.'/'.$expectedFilename));
        }
    }

    private function resolveArgument(\ReflectionParameter $parameter, Dance $dance)
    {
        $name = StringUtil::underscore($parameter->name);

        if ('container' === $name) {
            return $this->container;
        }

        if (isset($this->container[$name])) {
            $service = $this->container[$name];

            if ($service instanceof DanceAware) {
                $service->setDance($dance);
            }

            if ($service instanceof LazyService) {
                return $service->getInstance();
            }

            return $service;
        }

        if ($parameter->isOptional()) {
            return $parameter->getDefaultValue();
        }

        throw new \RuntimeException(
            sprintf(
                'Unable to resolve parameter "%s" of class "%s" no service/parameter found with name "%s". '.
                'Consider adding a default value.',
                $name,
                $parameter->getDeclaringClass()->name,
                $name
            )
        );
    }
}


text:
namespace Lucene {

class DocFieldConsumersPerField : public DocFieldConsumerPerField {
public:
    DocFieldConsumersPerField(const DocFieldConsumersPerThreadPtr& perThread, const DocFieldConsumerPerFieldPtr& one, const DocFieldConsumerPerFieldPtr& two);
    virtual ~DocFieldConsumersPerField();

    LUCENE_CLASS(DocFieldConsumersPerField);

public:
    DocFieldConsumerPerFieldPtr one;
    DocFieldConsumerPerFieldPtr two;
    DocFieldConsumersPerThreadWeakPtr _perThread;

public:
    /// Processes all occurrences of a single field
    virtual void processFields(Collection<FieldablePtr> fields, int32_t count);

    virtual void abort();
};

}

#endif