Skip to content

Commit 28bed85

Browse files
authored
Separate classes (#166)
* add: separate each level of config as class * fix: add execution configuration files * fix: remame classes * fix: missing files * fix: print configuration * add: configuration documentation * Prettified Code! * fix: add documentation --------- Co-authored-by: mosoriob <mosoriob@users.noreply.github.com>
1 parent 794c264 commit 28bed85

File tree

10 files changed

+148
-192
lines changed

10 files changed

+148
-192
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,42 @@
44

55
## Installation
66

7-
### Docker
7+
### Docker
88

99
You must install [Docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/install/).
1010

1111
Clone the repository
1212

13-
```bash
13+
```console
1414
$ git clone https://github.com/KnowledgeCaptureAndDiscovery/wings.git
1515
```
1616

1717
Deploy the container with the following command:
1818

19-
```bash
19+
```console
2020
$ docker-compose up -d
2121
```
2222

23-
2423
Open the browser [http://localhost:8080/wings-portal](http://localhost:8080/wings-portal) to access the Wings portal.
2524

25+
To stop the container, run the following command:
26+
27+
```bash
28+
$ docker-compose down
29+
```
30+
31+
#### Users
32+
33+
The default user is `admin` and the password is `4dm1n!23`. You can change the password in the `./wings-docker/config/tomcat/tomcat-users.xml` and rebuild the container.
34+
35+
```
36+
$ docker-compose build
37+
$ docker-compose up -d
38+
```
2639

27-
Go to [README Docker](wings-docker/) for additional instructions on running the Docker image.
40+
#### Configuration
2841

42+
Please follow the instructions in [README Configuration](docs/configuration.md) to configure the Wings project.
2943

3044
#### Images
3145

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
- wings_data:/opt/wings
1212
- /var/run/docker.sock:/var/run/docker.sock
1313
- ./portal.properties:/etc/wings/portal.properties
14+
1415
ports:
1516
- 8080:8080
1617
volumes:

docs/configuration.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Wings configuration documentation
2+
3+
The wings configuration file is located at `/etc/wings/portal.properties`. It contains the following sections:
4+
5+
- **main**: modify main properties
6+
- **storage**: modify the paths where the data and database is stored
7+
- **ontology**: reference to the WINGS ontology
8+
- **execution**: available engines to run the workflow
9+
- **publisher**: describes how the wings system shares data, execution, and provenance.
10+
11+
Be sure to modify the configuration file carefully, as changes may affect the functionality of the Wings system.
12+
13+
To inspect the configuration file, open a browser and go to [http://localhost:8080/wings-portal/config](http://localhost:8080/wings-portal/config). The sensitive information is hidden.
14+
15+
### Main
16+
17+
The **main** section of the configuration file allows you to modify the main properties of the Wings system.
18+
19+
| Name | Description | Default |
20+
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
21+
| server | The URL of the Wings instance is used to generate the accessible URI for resources. For example, if the value is set to the default, the component library of the domain CaesarCypher and user admin will be available at http://localhost:8080/wings-portal/export/users/admin/CaesarCypher/components/library.owl. | Obtained by HTTP request. For example, http://localhost:8080 |
22+
| graphviz | Path where the graphviz software is installed | /usr/bin/dot |
23+
| light-reasoner | Enable or disable validation in the planning of workflow | false |
24+
25+
### Storage
26+
27+
The **storage** section of the configuration file allows you to specify the location of the data and database directories. Make sure to set the paths to directories with sufficient storage space and appropriate permissions for the following properties:
28+
29+
| name | description | default value |
30+
| ------------- | -------------------------------------------------- | -------------------- |
31+
| storage.local | Directory where the data and components are stored | $HOME/.wings/storage |
32+
| storage.local | RDF store database (Apache JENA) | $HOME/.wings/TDB |
33+
| storage.local | Directory where the log files are stored | $HOME/.wings/logs |
34+
35+
### Ontology
36+
37+
The following text describes the ontology section of the Wings configuration file. The properties within this section should not be modified unless you are an advanced user with knowledge of the WINGS ontology
38+
39+
The ontology section of the configuration file specifies the location and URIs of the WINGS ontology files. The following properties defin
40+
41+
| Name | Description | Default Value |
42+
| ------------------ | ----------------------------------------------------- | ----------------------------------------------------- |
43+
| ontology.component | Location and URI of the WINGS ontology component ont | http://www.wings-workflows.org/ontology/component.owl |
44+
| ontology.data | Location and URI of the WINGS ontology data file | http://www.wings-workflows.org/ontology/data.owl |
45+
| ontology.execution | Location and URI of the WINGS ontology execution file | http://www.wings-workflows.org/ontology/execution.owl |
46+
| ontology.workflow | Location and URI of the WINGS ontology workflow file | http://www.wings-workflows.org/ontology/workflow.owl |
47+
48+
Again, these properties should not be modified unless you are an advanced user with knowledge of the WINGS ontology.
49+
50+
### Execution and engine
51+
52+
The "Execution" section lists the available engines for running your workflows.
53+
54+
| Name | Description |
55+
| -------------- | ---------------------------------------------------------- |
56+
| name | A short name to describe the engine |
57+
| implementation | Java path where the implementation is |
58+
| type | Modify if the engine is used in the planning, step or both |
59+
60+
WINGS supports the following engines:
61+
62+
1. `local` runs the workflow as a UNIX process.
63+
2. `distributed` runs the workflows using round robin, connecting to the server using the SSH protocol.
64+
65+
By default, the local engine is activated.
66+
67+
```json
68+
execution =
69+
{
70+
engine =
71+
{
72+
name = Local;
73+
implementation = edu.isi.wings.execution.engine.api.impl.local.LocalExecutionEngine;
74+
type = BOTH;
75+
}
76+
77+
engine =
78+
{
79+
name = Distributed;
80+
implementation = edu.isi.wings.execution.engine.api.impl.distributed.DistributedExecutionEngine;
81+
type = BOTH;
82+
}
83+
}
84+
```

portal/src/main/java/edu/isi/wings/portal/classes/config/ExecutionConfig.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,22 @@ public class ExecutionConfig {
1616

1717
public ExecutionConfig(PropertyListConfiguration serverConfig) {
1818
this.engines = new HashMap<String, ExecutionEngineConfig>();
19-
List<HierarchicalConfiguration> engineNodes = serverConfig.configurationsAt(
20-
"execution.engine"
21-
);
22-
for (HierarchicalConfiguration engineNode : engineNodes) {
23-
ExecutionEngineConfig engine = this.getExeEngine(engineNode);
24-
this.engines.put(engine.getName(), engine);
25-
}
26-
}
27-
28-
public ExecutionConfig() {
29-
this.engines = new HashMap<String, ExecutionEngineConfig>();
30-
ExecutionEngineConfig defaultLocal = new ExecutionEngineConfig(
31-
"Local",
32-
LocalExecutionEngine.class.getCanonicalName(),
33-
ExecutionEngineConfig.Type.BOTH
34-
);
35-
ExecutionEngineConfig defaultDistrubited = new ExecutionEngineConfig(
36-
"Distributed",
37-
DistributedExecutionEngine.class.getCanonicalName(),
38-
ExecutionEngineConfig.Type.BOTH
39-
);
19+
if (serverConfig.containsKey("execution.engine")) {
20+
List<HierarchicalConfiguration> engineNodes =
21+
serverConfig.configurationsAt("execution.engine");
22+
for (HierarchicalConfiguration engineNode : engineNodes) {
23+
ExecutionEngineConfig engine = this.getExeEngine(engineNode);
24+
this.engines.put(engine.getName(), engine);
25+
}
26+
} else {
27+
ExecutionEngineConfig defaultLocal = new ExecutionEngineConfig(
28+
"Local",
29+
LocalExecutionEngine.class.getCanonicalName(),
30+
ExecutionEngineConfig.Type.BOTH
31+
);
4032

41-
this.engines.put(defaultLocal.getName(), defaultLocal);
42-
this.engines.put(defaultDistrubited.getName(), defaultDistrubited);
33+
this.engines.put(defaultLocal.getName(), defaultLocal);
34+
}
4335
}
4436

4537
@SuppressWarnings("rawtypes")

portal/src/main/java/edu/isi/wings/portal/classes/config/MainConfig.java

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,36 @@ public class MainConfig {
1515
public static final String USERS_RELATIVE_DIR = "users";
1616
public static final String EXPORT_SERVLET_PATH = "/export";
1717

18-
public String dotFile;
18+
public String dotFile = "/usr/bin/dot";
1919
public String serverUrl;
20-
public boolean hasMetaWorkflows;
21-
public String clients;
20+
public boolean hasMetaWorkflows = false;
21+
public String clients = null;
2222
public String contextRootPath;
2323
public String exportCommunityUrl;
2424
public String communityPath;
2525

26-
public MainConfig(MainConfig source) {
27-
this.dotFile = source.getDotFile();
28-
this.serverUrl = source.getServerUrl();
29-
this.hasMetaWorkflows = source.isHasMetaWorkflows();
30-
this.clients = source.getClients();
31-
this.contextRootPath = source.getContextRootPath();
32-
this.exportCommunityUrl = source.getExportCommunityUrl();
33-
this.communityPath = source.getCommunityPath();
34-
}
35-
3626
public MainConfig(
3727
PropertyListConfiguration serverConfig,
3828
HttpServletRequest request
3929
) {
40-
this.serverUrl = serverConfig.getString(MAIN_SERVER_KEY);
41-
this.dotFile = serverConfig.getString(MAIN_GRAPHVIZ_KEY);
42-
this.clients = serverConfig.getString(MAIN_CLIENTS_KEY);
4330
this.contextRootPath = request.getContextPath();
31+
if (serverConfig.containsKey(MAIN_GRAPHVIZ_KEY)) {
32+
this.dotFile = serverConfig.getString(MAIN_GRAPHVIZ_KEY);
33+
}
34+
if (serverConfig.containsKey(MAIN_SERVER_KEY)) {
35+
this.serverUrl = serverConfig.getString(MAIN_SERVER_KEY);
36+
} else {
37+
this.serverUrl =
38+
request.getScheme() +
39+
"://" +
40+
request.getServerName() +
41+
":" +
42+
request.getServerPort();
43+
}
44+
if (serverConfig.containsKey(MAIN_CLIENTS_KEY)) {
45+
this.clients = serverConfig.getString(MAIN_CLIENTS_KEY);
46+
}
47+
4448
if (
4549
serverConfig.containsKey(MAIN_METAWORKFLOWS_KEY)
4650
) this.hasMetaWorkflows = serverConfig.getBoolean(MAIN_METAWORKFLOWS_KEY);
@@ -58,26 +62,6 @@ public MainConfig(
5862
StorageConfig.COMMUNITY_RELATIVE_DIR;
5963
}
6064

61-
public MainConfig(String defaultServer, HttpServletRequest request) {
62-
this.serverUrl = defaultServer;
63-
File loc1 = new File("/usr/bin/dot");
64-
File loc2 = new File("/usr/local/bin/dot");
65-
dotFile = loc2.exists() ? loc2.getAbsolutePath() : loc1.getAbsolutePath();
66-
this.contextRootPath = request.getContextPath();
67-
this.exportCommunityUrl =
68-
this.serverUrl +
69-
contextRootPath +
70-
EXPORT_SERVLET_PATH +
71-
"/" +
72-
StorageConfig.COMMUNITY_RELATIVE_DIR;
73-
this.communityPath =
74-
contextRootPath +
75-
"/" +
76-
USERS_RELATIVE_DIR +
77-
"/" +
78-
StorageConfig.COMMUNITY_RELATIVE_DIR;
79-
}
80-
8165
public static String getMainLightReasonerKey() {
8266
return MAIN_LIGHT_REASONER_KEY;
8367
}

portal/src/main/java/edu/isi/wings/portal/classes/config/OntologyConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public OntologyConfig(PropertyListConfiguration serverConfig) {
3737
}
3838
}
3939

40-
public OntologyConfig() {}
41-
4240
public String getComponentOntologyUrl() {
4341
return componentOntologyUrl;
4442
}

portal/src/main/java/edu/isi/wings/portal/classes/config/PortalConfig.java

Lines changed: 7 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ public PropertyListConfiguration getPortalConfiguration(
3232
) {
3333
ServletContext app = request.getSession().getServletContext();
3434
this.portalConfigurationFile = obtainConfigPath(app, request);
35-
if (this.portalConfigurationFile == null) createDefaultConfigurationFile(
36-
request
37-
);
38-
checkIfFileExists(this.portalConfigurationFile);
35+
try {
36+
checkIfFileExists(portalConfigurationFile);
37+
} catch (Exception e) {
38+
throw new RuntimeException(
39+
"Could not find config file: " + portalConfigurationFile
40+
);
41+
}
3942
return loadConfigurationOnProps();
4043
}
4144

@@ -85,76 +88,6 @@ private void getPlannerConfiguration(PropertyListConfiguration serverConfig) {
8588
this.plannerConfig = new PlannerConfig(serverConfig);
8689
}
8790

88-
private void createDefaultConfigurationFile(HttpServletRequest request) {
89-
String configFileName = "portal.properties";
90-
String configDirectory = createDefaultConfigurationDirectory();
91-
this.portalConfigurationFile =
92-
configDirectory + File.separator + configFileName;
93-
File cfile = new File(this.portalConfigurationFile);
94-
File configDir = cfile.getParentFile();
95-
StorageConfig.createStorageDirectory(configDir.getAbsolutePath());
96-
if (request != null) createDefaultPortalConfig(request);
97-
}
98-
99-
private String createDefaultConfigurationDirectory() {
100-
String defaultDirectory = ".wings";
101-
String home = System.getProperty("user.home");
102-
if (home != null && !home.equals("")) {
103-
return home + File.separator + defaultDirectory;
104-
}
105-
return "/etc/wings/portal.properties";
106-
}
107-
108-
private void createDefaultPortalConfig(HttpServletRequest request) {
109-
String server =
110-
request.getScheme() +
111-
"://" +
112-
request.getServerName() +
113-
":" +
114-
request.getServerPort();
115-
116-
PropertyListConfiguration config = new PropertyListConfiguration();
117-
StorageConfig storageConfig = new StorageConfig(config);
118-
OntologyConfig ontologyDefaultConfig = new OntologyConfig();
119-
MainConfig mainDefaultConfig = new MainConfig(server, request);
120-
ExecutionConfig executionConfig = new ExecutionConfig();
121-
122-
config.addProperty(MainConfig.MAIN_SERVER_KEY, server);
123-
config.addProperty(MainConfig.MAIN_GRAPHVIZ_KEY, mainDefaultConfig.dotFile);
124-
config.addProperty(
125-
StorageConfig.STORAGE_LOCAL,
126-
storageConfig.storageDirectory
127-
);
128-
config.addProperty(StorageConfig.STORAGE_TDB, storageConfig.tdbDirectory);
129-
config.addProperty(
130-
OntologyConfig.ONTOLOGY_COMPONENT_KEY,
131-
ontologyDefaultConfig.componentOntologyUrl
132-
);
133-
config.addProperty(
134-
OntologyConfig.ONTOLOGY_DATA_KEY,
135-
ontologyDefaultConfig.dataOntologyUrl
136-
);
137-
config.addProperty(
138-
OntologyConfig.ONTOLOGY_EXECUTION_KEY,
139-
ontologyDefaultConfig.executionOntologyUrl
140-
);
141-
config.addProperty(
142-
OntologyConfig.ONTOLOGY_RESOURCE_KEY,
143-
ontologyDefaultConfig.resourceOntologyUrl
144-
);
145-
config.addProperty(
146-
OntologyConfig.ONTOLOGY_WORKFLOW_KEY,
147-
ontologyDefaultConfig.workflowOntologyUrl
148-
);
149-
executionConfig.addDefaultEngineConfig(config);
150-
151-
try {
152-
config.save(this.portalConfigurationFile);
153-
} catch (Exception e) {
154-
e.printStackTrace();
155-
}
156-
}
157-
15891
private void getEngineNodeConfiguration(
15992
PropertyListConfiguration serverConfig
16093
) {

portal/src/main/java/edu/isi/wings/portal/classes/config/StorageConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public StorageConfig(PropertyListConfiguration serverConfig) {
2727
}
2828
this.logsDirectory =
2929
this.storageDirectory + File.separator + LOGS_DIRECTORY;
30-
this.logsDirectory = this.storageDirectory + File.separator + TDB_DIRECTORY;
30+
this.tdbDirectory = this.storageDirectory + File.separator + TDB_DIRECTORY;
3131
this.communityDirectory =
3232
this.storageDirectory + File.separator + COMMUNITY_RELATIVE_DIR;
3333

0 commit comments

Comments
 (0)