text:
/**
 *
 */
package org.svnadmin.service;

import java.io.File;
import java.util.Collection;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.svnadmin.Constants;
import org.svnadmin.dao.PjDao;
import org.svnadmin.dao.PjUsrDao;
import org.svnadmin.entity.Pj;
import org.svnadmin.entity.PjUsr;
import org.svnadmin.entity.Usr;
import org.svnadmin.util.EncryptUtil;
import org.svnadmin.util.I18N;
import org.svnadmin.util.UsrProvider;
import org.tmatesoft.svn.core.SVNAuthenticationException;
import org.tmatesoft.svn.core.SVNDirEntry;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNWCUtil;

/**
 * 仓库服务层
 * @author Huiwu Yuan
 * @since 3.0.2
 *
 */
@Service(RepositoryService.BEAN_NAME)
public class RepositoryService{

	/**
	 * Bean名称
	 */
	public static final String BEAN_NAME="repositoryService";
	/**
	 * 日志
	 */
	private final Logger LOG = Logger.getLogger(RepositoryService.class);

	/**
	 * 项目DAO
	 */
	@Resource(name=PjDao.BEAN_NAME)
	PjDao pjDao;
	/**
	 * 项目用户DAO
	 */
	@Resource(name=PjUsrDao.BEAN_NAME)
	PjUsrDao pjUsrDao;

	/**
	 * 获取svn仓库
	 * @param pjId 项目ID
	 * @return svn仓库
	 * @throws SVNException svn异常,例如没有权限等
	 */
	public SVNRepository getRepository(String pjId) throws SVNException{
		Pj pj = pjDao.get(pjId);
		if(pj == null){
			LOG.warn("Not found project: "+pjId);
			return null;
		}
		return this.getRepository(pj);
	}

	/**
	 * 从项目的url中获取svn的url
	 * @param url 项目url
	 * @return svn url
	 */
	public static String parseURL(String url){
		if(StringUtils.isBlank(url)){
			return null;
		}
		String result = url.trim();//去空格
		result = StringUtils.replace(result, "\t", " ");
		result = StringUtils.replace(result, "\r", " ");
		result = StringUtils.replace(result, "\n", " ");
		result = StringUtils.replace(result, "\b", " ");
		result = StringUtils.replace(result, "<", " ");//eg.

		result = StringUtils.replace(result, "(", " ");//eg. ()

		result = result.trim();
		int blank = result.indexOf(" ");
		if(blank != -1){
			result = result.substring(0, blank);
		}

		return result;
	}

	/**
	 * 获取svn仓库
	 * @param pj 项目
	 * @return svn仓库
	 * @throws SVNException svn异常,例如没有权限等
	 */
	public SVNRepository getRepository(Pj pj) throws SVNException{

		Usr usr = UsrProvider.getCurrentUsr();

		String svnUrl = parseURL(pj.getUrl());
		if(StringUtils.isBlank(svnUrl)){
			throw new RuntimeException(I18N.getLbl("pj.error.url", "URL不可以为空"));
		}
		String svnUserName = usr.getUsr();
		String svnPassword = usr.getPsw();
		if(!Constants.HTTP_MUTIL.equals(pj.getType())){
			//pj_usr覆盖用户的密码
			PjUsr pjUsr = pjUsrDao.get(pj.getPj(), svnUserName);
			if(pjUsr != null){
				svnPassword = pjUsr.getPsw();
			}
		}
		svnPassword = EncryptUtil.decrypt(svnPassword);//解密

    	 SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(svnUrl));
	     ISVNAuthenticationManager authManager =
	                  SVNWCUtil.createDefaultAuthenticationManager(svnUserName, svnPassword);
	     repository.setAuthenticationManager(authManager);

	     return repository;
	}

	/**
	 * 返回项目仓库的根
	 * @param pj 项目
	 * @return 仓库根
	 */
	public String getRepositoryRoot(Pj pj){
		SVNRepository repository = null;
		try{
			repository = this.getRepository(pj);
			return repository.getRepositoryRoot(true).toString();
		}catch(SVNAuthenticationException e){
    		LOG.error(e.getMessage());
    		return null;
    	} catch (SVNException e) {
    		LOG.error(e.getMessage());
    		e.printStackTrace();
			return null;
		}finally{
			if(repository != null){
				repository.closeSession();
			}
		}
	}

	/**
	 * 获取项目指定路径的svn仓库文件系统
	 * @param pj 项目
	 * @param path 相对仓库根目录的路径
	 * @return 目录或文件系统
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public Collection<SVNDirEntry> getDir(String pj,String path){
		if(StringUtils.isBlank(path)){
			path = "/";//root
		}
		if(!path.startsWith("/")){
			path = "/"+path;
		}
		SVNRepository repository = null;
		try {
			repository = this.getRepository(pj);
			SVNProperties properties = new SVNProperties();
	    	return repository.getDir(path, SVNRevision.HEAD.getNumber(), properties, (Collection) null);
    	}catch(SVNAuthenticationException e){
    		e.printStackTrace();
			throw new RuntimeException(I18N.getLbl("svn.auth.error", "认证失败"));
    	}catch (SVNException e) {
    		e.printStackTrace();
    		throw new RuntimeException(e.getMessage());
		}finally{
			if(repository!=null){
				repository.closeSession();
			}
		}
	}

	/**
     * Creates a local blank FSFS-type repository.
     * A call to this routine is equivalent to
     * createLocalRepository(path, null, enableRevisionProperties, force).
     *
     * @param  respository                          a repository root location
     * @return                               a local URL (file:///) of a newly
     *                                       created repository
     */
	public static SVNURL createLocalRepository(File respository){
		try {
			return SVNRepositoryFactory.createLocalRepository(respository, true,
					false);
		} catch (SVNException e) {
			throw new RuntimeException(I18N.getLbl("pj.save.error.createRepository","创建仓库失败.{0}",new Object[]{respository.getAbsolutePath()})
			+ " : "+ e.getMessage());
		}
	}

	static {
        /*
         * For using over http:// and https://
         */
        DAVRepositoryFactory.setup();
        /*
         * For using over svn:// and svn+xxx://
         */
        SVNRepositoryFactoryImpl.setup();

        /*
         * For using over file:///
         */
        FSRepositoryFactory.setup();
    }

}


