Skip to content

Commit 12543a2

Browse files
committed
Merge remote-tracking branch 'upstream/master' into dev/ws-cleanup
2 parents d4ec7c5 + 8aaf4c8 commit 12543a2

File tree

371 files changed

+3692
-1836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

371 files changed

+3692
-1836
lines changed

docs/source/get_started/connect_openmrs.rst

+33-16
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,44 @@ Configuring the OpenMRS-19 module
5252

5353
The MOTECH OpenMRS-19 module exposes a configuration file called openmrs.properties. This file is registered with the configuration
5454
system. Based on what configuration mode the system is configured with, you can change the settings either by using the Admin UI(UI Mode) or
55-
the file in the config file location(File Mode). The default username and password match the defaults from OpenMRS(make sure
56-
that you change these in production environment).
55+
the file in the config file location(File Mode). You can modify this file through the UI by clicking Admin > Manage Modules > Click the gear icon on the right of the OpenMRS module.
56+
57+
.. image:: img/openmrs_modules_click_gear_screenshot.png
58+
59+
The default username and password match the defaults from OpenMRS(make sure that you change these in production environment).
5760

5861
The table below describes the properties declared in the file and their default values, that will work with a default localhost
5962
OpenMRS installation. The openmrs.motechIdName setting needs to match an identifier type from OpenMRS. More information on creating
6063
the identifier type in OpenMRS can be found in the :std:ref:`next section<create_id_type>`
6164

