Skip to content

Commit

Permalink
Initial import of code from jakefeasel/sqlfiddle branch work
Browse files Browse the repository at this point in the history
  • Loading branch information
jakefeasel committed Apr 21, 2014
0 parents commit 777fb83
Show file tree
Hide file tree
Showing 256 changed files with 42,491 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
.project
.vagrant
target
src/main/resources/custom/dev/node_modules
21 changes: 21 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013 Jake Feasel

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.
23 changes: 23 additions & 0 deletions README.md
@@ -0,0 +1,23 @@
SQL Fiddle
==========

##About

See [the SQL Fiddle about page](http://sqlfiddle.com/about.html) page for background on the site.

## Getting the project up and running

Fork the code on github to a local branch for youself.

You are going to need [Vagrant](http://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/) installed locally to get SQL Fiddle running. Once you have both of these installed, and this project cloned locally, run this command from the root of your working copy:

vagrant up

This will take a while to download the base image and all of the many dependencies. Once it has finished, you will have the software running in a set of VMs. You can now access your local server at [localhost:8080/sqlfiddle](http://localhost:8080/sqlfiddle).

You should now have a functional copy of SQL Fiddle running locally.

I'm happy to entertain pull requests!

Thanks,
Jake Feasel
23 changes: 23 additions & 0 deletions Vagrantfile
@@ -0,0 +1,23 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.define "postgresql93" do |postgresql93|
postgresql93.vm.provision :shell, :path => "pg93_bootstrap.sh"
postgresql93.vm.network "private_network", ip: "192.168.50.4"
postgresql93.vm.box = "hashicorp/precise32"
end

config.vm.define "idm", primary: true do |idm|
idm.vm.provision :shell, :path => "idm_bootstrap.sh"
idm.vm.network "private_network", ip: "192.168.50.3"
idm.vm.network "forwarded_port", guest: 8080, host: 8080
idm.vm.network "forwarded_port", guest: 8443, host: 8443
idm.vm.box = "hashicorp/precise32"
end

end
17 changes: 17 additions & 0 deletions idm_bootstrap.sh
@@ -0,0 +1,17 @@
#!/bin/bash

sudo su -c 'echo "192.168.50.4 OPENIDM_REPO_HOST" >> /etc/hosts'
sudo su -c 'echo "192.168.50.4 SQLFIDDLE_HOST" >> /etc/hosts'
sudo su -c 'echo "192.168.50.4 POSTGRESQL93_HOST" >> /etc/hosts'

sudo apt-get update
sudo apt-get --yes --force-yes install python-software-properties
sudo add-apt-repository --yes ppa:webupd8team/java
sudo apt-get update
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo apt-get --yes --force-yes install oracle-java7-installer maven postgresql-client
cd /vagrant
mvn clean install
cd target/sqlfiddle
nohup ./startup.sh &
33 changes: 33 additions & 0 deletions pg93_bootstrap.sh
@@ -0,0 +1,33 @@
#!/bin/bash

export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

sudo su -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get --yes update
sudo apt-get --yes upgrade
sudo apt-get --yes --force-yes install postgresql-9.3 postgresql-contrib-9.3

sudo pg_dropcluster --stop 9.3 main
sudo su -c "echo \"listen_addresses = '*'\" >> /etc/postgresql-common/createcluster.conf"
sudo pg_createcluster --start -e UTF-8 --locale en_US.UTF-8 9.3 main -- --auth-local=trust
sudo su -c "echo \"host all all 192.168.50.0/24 md5\" >> /etc/postgresql/9.3/main/pg_hba.conf"
sudo service postgresql reload

echo "alter user postgres with password 'password';" | psql -U postgres
sudo iptables -A INPUT -p tcp --dport 5432 -j ACCEPT

# initialize the template database, used by fiddle databases running in this env
psql -U postgres postgres < /vagrant/src/main/resources/db/postgresql/initial_setup.sql
psql -U postgres db_template < /vagrant/src/main/resources/db/postgresql/db_template.sql

# initialize the sqlfiddle central database, which has all sqlfiddle-specific data structures
createdb -U postgres -E UTF8 sqlfiddle
psql -U postgres sqlfiddle < /vagrant/src/main/resources/db/sqlfiddle/schema.sql
psql -U postgres sqlfiddle < /vagrant/src/main/resources/db/sqlfiddle/data.sql

# initialize the openidm repository
psql -U postgres < /vagrant/src/main/resources/db/openidm/createuser.pgsql
psql -U openidm < /vagrant/src/main/resources/db/openidm/openidm.pgsql
112 changes: 112 additions & 0 deletions pom.xml
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
~
~ Copyright (c) 2013 ForgeRock AS All rights reserved.
-->
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>www-sqlfiddle-com</artifactId>
<groupId>sqlfiddle</groupId>
<version>2.0</version>
<packaging>pom</packaging>
<name>SQL Fiddle file assembly</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<openidm.version>3.0.0-SNAPSHOT</openidm.version>
</properties>

<repositories>
<repository>
<id>forgerock-staging-repository</id>
<name>ForgeRock Release Repository</name>
<url>http://maven.forgerock.org/repo/releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>forgerock-snapshots-repository</id>
<name>ForgeRock Snapshot Repository</name>
<url>http://maven.forgerock.org/repo/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.forgerock.openicf.connectors</groupId>
<artifactId>scriptedsql-connector</artifactId>
<version>1.1.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.28</version>
</dependency>
</dependencies>
<build>
<finalName>sqlfiddle</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>unpack-openidm-staging</id>
<goals>
<goal>unpack</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.forgerock.openidm</groupId>
<artifactId>openidm-zip</artifactId>
<version>${openidm.version}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/idm-staging/</outputDirectory>
</artifactItem>
</artifactItems>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<includeBaseDirectory>false</includeBaseDirectory>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>zip-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
76 changes: 76 additions & 0 deletions src/main/assembly/zip.xml
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>dir</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>/</outputDirectory>
<fileMode>0640</fileMode>
<excludes>
<exclude>dev/*</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/idm-staging/openidm</directory>
<outputDirectory>/</outputDirectory>
<fileMode>750</fileMode>
<includes>
<include>startup.sh</include>
<include>startup.bat</include>
<include>shutdown.sh</include>
<include>startup.sh</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/idm-staging/openidm/security</directory>
<outputDirectory>//security</outputDirectory>
<directoryMode>0700</directoryMode>
<fileMode>0600</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/idm-staging/openidm</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>conf/**</include>
<include>bin/**</include>
<include>bundle/**</include>
<include>legal-notices/*</include>
<include>logs/*</include>
<include>security/*</include>
</includes>
<excludes>
<exclude>conf/endpoint-*.json</exclude>
<exclude>conf/ui*.json</exclude>
<exclude>conf/workflow.json</exclude>
<exclude>conf/process-access.json</exclude>
<exclude>conf/repo.orientdb.json</exclude>
</excludes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>/bundle</outputDirectory>
<useTransitiveDependencies>false</useTransitiveDependencies>
<!--<useTransitiveFiltering>true</useTransitiveFiltering>-->
<excludes>
<exclude>org.forgerock.openidm:openidm-zip</exclude>
<exclude>org.forgerock.openicf.connectors*</exclude>
</excludes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputDirectory>/connectors</outputDirectory>
<useTransitiveDependencies>false</useTransitiveDependencies>
<!--<useTransitiveFiltering>true</useTransitiveFiltering>-->
<includes>
<include>org.forgerock.openicf.connectors*</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
Binary file added src/main/resources/.DS_Store
Binary file not shown.
38 changes: 38 additions & 0 deletions src/main/resources/conf/authentication.json
@@ -0,0 +1,38 @@
{
"queryId" : "credential-query",
"queryOnResource" : "managed/user",
"propertyMapping" : {
"authenticationId" : "_id",
"userCredential" : "password",
"userRoles" : "roles"
},
"defaultUserRoles" : [ ],
"serverAuthContext" : {
"sessionModule" : {
"name" : "JWT_SESSION",
"properties" : {
"keyAlias" : "openidm-localhost",
"privateKeyPassword" : "&{openidm.keystore.password}",
"keystoreType" : "&{openidm.keystore.type}",
"keystoreFile" : "&{openidm.keystore.location}",
"keystorePassword" : "&{openidm.keystore.password}",
"maxTokenLifeMinutes" : "120",
"tokenIdleTimeMinutes" : "30",
"sessionOnly" : true
}
},
"authModules" : [
{
"name" : "INTERNAL_USER",
"properties" : {
"propertyMapping" : {
"authenticationId" : "_id",
"userCredential" : "password",
"userRoles" : "roles"
},
"defaultUserRoles" : [ ]
}
}
]
}
}
8 changes: 8 additions & 0 deletions src/main/resources/conf/cluster.json
@@ -0,0 +1,8 @@
{
"enabled": false,
"instanceId" : "&{openidm.node.id}",
"instanceTimeout" : "30000",
"instanceRecoveryTimeout" : "30000",
"instanceCheckInInterval" : "5000",
"instanceCheckInOffset" : "0"
}
5 changes: 5 additions & 0 deletions src/main/resources/conf/endpoint-executeQuery.json
@@ -0,0 +1,5 @@
{
"context" : "endpoint/executeQuery",
"type" : "groovy",
"file" : "script/executeQuery.groovy"
}
3 changes: 3 additions & 0 deletions src/main/resources/conf/managed.json
@@ -0,0 +1,3 @@
{
"objects" : [ ]
}
5 changes: 5 additions & 0 deletions src/main/resources/conf/policy.json
@@ -0,0 +1,5 @@
{
"type" : "text/javascript",
"file" : "policy.js",
"resources" : [ ]
}

0 comments on commit 777fb83

Please sign in to comment.