text:
package cronapi.osjava.sj.loader.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 * Loads properties using the DOM API from an InputStream containing XML
 */
public class XmlProperties extends AbstractProperties {

    public XmlProperties() {
        super();
    }

    public XmlProperties(Properties props) {
        super(props);
    }

    public void load(InputStream in) throws IOException {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = null;
        Document document = null;

        try {
            builder = factory.newDocumentBuilder();
            document = builder.parse(in);
        } catch (ParserConfigurationException pce) {
            throw new IOException("Unable to get DocumentBuilder from factory. " + pce.getMessage());
        }
        catch (SAXException se) {
            throw new IOException("Unable to parse document. " + se.getMessage());
        }

        if (document != null) {
            loadDocument(document);
        }
    }

    private void loadDocument(Document document) {
        Element root = document.getDocumentElement();
        String level = root.getNodeName();
        processChildren(level, root);
    }

    private void processChildren(String level, Node node) {
        NodeList children = node.getChildNodes();
        for(int i=0;i<children.getLength();i++) {
            Node child = children.item(i);
            addNode(level, child);
            if (child.hasAttributes()) {
                String attributeLevel = level + getDelimiter() + child.getNodeName();
                addAttributes(attributeLevel, child.getAttributes());
            }
        }
    }

    private void addNode(String level, Node node) {
        switch (node.getNodeType()) {
            case Node.ELEMENT_NODE :
                level = level + getDelimiter() + node.getNodeName();
                break;
            case Node.TEXT_NODE :
                store(level, node.getNodeValue());
                break;
        }

        processChildren(level, node);
    }

    private void addAttributes(String level, NamedNodeMap map) {
        for(int i=0;i<map.getLength();i++) {
            Node attribute = map.item(i);
            String attributeLevel = level + getDelimiter() + attribute.getNodeName();
            store(attributeLevel, attribute.getNodeValue());
        }
    }