62-
+---------------------+----------------------------------------------------------------------+--------------------------------+
63-
|Key |Description |Default Value |
64-
+=====================+======================================================================+================================+
65-
|openmrs.url |The top level url at which the OpenMRS Instance is accessible. |`http://localhost:8080/openmrs` |
66-
| |Required since MOTECH integrates with OpenMRS through REST API calls. | |
67-
+---------------------+----------------------------------------------------------------------+--------------------------------+
68-
|openmrs.user |The OpenMRS username that MOTECH will use to identify with OpenMRS. |admin |
69-
+---------------------+----------------------------------------------------------------------+--------------------------------+
70-
|openmrs.password |The OpenMRS user password that MOTECH will use to identify with |Admin123 |
71-
| |OpenMRS. | |
72-
+---------------------+----------------------------------------------------------------------+--------------------------------+
73-
|openmrs.motechIdName |The name of the OpenMRS identifier used by MOTECH. This must match |MOTECH Id |
74-
| |the identifier that you will create in OpenMRS. | |
75-
+---------------------+----------------------------------------------------------------------+--------------------------------+
65+
+-----------------------+----------------------------------------------------------------------+--------------------------------+
66+
|Key |Description |Default Value |
67+
+=======================+======================================================================+================================+
68+
|openmrs.url |The top level url at which the OpenMRS Instance is accessible. |`http://localhost:8080/openmrs` |
69+
| |Required since MOTECH integrates with OpenMRS through REST API calls. | |
70+
| |Using HTTPS in the openmrs.url requires a valid SSL certificate for | |
71+
| |connection. Otherwise, Java will return an error. For example, running| |
72+
| |the Bahmni demo with Vagrant automatically redirects all traffic to | |
73+
| |https regardless of the security certificate | |
74+
| |(https://192.168.33.10/openmrs). You can get around this by pointing | |
75+
| |to port 8080 as is done in the default value | |
76+
| |(http://192.168.33.10:8080/openmrs). | |
77+
+-----------------------+----------------------------------------------------------------------+--------------------------------+
78+
|openmrs.user |The OpenMRS username that MOTECH will use to identify with OpenMRS. |admin |
79+
+-----------------------+----------------------------------------------------------------------+--------------------------------+
80+
|openmrs.password |The OpenMRS user password that MOTECH will use to identify with |Admin123 |
81+
| |OpenMRS. | |
82+
+-----------------------+----------------------------------------------------------------------+--------------------------------+
83+
|openmrs.motechIdName |The name of the OpenMRS identifier used by MOTECH. This must match |MOTECH Id |
84+
| |the identifier that you will create in OpenMRS. The default is MOTECH | |
85+
| |Id, but it could easily be changed to anything. For example, one could| |
86+
| |choose caseID if storing CommCare caseIDs in OpenMRS. | |
87+
+-----------------------+----------------------------------------------------------------------+--------------------------------+
88+
|openmrs.identifierTypes|By default, we support the one identifier type specified in | |
89+
| |openmrs.motechIdName property. Define additional identifier types here| |
90+
| |if you need to create or query an OpenMRS patient with multiple, | |
91+
| |custom identifiers via MOTECH (comma separated, if more than one). | |
92+
+-----------------------+----------------------------------------------------------------------+--------------------------------+
7693

7794
.. note::
7895

Loading

maven.properties

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ motech.sql.password=password
44
motech.sql.driver=com.mysql.jdbc.Driver
55
motech.sql.url=jdbc:mysql://localhost:3306/
66

7+
motech.dir=${user.home}/.motech
8+
79
# Controls Which bootstrap file from testdata will be copied to ~/motech/config before ITs.
810
# The file is copied from testdata/${motech.sql.dbtype}
911
motech.sql.dbtype=mysql

modules/admin/pom.xml

+56-8
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141
<artifactId>motech-platform-server-bundle</artifactId>
4242
<version>${project.version}</version>
4343
</dependency>
44-
<dependency>
45-
<groupId>${project.groupId}</groupId>
46-
<artifactId>motech-platform-server-api</artifactId>
47-
<version>${project.version}</version>
48-
</dependency>
4944
<dependency>
5045
<groupId>${project.groupId}</groupId>
5146
<artifactId>motech-platform-server-config</artifactId>
@@ -88,6 +83,12 @@
8883
<artifactId>hamcrest-all</artifactId>
8984
<scope>test</scope>
9085
</dependency>
86+
<dependency>
87+
<groupId>${project.groupId}</groupId>
88+
<artifactId>motech-upload-test-bundle</artifactId>
89+
<version>${project.version}</version>
90+
<scope>test</scope>
91+
</dependency>
9192
<dependency>
9293
<groupId>org.sonatype.aether</groupId>
9394
<artifactId>org.motechproject.aether-api</artifactId>
@@ -116,7 +117,7 @@
116117
<excludeDefaultDirectories>true</excludeDefaultDirectories>
117118
<filesets>
118119
<fileset>
119-
<directory>${user.home}/.motech/config/org.motechproject.motech-admin-bundle</directory>
120+
<directory>${motech.dir}/config/org.motechproject.motech-admin-bundle</directory>
120121
<includes>
121122
<include>**/*</include>
122123
</includes>
@@ -205,7 +206,7 @@
205206
<goal>copy-resources</goal>
206207
</goals>
207208
<configuration>
208-
<outputDirectory>${user.home}/.motech/bundles</outputDirectory>
209+
<outputDirectory>${motech.dir}/bundles</outputDirectory>
209210
<resources>
210211
<resource>
211212
<directory>target</directory>
@@ -223,7 +224,7 @@
223224
<goal>copy-resources</goal>
224225
</goals>
225226
<configuration>
226-
<outputDirectory>${user.home}/.motech/rules</outputDirectory>
227+
<outputDirectory>${motech.dir}/rules</outputDirectory>
227228
<resources>
228229
<resource>
229230
<directory>src/main/resources/rules</directory>
@@ -312,6 +313,53 @@
312313
<groupId>com.github.searls</groupId>
313314
<artifactId>jasmine-maven-plugin</artifactId>
314315
</plugin>
316+
<plugin>
317+
<groupId>org.apache.maven.plugins</groupId>
318+
<artifactId>maven-dependency-plugin</artifactId>
319+
<version>2.10</version>
320+
<executions>
321+
<execution>
322+
<id>copy-upload-test-bundle-to-target</id>
323+
<phase>package</phase>
324+
<goals>
325+
<goal>copy</goal>
326+
</goals>
327+
<configuration>
328+
<artifactItems>
329+
<artifactItem>
330+
<groupId>${project.groupId}</groupId>
331+
<artifactId>motech-upload-test-bundle</artifactId>
332+
<version>${project.version}</version>
333+
<type>jar</type>
334+
<overWrite>true</overWrite>
335+
<outputDirectory>target/test-bundle/</outputDirectory>
336+
<destFileName>motech-upload-test-bundle.jar</destFileName>
337+
</artifactItem>
338+
</artifactItems>
339+
</configuration>
340+
</execution>
341+
<execution>
342+
<id>copy-upload-test-bundle</id>
343+
<phase>package</phase>
344+
<goals>
345+
<goal>copy</goal>
346+
</goals>
347+
<configuration>
348+
<artifactItems>
349+
<artifactItem>
350+
<groupId>${project.groupId}</groupId>
351+
<artifactId>motech-upload-test-bundle</artifactId>
352+
<version>${project.version}</version>
353+
<type>jar</type>
354+
<overWrite>true</overWrite>
355+
<outputDirectory>${user.home}/.motech/bundles</outputDirectory>
356+
<destFileName>motech-upload-test-bundle.jar</destFileName>
357+
</artifactItem>
358+
</artifactItems>
359+
</configuration>
360+
</execution>
361+
</executions>
362+
</plugin>
315363
</plugins>
316364
</build>
317365

modules/admin/src/main/java/org/motechproject/admin/bundles/BundleDirectoryManager.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import org.apache.commons.io.FileUtils;
44
import org.apache.commons.io.IOUtils;
5+
import org.motechproject.config.core.domain.BootstrapConfig;
6+
import org.motechproject.config.service.ConfigurationService;
57
import org.osgi.framework.Bundle;
6-
import org.springframework.beans.factory.annotation.Value;
8+
import org.springframework.beans.factory.annotation.Autowired;
79
import org.springframework.stereotype.Component;
810
import org.springframework.web.multipart.MultipartFile;
911

12+
import javax.annotation.PostConstruct;
1013
import java.io.File;
1114
import java.io.IOException;
1215
import java.io.InputStream;
@@ -22,9 +25,17 @@
2225
@Component
2326
public class BundleDirectoryManager {
2427

25-
@Value("${user.home}/.motech/bundles")
28+
@Autowired
29+
private ConfigurationService configurationService;
30+
2631
private String bundleDir;
2732

33+
@PostConstruct
34+
public void init() {
35+
BootstrapConfig bootstrapConfig = configurationService.loadBootstrapConfig();
36+
bundleDir = bootstrapConfig.getMotechDir() + "/bundles";
37+
}
38+
2839
/**
2940
* Returns the directory used to store Motech bundles
3041
* @return the bundle directory

platform/server-api/src/main/java/org/motechproject/server/api/BundleInformation.java modules/admin/src/main/java/org/motechproject/admin/bundles/BundleInformation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.motechproject.server.api;
1+
package org.motechproject.admin.bundles;
22

33
import org.osgi.framework.Bundle;
44
import org.osgi.framework.Version;

modules/admin/src/main/java/org/motechproject/admin/bundles/ExtendedBundleInformation.java

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.apache.commons.lang.StringUtils;
44
import org.joda.time.DateTime;
5-
import org.motechproject.server.api.BundleInformation;
65
import org.osgi.framework.Bundle;
76
import org.osgi.framework.BundleContext;
87
import org.osgi.framework.ServiceReference;

platform/server-api/src/main/java/org/motechproject/server/api/JarInformation.java modules/admin/src/main/java/org/motechproject/admin/bundles/JarInformation.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.motechproject.server.api;
1+
package org.motechproject.admin.bundles;
22

33

44
import org.motechproject.server.osgi.util.PlatformConstants;
@@ -23,13 +23,14 @@ public class JarInformation {
2323

2424
private static final Logger LOGGER = LoggerFactory.getLogger(JarInformation.class);
2525

26-
public static final String EXTRACTION_FAILED = "Extraction failed.";
27-
public static final String IMPLEMENTATION_VERSION = "Implementation-Version";
28-
public static final String IMPLEMENTATION_TITLE = "Implementation-Title";
29-
public static final String IMPLEMENTATION_VENDOR_ID = "Implementation-Vendor-Id";
30-
public static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName";
3126
public static final String BUNDLE_VERSION = "Bundle-Version";
3227

28+
private static final String EXTRACTION_FAILED = "Extraction failed.";
29+
private static final String IMPLEMENTATION_VERSION = "Implementation-Version";
30+
private static final String IMPLEMENTATION_TITLE = "Implementation-Title";
31+
private static final String IMPLEMENTATION_VENDOR_ID = "Implementation-Vendor-Id";
32+
private static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName";
33+
3334
private String path;
3435
private String filename;
3536
private String implementationVendorID;

platform/server-api/src/main/java/org/motechproject/server/api/PomInformation.java modules/admin/src/main/java/org/motechproject/admin/bundles/PomInformation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.motechproject.server.api;
1+
package org.motechproject.admin.bundles;
22

33
import org.apache.maven.model.Model;
44
import org.apache.maven.model.Parent;

modules/admin/src/main/java/org/motechproject/admin/internal/service/ModuleAdminService.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import org.motechproject.admin.bundles.ExtendedBundleInformation;
44
import org.motechproject.admin.security.SecurityConstants;
55
import org.motechproject.event.MotechEvent;
6-
import org.motechproject.server.api.BundleIcon;
7-
import org.motechproject.server.api.BundleInformation;
6+
import org.motechproject.admin.bundles.BundleInformation;
87
import org.osgi.framework.BundleException;
98
import org.springframework.security.access.prepost.PreAuthorize;
109
import org.springframework.web.multipart.MultipartFile;
@@ -34,14 +33,6 @@ public interface ModuleAdminService {
3433
@PreAuthorize(SecurityConstants.MANAGE_BUNDLES)
3534
BundleInformation getBundleInfo(long bundleId);
3635

37-
/**
38-
* Retrieves a {@link org.motechproject.server.api.BundleIcon} for the bundle with the given bundle id. The icon is
39-
* loaded from the bundle.
40-
* @param bundleId the bundle id of the bundle for which the icon should be retrieved.
41-
* @return the icon retrieved for the bundle. If no icon is available, the default icon is returned.
42-
*/
43-
BundleIcon getBundleIcon(long bundleId);
44-
4536
/**
4637
* Retrieves detailed information about the given bundle.
4738
* @param bundleId the bundle id of the bundle for which the information should be retrieved.

modules/admin/src/main/java/org/motechproject/admin/internal/service/impl/ModuleAdminServiceImpl.java

+3-48
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.motechproject.admin.internal.service.impl;
22

33
import org.apache.commons.io.FileUtils;
4-
import org.apache.commons.io.IOUtils;
54
import org.apache.commons.lang.StringUtils;
65
import org.apache.maven.wagon.ConnectionException;
76
import org.apache.maven.wagon.Wagon;
@@ -21,10 +20,9 @@
2120
import org.motechproject.mds.service.BundleWatcherSuspensionService;
2221
import org.motechproject.osgi.web.ModuleRegistrationData;
2322
import org.motechproject.osgi.web.service.UIFrameworkService;
24-
import org.motechproject.server.api.BundleIcon;
25-
import org.motechproject.server.api.BundleInformation;
26-
import org.motechproject.server.api.JarInformation;
27-
import org.motechproject.server.api.PomInformation;
23+
import org.motechproject.admin.bundles.BundleInformation;
24+
import org.motechproject.admin.bundles.JarInformation;
25+
import org.motechproject.admin.bundles.PomInformation;
2826
import org.osgi.framework.Bundle;
2927
import org.osgi.framework.BundleContext;
3028
import org.osgi.framework.BundleException;
@@ -57,8 +55,6 @@
5755
import java.io.File;
5856
import java.io.IOException;
5957
import java.io.InputStream;
60-
import java.net.URL;
61-
import java.net.URLConnection;
6258
import java.util.ArrayList;
6359
import java.util.Collections;
6460
import java.util.HashSet;
@@ -71,7 +67,6 @@
7167

7268
import static org.apache.commons.lang.StringUtils.isNotBlank;
7369
import static org.motechproject.config.core.constants.ConfigurationConstants.FILE_CHANGED_EVENT_SUBJECT;
74-
import static org.motechproject.server.api.BundleIcon.ICON_LOCATIONS;
7570
import static org.springframework.util.CollectionUtils.isEmpty;
7671

7772

@@ -83,8 +78,6 @@ public class ModuleAdminServiceImpl implements ModuleAdminService {
8378

8479
private static final Logger LOGGER = LoggerFactory.getLogger(ModuleAdminServiceImpl.class);
8580

86-
private static final String DEFAULT_ICON = "/bundle_icon.png";
87-
8881
@Autowired
8982
private BundleContext bundleContext;
9083

@@ -183,27 +176,6 @@ public void uninstallBundle(long bundleId, boolean removeConfig) throws BundleEx
183176
}
184177
}
185178

186-
@Override
187-
public BundleIcon getBundleIcon(long bundleId) {
188-
BundleIcon bundleIcon = null;
189-
Bundle bundle = getBundle(bundleId);
190-
191-
for (String iconLocation : ICON_LOCATIONS) {
192-
URL iconURL = bundle.getResource(iconLocation);
193-
if (iconURL != null) {
194-
bundleIcon = loadBundleIcon(iconURL);
195-
break;
196-
}
197-
}
198-
199-
if (bundleIcon == null) {
200-
URL defaultIconURL = getClass().getResource(DEFAULT_ICON);
201-
bundleIcon = loadBundleIcon(defaultIconURL);
202-
}
203-
204-
return bundleIcon;
205-
}
206-
207179
@Override
208180
public BundleInformation installBundleFromRepository(String moduleId, boolean startBundle) {
209181
try {
@@ -541,23 +513,6 @@ private JarInformation getJarInformations(File bundleFile) throws IOException {
541513
return jarInformation;
542514
}
543515

544-
private BundleIcon loadBundleIcon(URL iconURL) {
545-
InputStream is = null;
546-
try {
547-
URLConnection urlConn = iconURL.openConnection();
548-
is = urlConn.getInputStream();
549-
550-
String mime = urlConn.getContentType();
551-
byte[] image = IOUtils.toByteArray(is);
552-
553-
return new BundleIcon(image, mime);
554-
} catch (IOException e) {
555-
throw new MotechException("Error loading icon.", e);
556-
} finally {
557-
IOUtils.closeQuietly(is);
558-
}
559-
}
560-
561516
private Bundle getBundle(long bundleId) {
562517
Bundle bundle = bundleContext.getBundle(bundleId);
563518
if (bundle == null || !motechBundleFilter.passesCriteria(bundle)) {

0 commit comments

Comments
 (0)