Commit fcc0b08c550e5292d2cafbf4a0404c9e890e037a

Authored by Paul Brodner
1 parent 308a4ed5b8
Exists in master

added dockerfiles

File was created 1 FROM java:8
2
3 # Install maven
4 RUN apt-get update
5 RUN apt-get install -y maven
6
7 WORKDIR /code
8
9 ADD . /code
10 EXPOSE 8080
11
12 CMD ["mvn", "exec:java"]
13
14
docker-compose.yml
File was created 1 mongodata:
2 image: mongo:3.0.4
3 volumes:
4 - /data/db
5 command: --break-mongo
6 mongo:
7 image: mongo:3.0.4
8 volumes_from:
9 - mongodata
10 ports:
11 - "27017:27017"
12 command: --smallfiles
13 web:
14 build: .
15 ports:
16 - "8080:8080"
17 links:
18 - mongo
19
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 <modelVersion>4.0.0</modelVersion> 3 <modelVersion>4.0.0</modelVersion>
4 4
5 <groupId>org.alfresco</groupId> 5 <groupId>org.alfresco</groupId>
6 <artifactId>tas-environments</artifactId> 6 <artifactId>tas-environments</artifactId>
7 <version>0.0.1-SNAPSHOT</version> 7 <version>0.0.1-SNAPSHOT</version>
8 <packaging>jar</packaging> 8 <packaging>jar</packaging>
9 9
10 <name>tas-environments</name> 10 <name>tas-environments</name>
11 <url>http://maven.apache.org</url> 11 <url>http://maven.apache.org</url>
12 12
13 <properties> 13 <properties>
14 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 14 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15 <jdk.version>1.8</jdk.version> 15 <jdk.version>1.8</jdk.version>
16 <tas.utility.version>1.0.5-SNAPSHOT</tas.utility.version> 16 <tas.utility.version>1.0.9-SNAPSHOT</tas.utility.version>
17 17
18 <spark.version>2.3</spark.version> 18 <spark.version>2.3</spark.version>
19 <spark.freemarker-template.version>2.3</spark.freemarker-template.version> 19 <spark.freemarker-template.version>2.3</spark.freemarker-template.version>
20 <spring.version>4.2.0.RELEASE</spring.version> 20 <spring.version>4.2.0.RELEASE</spring.version>
21 <spring.mongo.version>1.9.1.RELEASE</spring.mongo.version> 21 <spring.mongo.version>1.9.1.RELEASE</spring.mongo.version>
22 </properties> 22 </properties>
23 23
24 <dependencies> 24 <dependencies>
25 25
26 <!-- alfresco tester settings --> 26 <!-- alfresco tester settings -->
27 <dependency> 27 <dependency>
28 <groupId>org.alfresco.tas</groupId> 28 <groupId>org.alfresco.tas</groupId>
29 <artifactId>utility</artifactId> 29 <artifactId>utility</artifactId>
30 <version>${tas.utility.version}</version> 30 <version>${tas.utility.version}</version>
31 <exclusions> 31 <exclusions>
32 <exclusion> 32 <exclusion>
33 <artifactId>slf4j-api</artifactId> 33 <artifactId>slf4j-api</artifactId>
34 <groupId>org.slf4j</groupId> 34 <groupId>org.slf4j</groupId>
35 </exclusion> 35 </exclusion>
36 <exclusion> 36 <exclusion>
37 <groupId>org.slf4j</groupId> 37 <groupId>org.slf4j</groupId>
38 <artifactId>slf4j-log4j12</artifactId> 38 <artifactId>slf4j-log4j12</artifactId>
39 </exclusion> 39 </exclusion>
40 <exclusion> 40 <exclusion>
41 <groupId>log4j</groupId> 41 <groupId>log4j</groupId>
42 <artifactId>log4j</artifactId> 42 <artifactId>log4j</artifactId>
43 </exclusion> 43 </exclusion>
44 </exclusions> 44 </exclusions>
45 </dependency> 45 </dependency>
46 46
47 <!-- DB Context MONGO --> 47 <!-- DB Context MONGO -->
48 <dependency> 48 <dependency>
49 <groupId>org.springframework.data</groupId> 49 <groupId>org.springframework.data</groupId>
50 <artifactId>spring-data-mongodb</artifactId> 50 <artifactId>spring-data-mongodb</artifactId>
51 <version>1.9.5.RELEASE</version> 51 <version>1.9.5.RELEASE</version>
52 </dependency> 52 </dependency>
53 53
54 <!-- SPARK --> 54 <!-- SPARK -->
55 <dependency> 55 <dependency>
56 <groupId>com.sparkjava</groupId> 56 <groupId>com.sparkjava</groupId>
57 <artifactId>spark-core</artifactId> 57 <artifactId>spark-core</artifactId>
58 <version>${spark.version}</version> 58 <version>${spark.version}</version>
59 </dependency> 59 </dependency>
60 60
61 <dependency> 61 <dependency>
62 <groupId>com.sparkjava</groupId> 62 <groupId>com.sparkjava</groupId>
63 <artifactId>spark-template-freemarker</artifactId> 63 <artifactId>spark-template-freemarker</artifactId>
64 <version>${spark.freemarker-template.version}</version> 64 <version>${spark.freemarker-template.version}</version>
65 </dependency> 65 </dependency>
66 66
67 <!-- Spring Core --> 67 <!-- Spring Core -->
68 <dependency> 68 <dependency>
69 <groupId>org.springframework</groupId> 69 <groupId>org.springframework</groupId>
70 <artifactId>spring-core</artifactId> 70 <artifactId>spring-core</artifactId>
71 <version>${spring.version}</version> 71 <version>${spring.version}</version>
72 </dependency> 72 </dependency>
73 73
74 <!-- Spring Context --> 74 <!-- Spring Context -->
75 <dependency> 75 <dependency>
76 <groupId>org.springframework</groupId> 76 <groupId>org.springframework</groupId>
77 <artifactId>spring-context</artifactId> 77 <artifactId>spring-context</artifactId>
78 <version>${spring.version}</version> 78 <version>${spring.version}</version>
79 </dependency> 79 </dependency>
80 80
81 <!-- Spring BEANS fixing: NoClassDefFoundError: org/springframework/beans/factory/SmartInitializingSingleton --> 81 <!-- Spring BEANS fixing: NoClassDefFoundError: org/springframework/beans/factory/SmartInitializingSingleton -->
82 <dependency> 82 <dependency>
83 <groupId>org.springframework</groupId> 83 <groupId>org.springframework</groupId>
84 <artifactId>spring-beans</artifactId> 84 <artifactId>spring-beans</artifactId>
85 <version>${spring.version}</version> 85 <version>${spring.version}</version>
86 </dependency> 86 </dependency>
87 </dependencies> 87 </dependencies>
88 88
89 <build> 89 <build>
90 <plugins> 90 <plugins>
91 <plugin> 91 <plugin>
92 <groupId>org.apache.maven.plugins</groupId> 92 <groupId>org.apache.maven.plugins</groupId>
93 <artifactId>maven-compiler-plugin</artifactId> 93 <artifactId>maven-compiler-plugin</artifactId>
94 <version>3.5.1</version> 94 <version>3.5.1</version>
95 <configuration> 95 <configuration>
96 <source>1.8</source> 96 <source>1.8</source>
97 <target>1.8</target> 97 <target>1.8</target>
98 </configuration> 98 </configuration>
99 </plugin> 99 </plugin>
100 100
101 <plugin> 101 <plugin>
102 <groupId>org.codehaus.mojo</groupId> 102 <groupId>org.codehaus.mojo</groupId>
103 <artifactId>exec-maven-plugin</artifactId> 103 <artifactId>exec-maven-plugin</artifactId>
104 <version>1.2.1</version> 104 <version>1.2.1</version>
105 <executions> 105 <executions>
106 <execution> 106 <execution>
107 <goals> 107 <goals>
108 <goal>java</goal> 108 <goal>java</goal>
109 </goals> 109 </goals>
110 </execution> 110 </execution>
111 </executions> 111 </executions>
112 <configuration> 112 <configuration>
113 <mainClass>org.alfresco.tasenvironment.App</mainClass> 113 <mainClass>org.alfresco.tasenvironment.App</mainClass>
114 <arguments> 114 <arguments>
115 </arguments> 115 </arguments>
116 </configuration> 116 </configuration>
117 </plugin> 117 </plugin>
118 </plugins> 118 </plugins>
119 119
120 </build> 120 </build>
121 </project> 121 </project>
122 122
src/main/java/org/alfresco/tasenvironment/models/Environment.java
1 package org.alfresco.tasenvironment.models; 1 package org.alfresco.tasenvironment.models;
2 2
3 import org.alfresco.utility.network.ServerHealth; 3 import org.alfresco.utility.network.ServerHealth;
4 import org.alfresco.utility.network.TenantConsole;
4 import org.springframework.data.annotation.Id; 5 import org.springframework.data.annotation.Id;
5 import org.springframework.data.annotation.PersistenceConstructor; 6 import org.springframework.data.annotation.PersistenceConstructor;
6 import org.springframework.data.mongodb.core.mapping.Document; 7 import org.springframework.data.mongodb.core.mapping.Document;
7 8
8 /** 9 /**
9 * @author pbrodner 10 * @author pbrodner
10 */ 11 */
11 @Document(collection = "environments") 12 @Document(collection = "environments")
12 public class Environment 13 public class Environment
13 { 14 {
15 ServerHealth serverHealth = new ServerHealth();
16 private TenantConsole tenantConsole = new TenantConsole();
17
18
14 @Id 19 @Id
15 private String id; 20 private String id;
16 21
17 private String name; 22 private String name;
18 private String ip; 23 private String ip;
19 private String port; 24 private String port;
20 25
21 @PersistenceConstructor 26 @PersistenceConstructor
22 public Environment(String name, String ip, String port) 27 public Environment(String name, String ip, String port)
23 { 28 {
24 setName(name); 29 setName(name);
25 setIp(ip); 30 setIp(ip);
26 setPort(port); 31 setPort(port);
27 } 32 }
28 33
29 public String getName() 34 public String getName()
30 { 35 {
31 return name; 36 return name;
32 } 37 }
33 38
34 public void setName(String name) 39 public void setName(String name)
35 { 40 {
36 this.name = name; 41 this.name = name;
37 } 42 }
38 43
39 public String getIp() 44 public String getIp()
40 { 45 {
41 return ip; 46 return ip;
42 } 47 }
43 48
44 public void setIp(String ip) 49 public void setIp(String ip)
45 { 50 {
46 this.ip = ip; 51 this.ip = ip;
47 } 52 }
48 53
49 public String getPort() 54 public String getPort()
50 { 55 {
51 return port; 56 return port;
52 } 57 }
53 58
54 public void setPort(String port) 59 public void setPort(String port)
55 { 60 {
56 this.port = port; 61 this.port = port;
57 } 62 }
58 63
59 public void setId(String id) 64 public void setId(String id)
60 { 65 {
61 this.id = id; 66 this.id = id;
62 } 67 }
63 68
64 public String getId() 69 public String getId()
65 { 70 {
66 return id; 71 return id;
67 } 72 }
68 73
69 @Override 74 @Override
70 public String toString() 75 public String toString()
71 { 76 {
72 return String.format("Environment [id=%s, name=%s, ip=%s]", getId(), getName(), getId()); 77 return String.format("Environment [id=%s, name=%s, ip=%s]", getId(), getName(), getId());
73 } 78 }
74 79
75 public String getAlfrescoPath() 80 public String getAlfrescoPath()
76 { 81 {
77 return String.format("http://%s:%s/alfresco", getIp(), getPort()); 82 return String.format("http://%s:%s/alfresco", getIp(), getPort());
78 } 83 }
79 84
80 public String getSharePath() 85 public String getSharePath()
81 { 86 {
82 return String.format("http://%s:%s/share", getIp(), getPort()); 87 return String.format("http://%s:%s/share", getIp(), getPort());
83 } 88 }
84 89
85 public String getStatus() 90 public String getStatus()
86 { 91 {
87 boolean isOnline = false; 92 boolean isOnline = false;
88 try 93 try
89 { 94 {
90 ServerHealth serverHealth = new ServerHealth();
91 isOnline = serverHealth.isServerReachable(getIp(), Integer.valueOf(getPort())); 95 isOnline = serverHealth.isServerReachable(getIp(), Integer.valueOf(getPort()));
92 } 96 }
93 catch (Exception e) 97 catch (Exception e)
94 { 98 {
95 e.printStackTrace(); 99 e.printStackTrace();
96 } 100 }
97 101
98 if (isOnline) 102 if (isOnline)
99 return getOnlineIcon(); 103 return getOnlineIcon();
100 else 104 else
101 return getOfflineIcon(); 105 return getOfflineIcon();
102 } 106 }
103 107
104 public String getOnlineIcon() 108 public String getOnlineIcon()
105 { 109 {
106 return "<span class=\"label label-success\"> Online</span>"; 110 return "<span class=\"label label-success\"> Online</span>";
107 } 111 }
108 112
109 public String getOfflineIcon() 113 public String getOfflineIcon()
110 { 114 {
111 return "<span class=\"label label-danger\"> Offline</span>"; 115 return "<span class=\"label label-danger\"> Offline</span>";
112 } 116 }
117
118 public String getTenant()
119 {
120 try
121 {
122 if (tenantConsole.tenantExist("http", getIp(), Integer.valueOf(getPort()), "admin", "admin"))
123 return "<span class=\"label label-danger\"> Yes</span>";
124 else
125 return "<span class=\"label label-success\">No</span>";
126 }
127 catch (Exception e)
128 {
129 return "<span class=\"label label-success\">No</span>";
130 }
131
132 }
src/main/resources/spark/template/freemarker/environment/index.ftl
1 <a href="/environment/new" data-toggle="tooltip" title="Add a new Environment!">Add New</a> 1 <a href="/environment/new" data-toggle="tooltip" title="Add a new Environment!">Add New</a>
2 <table class="table table-striped table-bordered table-condensed"> 2 <table class="table table-striped table-bordered table-condensed">
3 <thead> 3 <thead>
4 <tr> 4 <tr>
5 <th>Name</th> 5 <th>Name</th>
6 <th>IP</th> 6 <th>IP</th>
7 <th>Alfresco Path</th> 7 <th>Alfresco Path</th>
8 <th>Status</th> 8 <th>Status</th>
9 <th>With Tenant</th>
9 <th></th> 10 <th></th>
10 </tr> 11 </tr>
11 </thead> 12 </thead>
12 <tbody> 13 <tbody>
13 <#list environments as env> 14 <#list environments as env>
14 <tr> 15 <tr>
15 <td>${env.getName()}</td> 16 <td>${env.getName()}</td>
16 <td>${env.getIp()}</td> 17 <td>${env.getIp()}</td>
17 <td><a href="${env.getAlfrescoPath()}" target="_blank">${env.getAlfrescoPath()}</a></td> 18 <td><a href="${env.getAlfrescoPath()}" target="_blank">${env.getAlfrescoPath()}</a></td>
18 <td align="center">${env.getStatus()}</td> 19 <td align="center">${env.getStatus()}</td>
19 <td> 20 <td align="center">${env.getTenant()}</td>
20 21 <td>
21 <form method="DELETE" action="/environment/delete/${env.getId()}"> 22 <form method="DELETE" action="/environment/delete/${env.getId()}">
22 <button type="submit" class="btn btn-small">Delete</button> 23 <button type="submit" class="btn btn-small">Delete</button>
23 </form> 24 </form>
24
25 </td> 25 </td>
26 </tr> 26 </tr>
27 </#list> 27 </#list>
28 </tbody> 28 </tbody>
29 </table> 29 </table>
src/main/resources/spark/template/freemarker/layout.ftl
1 <html> 1 <html>
2 <head> 2 <head>
3 <title>TAS Environments</title> 3 <title>TAS Environments</title>
4 <link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 4 <link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
5 <link href="/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css" > 5 <link href="/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css" >
6 <link href="/css/starter-template.css" rel="stylesheet" type="text/css" > 6 <link href="/css/starter-template.css" rel="stylesheet" type="text/css" >
7 </head> 7 </head>
8 <body> 8 <body>
9 9
10 <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 10 <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
11 <div class="container-fluid"> 11 <div class="container-fluid">
12 <!-- Brand and toggle get grouped for better mobile display --> 12 <!-- Brand and toggle get grouped for better mobile display -->
13 <div class="navbar-header"> 13 <div class="navbar-header">
14 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> 14 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
15 <span class="sr-only">Toggle navigation</span> 15 <span class="sr-only">Toggle navigation</span>
16 <span class="icon-bar"></span> 16 <span class="icon-bar"></span>
17 <span class="icon-bar"></span> 17 <span class="icon-bar"></span>
18 <span class="icon-bar"></span> 18 <span class="icon-bar"></span>
19 </button> 19 </button>
20 <a class="navbar-brand" href="/">TAS Environments</a> 20 <a class="navbar-brand" href="/">TAS Environments</a>
21 </div> 21 </div>
22 22
23 <!-- Collect the nav links, forms, and other content for toggling --> 23
24 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
25 <form class="navbar-form navbar-left" role="search">
26 <div class="form-group">
27 <input type="text" class="form-control" placeholder="Filter">
28 </div>
29 <button type="submit" class="btn btn-default">Go</button>
30 </form>
31 </div><!-- /.navbar-collapse -->
32 </div><!-- /.container-fluid --> 24 </div><!-- /.container-fluid -->
33 </nav> 25 </nav>
34 26
35 <#include "alert.ftl"> 27 <#include "alert.ftl">
36 <div class="container"> 28 <div class="container">
37 <h3>${pageTitle}</h3> 29 <h3>${pageTitle}</h3>
38 <#include "${templateName}"> 30 <#include "${templateName}">
39 </div> 31 </div>
40 <script src="/js/jquery.min.js"></script> 32 <script src="/js/jquery.min.js"></script>
41 <script src="/js/bootstrap.min.js"></script> 33 <script src="/js/bootstrap.min.js"></script>
42 </body> 34 </body>
43 </html> 35 </html>
44 36