    private void store(String name, String value) {
        if (value.trim().length() > 0) {
            setProperty(name, value);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package org.jetbrains.plugins.github;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ThrowableConsumer;
import com.intellij.util.ThrowableConvertor;
import git4idea.GitUtil;
import git4idea.config.GitVcsApplicationSettings;
import git4idea.config.GitVersion;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.github.api.*;
import org.jetbrains.plugins.github.ui.GithubBasicLoginDialog;
import org.jetbrains.plugins.github.ui.GithubLoginDialog;

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

/**
 * Various utility methods for the GutHub plugin.
 *
 * @author oleg
 * @author Kirill Likhodedov
 * @author Aleksey Pivovarov
 */
public class GithubUtil {

  public static final Logger LOG = Logger.getInstance("github");

  // TODO: these functions ugly inside and out
  @NotNull
  public static GithubAuthData runAndGetValidAuth(@Nullable Project project,
                                                  @NotNull ProgressIndicator indicator,
                                                  @NotNull ThrowableConsumer<GithubAuthData, IOException> task) throws IOException {
    GithubAuthData auth = GithubSettings.getInstance().getAuthData();
    try {
      if (auth.getAuthType() == GithubAuthData.AuthType.ANONYMOUS) {
        throw new GithubAuthenticationException("Bad authentication type");
      }
      task.consume(auth);
      return auth;
    }
    catch (GithubAuthenticationException e) {
      auth = getValidAuthData(project, indicator);
      if (auth == null) {
        throw new GithubAuthenticationCanceledException("Can't get valid credentials");
      }
      task.consume(auth);
      return auth;
    }
    catch (IOException e) {
      if (checkSSLCertificate(e, auth.getHost(), indicator)) {
        return runAndGetValidAuth(project, indicator, task);
      }
      throw e;
    }
  }

  @NotNull
  public static <T> T runWithValidAuth(@Nullable Project project,
                                       @NotNull ProgressIndicator indicator,
                                       @NotNull ThrowableConvertor<GithubAuthData, T, IOException> task) throws IOException {
    GithubAuthData auth = GithubSettings.getInstance().getAuthData();
    try {
      if (auth.getAuthType() == GithubAuthData.AuthType.ANONYMOUS) {
        throw new GithubAuthenticationException("Bad authentication type");
      }
      return task.convert(auth);
    }
    catch (GithubAuthenticationException e) {
      auth = getValidAuthData(project, indicator);
      if (auth == null) {
        throw new GithubAuthenticationCanceledException("Can't get valid credentials");
      }
      return task.convert(auth);
    }
    catch (IOException e) {
      if (checkSSLCertificate(e, auth.getHost(), indicator)) {
        return runWithValidAuth(project, indicator, task);
      }
      throw e;
    }
  }

  @NotNull
  public static <T> T runWithValidBasicAuth(@Nullable Project project,
                                            @NotNull ProgressIndicator indicator,
                                            @NotNull ThrowableConvertor<GithubAuthData, T, IOException> task) throws IOException {
    GithubAuthData auth;
    if (GithubSettings.getInstance().getAuthType() == GithubAuthData.AuthType.BASIC) {
      auth = GithubSettings.getInstance().getAuthData();
    }
    else {
      auth = GithubAuthData.createAnonymous();
    }
    try {
      if (auth.getAuthType() != GithubAuthData.AuthType.BASIC) {
        throw new GithubAuthenticationException("Bad authentication type");
      }
      return task.convert(auth);
    }
    catch (GithubAuthenticationException e) {
      auth = getValidBasicAuthData(project, indicator);
      if (auth == null) {
        throw new GithubAuthenticationCanceledException("Can't get valid credentials");
      }
      return task.convert(auth);
    }
    catch (IOException e) {
      if (checkSSLCertificate(e, auth.getHost(), indicator)) {
        return runWithValidBasicAuth(project, indicator, task);
      }
      throw e;
    }
  }

  private static boolean checkSSLCertificate(IOException e, final String host, ProgressIndicator indicator) {
    final GithubSslSupport sslSupport = GithubSslSupport.getInstance();
    if (GithubSslSupport.isCertificateException(e)) {
      final Ref<Boolean> result = new Ref<Boolean>();
      ApplicationManager.getApplication().invokeAndWait(new Runnable() {
        @Override
        public void run() {
          result.set(sslSupport.askIfShouldProceed(host));
        }
      }, indicator.getModalityState());
      return result.get();
    }
    return false;
  }

  /**
   * @return null if user canceled login dialog. Valid GithubAuthData otherwise.
   */
  @Nullable
  public static GithubAuthData getValidAuthData(@Nullable Project project, @NotNull ProgressIndicator indicator) {
    final GithubLoginDialog dialog = new GithubLoginDialog(project);
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      @Override
      public void run() {
        dialog.show();
      }
    }, indicator.getModalityState());
    if (!dialog.isOK()) {
      return null;
    }
    return dialog.getAuthData();
  }

  /**
   * @return null if user canceled login dialog. Valid GithubAuthData otherwise.
   */
  @Nullable
  public static GithubAuthData getValidBasicAuthData(@Nullable Project project, @NotNull ProgressIndicator indicator) {
    final GithubLoginDialog dialog = new GithubBasicLoginDialog(project);
    ApplicationManager.getApplication().invokeAndWait(new Runnable() {
      @Override
      public void run() {
        dialog.show();
      }
    }, indicator.getModalityState());
    if (!dialog.isOK()) {
      return null;
    }
    return dialog.getAuthData();
  }

  @Nullable
  public static GithubAuthData getValidAuthDataFromConfig(@Nullable Project project, @NotNull ProgressIndicator indicator) {
    GithubAuthData auth = GithubSettings.getInstance().getAuthData();
    try {
      checkAuthData(auth);
      return auth;
    }
    catch (GithubAuthenticationException e) {
      return getValidAuthData(project, indicator);
    }
    catch (IOException e) {
      LOG.info("Connection error", e);
      return null;
    }
  }

  @NotNull
  public static GithubUserDetailed checkAuthData(@NotNull GithubAuthData auth) throws IOException {
    if (StringUtil.isEmptyOrSpaces(auth.getHost())) {
      throw new GithubAuthenticationException("Target host not defined");
    }

    switch (auth.getAuthType()) {
      case BASIC:
        GithubAuthData.BasicAuth basicAuth = auth.getBasicAuth();
        assert basicAuth != null;
        if (StringUtil.isEmptyOrSpaces(basicAuth.getLogin()) || StringUtil.isEmptyOrSpaces(basicAuth.getPassword())) {
          throw new GithubAuthenticationException("Empty login or password");
        }
        break;
      case TOKEN:
        GithubAuthData.TokenAuth tokenAuth = auth.getTokenAuth();
        assert tokenAuth != null;
        if (StringUtil.isEmptyOrSpaces(tokenAuth.getToken())) {
          throw new GithubAuthenticationException("Empty token");
        }
        break;
      case ANONYMOUS:
        throw new GithubAuthenticationException("Anonymous connection not allowed");
    }

    try {
      return testConnection(auth);
    }
    catch (JsonException e) {
      throw new GithubAuthenticationException("Can't get user info", e);
    }
  }

  @NotNull
  private static GithubUserDetailed testConnection(@NotNull GithubAuthData auth) throws IOException {
    return GithubApiUtil.getCurrentUserDetailed(auth);
  }

  /*
  * Git utils
  */

  @Nullable
  public static String findGithubRemoteUrl(@NotNull GitRepository repository) {
    Pair<GitRemote, String> remote = findGithubRemote(repository);
    if (remote == null) {
      return null;
    }
    return remote.getSecond();
  }

  @Nullable
  public static Pair<GitRemote, String> findGithubRemote(@NotNull GitRepository repository) {
    Pair<GitRemote, String> githubRemote = null;
    for (GitRemote gitRemote : repository.getRemotes()) {
      for (String remoteUrl : gitRemote.getUrls()) {
        if (GithubUrlUtil.isGithubUrl(remoteUrl)) {
          final String remoteName = gitRemote.getName();
          if ("github".equals(remoteName) || "origin".equals(remoteName)) {
            return new Pair<GitRemote, String>(gitRemote, remoteUrl);
          }
          if (githubRemote == null) {
            githubRemote = new Pair<GitRemote, String>(gitRemote, remoteUrl);
          }
          break;
        }
      }
    }
    return githubRemote;
  }

  @Nullable
  public static String findUpstreamRemote(@NotNull GitRepository repository) {
    for (GitRemote gitRemote : repository.getRemotes()) {
      final String remoteName = gitRemote.getName();
      if ("upstream".equals(remoteName)) {
        for (String remoteUrl : gitRemote.getUrls()) {
          if (GithubUrlUtil.isGithubUrl(remoteUrl)) {
            return remoteUrl;
          }
        }
        return gitRemote.getFirstUrl();
      }
    }
    return null;
  }

  public static boolean testGitExecutable(final Project project) {
    final GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance();
    final String executable = settings.getPathToGit();
    final GitVersion version;
    try {
      version = GitVersion.identifyVersion(executable);
    }
    catch (Exception e) {
      GithubNotifications.showErrorDialog(project, GitBundle.getString("find.git.error.title"), e);
      return false;
    }

    if (!version.isSupported()) {
      GithubNotifications.showWarningDialog(project, GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN),
                                            GitBundle.getString("find.git.success.title"));
      return false;
    }
    return true;
  }

  public static boolean isRepositoryOnGitHub(@NotNull GitRepository repository) {
    return findGithubRemoteUrl(repository) != null;
  }

  public static void setVisibleEnabled(AnActionEvent e, boolean visible, boolean enabled) {
    e.getPresentation().setVisible(visible);
    e.getPresentation().setEnabled(enabled);
  }

  @NotNull
  public static String getErrorTextFromException(@NotNull IOException e) {
    return e.getMessage();
  }

  @Nullable
  public static GitRepository getGitRepository(@NotNull Project project, @Nullable VirtualFile file) {
    GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
    List<GitRepository> repositories = manager.getRepositories();
    if (repositories.size() == 0) {
      return null;
    }
    if (repositories.size() == 1) {
      return repositories.get(0);
    }
    if (file != null) {
      GitRepository repository = manager.getRepositoryForFile(file);
      if (repository != null) {
        return repository;
      }
    }
    return manager.getRepositoryForFile(project.getBaseDir());
  }

}


text:
package org.commonjava.indy.content.index.change;

import org.commonjava.indy.change.event.ArtifactStoreDeletePostEvent;
import org.commonjava.indy.content.index.ContentIndexManager;
import org.commonjava.indy.model.core.ArtifactStore;
import org.commonjava.indy.model.core.StoreKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

@ApplicationScoped
public class StoreChangeListener
{
    private final Logger logger = LoggerFactory.getLogger( getClass() );

    @Inject
    private ContentIndexManager contentIndexManager;

    public void storeDeleted( @Observes final ArtifactStoreDeletePostEvent event )
    {
        logger.info( "Updating content index for removed stores." );
        for ( final ArtifactStore store : event )
        {
            logger.info( "Updating content index for removal of: {}", store.getKey() );
            processChanged( store );
        }
    }

    private void processChanged( final ArtifactStore store )
    {
        final StoreKey key = store.getKey();

        logger.info( "Clean index for: {}", key );
        contentIndexManager.clearAllIndexedPathInStore( store );

        logger.info( "Clean index with origin: {}", key );
        contentIndexManager.clearAllIndexedPathWithOriginalStore( store );
    }

}


text:
export const environment = {
    production: false,
    hmr: false,
    appConfig: 'appconfig.json'
};


text:
/*_____________________________________________  container, overlay, & wrapper  */
#sb-container, #sb-wrapper {
  text-align: left; /* reset left alignment */
}
#sb-container, #sb-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  margin: 0;
  padding: 0;
}
#sb-container {
  height: 100%;
  display: none;
  visibility: hidden;
  z-index: 999;
}
body > #sb-container {
  /* use position:fixed in modern browsers */
  position: fixed;
}
#sb-overlay {
  /* needed in IE6 where sb-container uses position:absolute */
  /* height: expression(document.documentElement.clientHeight + 'px'); */
}
#sb-container > #sb-overlay {
  /* use for sb-container position:fixed */
  height: 100%;
}

/*_________________________________________________________________  wrapper  */
#sb-wrapper {
  position: relative;
}
#sb-wrapper img {
  border: none;
}

/*____________________________________________________________________  body  */
#sb-body {
  position: relative;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #303030;
}
#sb-body-inner {
  position: relative;
  height: 100%;
}
#sb-content.html {
  height: 100%;
  overflow: auto; /* make html content scrollable */
}

/*_________________________________________________________________  loading  */
#sb-loading {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  text-align: center;
  padding-top: 10px;
}
#sb-body, #sb-loading {
  background-color: #060606; /* should match loading image background color */
}

/*____________________________________________________________  title & info  */
#sb-title, #sb-info {
  position: relative;
  margin: 0; /* these must have no vertical margin or padding */
  padding: 0;
  overflow: hidden;
}
#sb-title-inner, #sb-info-inner {
  position: relative;
  font-family: 'Lucida Grande', Tahoma, sans-serif;
  line-height: 16px;
}
#sb-title, #sb-title-inner {
  height: 26px;
}
#sb-title-inner {
  font-size: 16px;
  padding: 5px 0;
  color: #fff;
}
#sb-info, #sb-info-inner {
  height: 20px;
}
#sb-info-inner {
  font-size: 12px;
  color: #fff;
}

/*_____________________________________________________________________  nav  */
#sb-nav {
  float: right;
  height: 16px;
  padding: 2px 0;
  width: 45%;
}
#sb-nav a {
  display: block;
  float: right;
  height: 16px;
  width: 16px;
  margin-left: 3px;
  cursor: pointer;
}
#sb-nav-close {
  background-image: url(resources/close.png);
  background-repeat: no-repeat;
}
#sb-nav-next {
  background-image: url(resources/next.png);
  background-repeat: no-repeat;
}
#sb-nav-previous {
  background-image: url(resources/previous.png);
  background-repeat: no-repeat;
}
#sb-nav-play {
  background-image: url(resources/play.png);
  background-repeat: no-repeat;
}
#sb-nav-pause {
  background-image: url(resources/pause.png);
  background-repeat: no-repeat;
}

/*_________________________________________________________________  counter  */
#sb-counter {
  float: left;
  padding: 2px 0;
  width: 45%;
}
#sb-counter a {
  padding: 0 4px 0 0;
  text-decoration: none;
  cursor: pointer;
  color: #fff;
}
#sb-counter a.sb-counter-current {
  text-decoration: underline;
}

/*________________________________________________________________  messages  */
div.sb-message {
  font-family: 'Lucida Grande', Tahoma, sans-serif;
  font-size: 12px;
  padding: 10px;
  text-align: center;
}
div.sb-message a:link, div.sb-message a:visited {
  color: #fff;
  text-decoration: underline;
}


text:
Logging
=======

Ninja uses the Logback via slf4j as logging library.

Configuration of Logback inside Ninja
-------------------------------------

Usually you want to use different logging settings when running in test, dev
or on production.

There are three main ways how you can configure Logback.

### #1 Using logback.xml

By default Logback will look for a file called logback.xml in the root of
your application. If it finds one it will intialize the logging system
accordingly. This approach is okay for simple setups.

### #2 Using Java system property to specify link to logback.xml

Logback evaluates a Java system property named logback.configurationFile.
This approach is handy if you are using Ninja's standalone mode:

java -Dlogback.configurationFile=/srv/conf/logback.xml -jar ninja-application.jar

This allows you to use one logging configuration for all your instances.
More about that approach here: http://logback.qos.ch/manual/configuration.html

### #3 Using application.conf to switch configurations

If you cannot or do not want to use external Java system properties you can
use application.conf and the key logback.configurationFile to specify
the location of the logging file. Ninja will pick up the file and configure
Logback accordingly.

# An example for application.conf based configuration of logback
%prod.logback.configurationFile=logback_prod.xml   # will be used in production
%dev.logback.configurationFile=logback_dev.xml     # will be used in dev mode

Ninja will look for specified files in three places in the following order:

 * On the classpath
 * On the filesystem
 * and if the "file" is a http url it will try to load the configuration from there.

There is one tiny drawback with using application.conf to configure logging:

Logging can start before Ninja starts up. Think of Jetty starting up and once
startup is finished Ninja begins to load. Jetty already might write some log messages,
but these are not configured by Ninja's applications.conf.

In that early phase it might be the case that Logback uses a default
configuration that prints out messages to System.out.

Using the Java system property -Dlogback.configurationFile to configure
logging will always override all settings in application.conf. This also configures
logging from the very beginning.

Quick intro to Logback
----------------------

Ninja provides you with a simple foundation to use Logback.
And this is perfect, because logback has everything you need to configure
logging - even for the largest systems you can image.

The best way to configure Logback is to follow the excellent guide
at: http://logback.qos.ch/manual/configuration.html

But just in case you were wondering how such a logback.xml file can look like:

<configuration>

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>myApp.log</file>

    <encoder>
      <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%msg%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="FILE" />
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

By the way - you can also write logback configuration files in Groovy.


text:
<?php

namespace Flower\ServiceLayer\Exception;
interface ExceptionInterface
{
}


text:
<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\bootstrap\Modal;
use yii\gii\generators\model\Generator;

/* @var $this yii\web\View */
/* @var $schema tunecino\models\Schema */
/* @var $form yii\widgets\ActiveForm */

$schemaForms = $schema->loadForms();
?>

    <?php $form = ActiveForm::begin([
        'options' => ['data-type' => 'ajax', 'style' => ['display' => 'inherit']],
    	  'action' => $schema->isNewRecord ? ['create-schema'] : ['update-schema', 'id' => $schema->id],
        // https://stackoverflow.com/questions/28756397/yii2-conditional-validator-always-returns-required
        'enableClientValidation' => false,
        'enableAjaxValidation' => true
    ]); ?>

    <?php Modal::begin([
        'id' => 'schema-' . ($schema->isNewRecord ? 'new' : $schema->id),
        'options' => ['class' => 'modal modal-fullscreen fade', 'data-backdrop' => 'static'],
        'header' =>  $schema->isNewRecord ?
            '
Create New Schema
' : '
Update Schema '.$schema->name.'
',
        'toggleButton' => $schema->isNewRecord ?
            ['label' => ' NEW', 'class' => 'btn btn-primary pull-right mt20 mb20'] :
            ['label' => ' UPDATE', 'class' => 'btn btn-info mt20 mb20'] ,
        'footer' =>
            Html::resetButton('Reset all', ['class' => 'btn btn-default']) .
            Html::submitButton($schema->isNewRecord ? 'Create' : 'Update', ['class' => $schema->isNewRecord ? 'btn btn-primary' : 'btn btn-info'])
    ]); ?>

Schema

    <?php foreach ($schemaForms as $fname => $fobj) { ?>

<a href="#<?= $fname ?>" aria-controls="<?= $fname ?>" role="tab" data-toggle="tab"><?= $fname ?>

    <?php } ?>

        <?= $form->field($schema, 'id')->hiddenInput()->label(false) ?>
        <?= $form->field($schema, 'name')->textInput(['maxlength' => true])?>
        <?= $form->field($schema, 'isModule')->hiddenInput()->label(false) ?>

    <?php foreach ($schemaForms as $fname => $fobj) { ?>
        <div role="tabpanel" class="tab-pane" id="<?= $fname ?>">
            <?= $form->field($schema, 'id')->hiddenInput()->label(false) ?>
            <?= $this->renderFile($fobj['viewFile'], [
                'model' => $fobj['model'],
                'form' => $form
            ]) ?>

    <?php } ?>

  <?= Html::hiddenInput('reload-pjax', 'schema-form', ['disabled' => true, 'data-close-modal' => 'true']); ?>
  <?= Html::hiddenInput('reload-pjax', 'schema-list', ['disabled' => true]); ?>
  <?= Html::hiddenInput('reload-pjax', 'schema-title', ['disabled' => true]); ?>
  <?= Html::hiddenInput('reload-pjax', 'schema-info', ['disabled' => true]); ?>
  <?= Html::hiddenInput('reload-pjax', 'breadcrumbs', ['disabled' => true]); ?>

  <?php Modal::end(); ActiveForm::end(); ?>

<?php
// http://designmodo.github.io/Flat-UI/docs/components.html#fui-checkbox
$this->registerJs(<<<JS
jQuery(':checkbox').radiocheck();
JS
);
?>


text:
import sys
import unittest
import json

from libcloud.utils.py3 import httplib

from libcloud.dns.base import Record, Zone
from libcloud.dns.drivers.rcodezero import RcodeZeroDNSDriver
from libcloud.dns.types import ZoneDoesNotExistError, ZoneAlreadyExistsError
from libcloud.dns.types import RecordType

from libcloud.test import LibcloudTestCase, MockHttp
from libcloud.test.file_fixtures import DNSFileFixtures

class RcodeZeroDNSTestCase(LibcloudTestCase):

    def setUp(self):
        RcodeZeroDNSDriver.connectionCls.conn_class = RcodeZeroDNSMockHttp
        RcodeZeroDNSMockHttp.type = None
        self.driver = RcodeZeroDNSDriver('mysecret')

        self.test_zone = Zone(id='example.at', domain='example.at',
                              driver=self.driver, type='master', ttl=None,
                              extra={})
        self.test_record = Record(id=None, name='', data='192.0.2.1',
                                  type=RecordType.A, zone=self.test_zone,
                                  driver=self.driver, extra={})

    def test_create_record(self):
        record = self.test_zone.create_record(name='newrecord',
                                              type=RecordType.A,
                                              data='192.0.5.4',
                                              extra={'ttl': 86400})
        self.assertEqual(record.id, None)
        self.assertEqual(record.name, 'newrecord')
        self.assertEqual(record.data, '192.0.5.4')
        self.assertEqual(record.type, RecordType.A)
        self.assertEqual(record.ttl, 86400)

    def test_create_zone(self):
        extra = {"masters": ["193.0.2.2"]}
        zone = self.driver.create_zone(
            "example.at", type='slave', extra=extra)
        self.assertEqual(zone.id, 'example.at.')
        self.assertEqual(zone.domain, 'example.at')
        self.assertEqual(zone.type, 'slave')
        self.assertEqual(zone.ttl, None)

    def test_delete_record(self):
        self.assertTrue(self.test_record.delete())

    def test_delete_zone(self):
        self.assertTrue(self.test_zone.delete())

    def test_get_record(self):
        record = self.driver.get_record('example.at.', '12345')
        self.assertEqual(record, None)

    def test_get_zone(self):
        zone = self.driver.get_zone('example.at')
        self.assertEqual(zone.id, 'example.at')
        self.assertEqual(zone.domain, 'example.at')
        self.assertEqual(zone.type, 'master')
        self.assertEqual(zone.ttl, None)

    def test_list_record_types(self):
        result = self.driver.list_record_types()
        self.assertEqual(len(result), 25)

    def test_list_records(self):
        records = self.driver.list_records(self.test_zone)
        self.assertEqual(len(records), 3)

    def test_list_zones(self):
        zones = self.driver.list_zones()
        self.assertEqual(zones[0].id, 'example1.at')
        self.assertEqual(zones[0].domain, 'example1.at')
        self.assertEqual(zones[0].type, 'slave')
        self.assertEqual(zones[0].ttl, None)
        self.assertEqual(zones[0].extra['masters'][0], '193.0.2.2')
        self.assertEqual(zones[0].extra['serial'], 20180411)
        self.assertEqual(zones[1].id, 'example2.at')
        self.assertEqual(zones[1].domain, 'example2.at')
        self.assertEqual(zones[1].type, 'master')
        self.assertEqual(zones[1].ttl, None)

    def test_update_record(self):
        record = self.driver.update_record(self.test_record,
                                           name='newrecord',
                                           type=RecordType.A,
                                           data='127.0.0.1',
                                           extra={'ttl': 300})
        self.assertEqual(record.id, '430059068a39501b8df5a577b1e46ad7')
        self.assertEqual(record.name, 'newrecord')
        self.assertEqual(record.data, '127.0.0.1')
        self.assertEqual(record.type, RecordType.A)
        self.assertEqual(record.ttl, 300)

    def test_update_zone(self):
        with self.assertRaises(NotImplementedError):
            self.driver.update_zone(self.test_zone, 'example.at')

#    # Test some error conditions

    def test_create_existing_zone(self):
        RcodeZeroDNSMockHttp.type = 'EXISTS'
        extra = {'masters': ['193.0.2.2']}
        with self.assertRaises(ZoneAlreadyExistsError):
            self.driver.create_zone(
                "example1.at", type='slave', extra=extra)

    def test_get_missing_zone(self):
        RcodeZeroDNSMockHttp.type = 'MISSING'
        with self.assertRaises(ZoneDoesNotExistError):
            self.driver.get_zone('example.com')

    def test_delete_missing_zone(self):
        RcodeZeroDNSMockHttp.type = 'MISSING'
        self.assertFalse(self.test_zone.delete())

class RcodeZeroDNSMockHttp(MockHttp):
    fixtures = DNSFileFixtures('rcodezero')
    base_headers = {'content-type': 'application/json'}

    def _api_v1_zones(self, method, url, body, headers):
        if method == 'GET':
            # list_zones()
            body = self.fixtures.load('list_zones.json')
        elif method == 'POST':
            # create_zone()
            # Don't bother with a fixture for this operation, because we do
            # nothing with the parsed body anyway.
            body = ''
        else:
            raise NotImplementedError('Unexpected method: %s' % method)
        return (httplib.OK, body, self.base_headers,
                httplib.responses[httplib.OK])

    def _api_v1_zones_example_at(self, method, *args, **kwargs):
        if method == 'GET':
            # list_records()
            body = self.fixtures.load('get_zone_details.json')
        elif method == 'DELETE':
            # delete_zone()
            return (httplib.NO_CONTENT, '', self.base_headers,
                    httplib.responses[httplib.NO_CONTENT])
        else:
            raise NotImplementedError('Unexpected method: %s' % method)
        return (httplib.OK, body, self.base_headers,
                httplib.responses[httplib.OK])

    def _api_v1_zones_example_at__rrsets(self, method, *args, **kwargs):
        return (self._api_v1_zones_example_at_rrsets(method, *args, **kwargs))

    def _api_v1_zones_example_at_rrsets(self, method, *args, **kwargs):
        if method == 'GET':
            # list_records()
            body = self.fixtures.load('list_records.json')
        elif method == 'PATCH':
            # create/update/delete_record()
            # Don't bother with a fixture for these operations, because we do
            # nothing with the parsed body anyway.
            body = ''
        else:
            raise NotImplementedError('Unexpected method: %s' % method)
        return (httplib.OK, body, self.base_headers,
                httplib.responses[httplib.OK])

    def _api_v1_zones_EXISTS(self, method, url, body, headers):
        # create_zone() is a POST. Raise on all other operations to be safe.
        if method != 'POST':
            raise NotImplementedError('Unexpected method: %s' % method)
        payload = json.loads(body)
        domain = payload['domain']
        body = json.dumps({'error': "Domain '%s' already exists" % domain})
        return (httplib.UNPROCESSABLE_ENTITY, body, self.base_headers,
                'Unprocessable Entity')

    def _api_v1_zones_example_com_MISSING(self, *args, **kwargs):
        return (httplib.NOT_FOUND,
                '{"status": "failed","message": "Zone not found"}',
                self.base_headers, 'Unprocessable Entity')

    def _api_v1_zones_example_at_MISSING(self, *args, **kwargs):
        return (httplib.NOT_FOUND,
                '{"status": "failed","message": "Zone not found"}',
                self.base_headers, 'Unprocessable Entity')

if __name__ == '__main__':
    sys.exit(unittest.main())


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>amu.saeed</groupId>
    <artifactId>kcminer</artifactId>
    <version>1.0</version>

    <dependencies>
        <dependency>
            <groupId>com.carrotsearch</groupId>
            <artifactId>hppc</artifactId>
            <version>0.7.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>args4j</groupId>
            <artifactId>args4j</artifactId>
            <version>2.32</version>
        </dependency>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-hadoop1</artifactId>
            <version>1.4.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>


text:
<?php

namespace Oro\Bundle\EntityBundle\Tests\Unit\Twig\Sandbox;

use Doctrine\Common\Cache\Cache;
use Oro\Bundle\EntityBundle\Twig\Sandbox\TemplateRendererConfigProvider;
use Oro\Bundle\EntityBundle\Twig\Sandbox\VariablesProvider;

class TemplateRendererConfigProviderTest extends \PHPUnit\Framework\TestCase
{
    private const CONFIG_CACHE_KEY = 'test_config_cache_key';

    /** @var VariablesProvider|\PHPUnit\Framework\MockObject\MockObject */
    private $variablesProvider;

    /** @var Cache|\PHPUnit\Framework\MockObject\MockObject */
    private $cache;

    /** @var TemplateRendererConfigProvider */
    private $configProvider;

    protected function setUp()
    {
        $this->variablesProvider = $this->createMock(VariablesProvider::class);
        $this->cache = $this->createMock(Cache::class);

        $this->configProvider = new TemplateRendererConfigProvider(
            $this->variablesProvider,
            $this->cache,
            self::CONFIG_CACHE_KEY
        );
    }

    public function testGetConfigurationWhenCachedConfigExists()
    {
        $cachedConfig = [
            'properties'         => ['Test\Entity' => ['field2']],
            'methods'            => ['Test\Entity' => ['getField1']],
            'accessors'          => ['Test\Entity' => ['field1' => 'getField1', 'field2' => null]],
            'default_formatters' => ['Test\Entity' => ['field1' => 'formatter1']]
        ];

        $this->cache->expects(self::once())
            ->method('fetch')
            ->with(self::CONFIG_CACHE_KEY)
            ->willReturn($cachedConfig);
        $this->cache->expects(self::never())
            ->method('save');

        self::assertSame($cachedConfig, $this->configProvider->getConfiguration());
        // test local cache
        self::assertSame($cachedConfig, $this->configProvider->getConfiguration());
    }

    public function testGetConfigurationWhenCachedConfigDoesNotExist()
    {
        $entityVariableGetters = [
            'Test\Entity' => [
                'field1' => 'getField1',
                'field2' => null,
                'field3' => [
                    'property_path'     => 'getField3',
                    'default_formatter' => 'formatter3'
                ],
                'field4' => ['property_path' => null]
            ]
        ];
        $config = [
            'default_formatters' => ['Test\Entity' => ['field3' => 'formatter3']],
            'properties'         => ['Test\Entity' => ['field2', 'field4']],
            'methods'            => ['Test\Entity' => ['getField1', 'getField3']],
            'accessors'          => [
                'Test\Entity' => [
                    'field1' => 'getField1',
                    'field2' => null,
                    'field3' => 'getField3',
                    'field4' => null
                ]
            ]
        ];

        $this->variablesProvider->expects(self::once())
            ->method('getEntityVariableGetters')
            ->willReturn($entityVariableGetters);

        $this->cache->expects(self::once())
            ->method('fetch')
            ->with(self::CONFIG_CACHE_KEY)
            ->willReturn(false);
        $this->cache->expects(self::once())
            ->method('save')
            ->with(self::CONFIG_CACHE_KEY, $config);

        self::assertSame($config, $this->configProvider->getConfiguration());
        // test local cache
        self::assertSame($config, $this->configProvider->getConfiguration());
    }

    public function testGetSystemVariableValues()
    {
        $systemVariableValues = ['variable1' => 'value1'];

        $this->variablesProvider->expects(self::once())
            ->method('getSystemVariableValues')
            ->willReturn($systemVariableValues);

        self::assertSame($systemVariableValues, $this->configProvider->getSystemVariableValues());
        // test local cache
        self::assertSame($systemVariableValues, $this->configProvider->getSystemVariableValues());
    }

    public function testGetEntityVariableProcessors()
    {
        $entityClass1 = 'Test\Entity1';
        $entityClass2 = 'Test\Entity2';
        $entityClass3 = 'Test\Entity3';
        $definitions = [
            $entityClass1 => ['prop1' => ['processor' => 'processor1']],
            $entityClass2 => ['prop2' => ['processor' => 'processor2', 'param2' => 'val2']],
            $entityClass3 => []
        ];

        $this->variablesProvider->expects(self::exactly(3))
            ->method('getEntityVariableProcessors')
            ->willReturnMap([
                [$entityClass1, $definitions[$entityClass1]],
                [$entityClass2, $definitions[$entityClass2]],
                [$entityClass3, $definitions[$entityClass3]]
            ]);

        foreach ($definitions as $entityClass => $definition) {
            self::assertSame(
                $definition,
                $this->configProvider->getEntityVariableProcessors($entityClass),
                $entityClass
            );
        }
        // test local cache
        foreach ($definitions as $entityClass => $definition) {
            self::assertSame(
                $definition,
                $this->configProvider->getEntityVariableProcessors($entityClass),
                $entityClass
            );
        }
    }

    public function testClearCache()
    {
        $this->cache->expects(self::once())
            ->method('delete')
            ->with(self::CONFIG_CACHE_KEY);

        $this->cache->expects(self::exactly(2))
            ->method('fetch')
            ->with(self::CONFIG_CACHE_KEY)
            ->willReturn(false);
        $this->cache->expects(self::exactly(2))
            ->method('save')
            ->with(self::CONFIG_CACHE_KEY);
        $this->variablesProvider->expects(self::exactly(2))
            ->method('getSystemVariableValues')
            ->willReturn([]);
        $this->variablesProvider->expects(self::exactly(2))
            ->method('getEntityVariableProcessors')
            ->with('Test\Entity')
            ->willReturn([]);

        // warmup local cache
        $this->configProvider->getConfiguration();
        $this->configProvider->getSystemVariableValues();
        $this->configProvider->getEntityVariableProcessors('Test\Entity');

        $this->configProvider->clearCache();

        // test that local cache was cleared
        $this->configProvider->getConfiguration();
        $this->configProvider->getSystemVariableValues();
        $this->configProvider->getEntityVariableProcessors('Test\Entity');
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="button_disabled">#ef9a9a</color>
    <color name="colorPrimary">#F44336</color>
    <color name="colorPrimaryDark">#B71C1C</color>
    <color name="colorAccent">#F44336</color>
    <color name="dark_blue">#0D47A1</color>
    <color name="light_blue">#64B5F6</color>
    <color name="yellow">#FFFF00</color>
    <color name="default_grey">#616161</color>
    <color name="grey">#9E9E9E</color>
    <color name="light_grey">#F5F5F5</color>
    <color name="black">#000000</color>
    <color name="white">#FFFFFF</color>
</resources>