Skip to content

Commit

Permalink
#3262 Orientdb upgraded to 2.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarcon committed Oct 22, 2018
1 parent 68996ac commit 5b18539
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 453 deletions.
82 changes: 0 additions & 82 deletions opal-config-migrator/pom.xml

This file was deleted.

29 changes: 0 additions & 29 deletions opal-config-migrator/src/main/assembly/cli.assembly.xml

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions opal-config-migrator/src/main/resources/orientdb-server-config.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public class WebContentInterceptor implements RequestCyclePostProcess {

@Override
public void postProcess(HttpRequest request, ResourceMethodInvoker resourceMethod, ServerResponse response) {
MultivaluedMap<String, Object> map = response.getHeaders();
MultivaluedMap<String, String> map = response.getStringHeaders();
//making sure IE doesn't cache: https://support.microsoft.com/en-us/kb/234067
map.put("Expires", Collections.<Object>singletonList("-1"));
map.put("Cache-Control", Collections.<Object>singletonList("no-cache"));
map.put("Pragma", Collections.<Object>singletonList("no-cache"));
map.put("Expires", Collections.singletonList("-1"));
map.put("Cache-Control", Collections.singletonList("no-cache"));
map.put("Pragma", Collections.singletonList("no-cache"));
}
}
6 changes: 3 additions & 3 deletions opal-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@
<artifactId>commons-configuration</artifactId>
</dependency>

<dependency>
<!--dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-enterprise</artifactId>
</dependency>
<artifactId>orientdb-community</artifactId>
</dependency-->
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public void onRemoval(RemovalNotification<String, DataSource> notification) {
DataSource dataSource = notification.getValue();
if(dataSource == null) {
log.info("Cannot close null DataSource {}", database);
} else {
} else if (dataSource instanceof BasicDataSource) {
try {
((BasicDataSource) dataSource).close();
} catch(SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import javax.annotation.PreDestroy;
import javax.validation.constraints.NotNull;

import com.orientechnologies.common.log.OLogManager;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -24,6 +26,8 @@
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.server.OServer;

import java.io.*;

@Component
public class LocalOrientDbServerFactory implements OrientDbServerFactory {

Expand Down Expand Up @@ -68,6 +72,8 @@ public void start() throws Exception {
System.setProperty("ORIENTDB_HOME", url.replaceFirst("^" + DEFAULT_SCHEME + ":", ""));
System.setProperty("ORIENTDB_ROOT_PASSWORD", PASSWORD);

ensureSecurityConfig();

server = new OServer() //
.startup(LocalOrientDbServerFactory.class.getResourceAsStream("/orientdb-server-config.xml")) //
.activate();
Expand Down Expand Up @@ -98,6 +104,21 @@ public ODatabaseDocumentTx getDocumentTx() {
return poolFactory.get(url, USERNAME, PASSWORD).acquire();
}

private void ensureSecurityConfig() throws IOException {
File securityFile = new File(System.getProperty("ORIENTDB_HOME") + File.separator + "config", "security.json");
if (!securityFile.exists()) {
if (!securityFile.getParentFile().exists()) {
securityFile.getParentFile().mkdirs();
}
securityFile.createNewFile();
JSONObject securityObject = new JSONObject();
securityObject.put("enabled", false);
try (PrintWriter out = new PrintWriter(securityFile.getAbsolutePath())) {
out.println(securityObject.toString());
}
}
}

private void ensureDatabaseExists() {
try(ODatabaseDocumentTx database = new ODatabaseDocumentTx(url)) {
if(!database.exists()) {
Expand Down
5 changes: 0 additions & 5 deletions opal-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@
<artifactId>obiba-password-hasher</artifactId>
<classifier>cli</classifier>
</dependency>
<dependency>
<groupId>org.obiba.opal</groupId>
<artifactId>opal-config-migrator</artifactId>
<classifier>cli</classifier>
</dependency>
<dependency>
<groupId>com.newrelic.agent.java</groupId>
<artifactId>newrelic-agent</artifactId>
Expand Down
2 changes: 0 additions & 2 deletions opal-server/src/main/assembly/opal-server.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<excludes>
<exclude>org.obiba.opal:opal-gwt-client:*</exclude>
<exclude>org.obiba.opal:opal-reporting:zip:dist</exclude>
<exclude>org.obiba.opal:opal-config-migrator:jar:cli</exclude>
<exclude>org.obiba.commons:obiba-password-hasher:jar:cli</exclude>
<exclude>org.apache.shiro.tools:shiro-tools-hasher:*</exclude>
</excludes>
Expand All @@ -99,7 +98,6 @@
<dependencySet>
<outputDirectory>tools/lib</outputDirectory>
<includes>
<include>org.obiba.opal:opal-config-migrator:jar:cli</include>
<include>org.apache.shiro.tools:shiro-tools-hasher:*</include>
<include>org.obiba.commons:obiba-password-hasher:jar:cli</include>
</includes>
Expand Down
16 changes: 0 additions & 16 deletions opal-server/src/main/deb/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,6 @@ case "$1" in
ln -s /etc/opal /var/lib/opal/conf
fi

EXPORT_FILE=$OPAL_HOME/data/orientdb/opal-config.export

JAR_CMD="java -jar /usr/share/opal-*/tools/lib/opal-config-migrator-*-cli.jar"

[ -r $OPAL_HOME/data/orientdb/opal-config ] && $JAR_CMD --check $OPAL_HOME/data/orientdb/opal-config && \
{ $JAR_CMD $OPAL_HOME/data/orientdb/opal-config $EXPORT_FILE && \
echo "Legacy export completed ..." && \
mv $OPAL_HOME/data/orientdb/opal-config $OPAL_HOME/data/orientdb/opal-config.bak || exit 1; }

[ -r $EXPORT_FILE.gz ] && { \
java -cp "/usr/share/opal/lib/*" -DOPAL_HOME=$OPAL_HOME org.obiba.opal.core.tools.OrientDbUtil import $EXPORT_FILE.gz && \
rm $EXPORT_FILE.gz && \
chown -R opal:adm $OPAL_HOME/data/orientdb && \
rm -Rf $OPAL_HOME/data/orientdb/opal-config.bak || { mv $OPAL_HOME/data/orientdb/opal-config.bak $OPAL_HOME/data/orientdb/opal-config; \
exit 1; }; }

chown -R opal:adm /var/lib/opal /var/log/opal /etc/opal /tmp/opal
chmod -R 750 /var/lib/opal /var/log/opal /etc/opal/ /tmp/opal
chmod +x /usr/share/opal/tools/shiro-hasher
Expand Down
10 changes: 0 additions & 10 deletions opal-server/src/main/deb/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ case "$1" in
else
/etc/init.d/opal stop
fi

EXPORT_FILE=$OPAL_HOME/data/orientdb/opal-config.export

echo "prerm migration check ..."

JAR_CMD="java -jar /usr/share/opal-*/tools/lib/opal-config-migrator-*-cli.jar"
$JAR_CMD --check $OPAL_HOME/data/orientdb/opal-config && \
{ $JAR_CMD $OPAL_HOME/data/orientdb/opal-config $EXPORT_FILE && \
echo "prerm legacy export completed ..." && \
mv $OPAL_HOME/data/orientdb/opal-config $OPAL_HOME/data/orientdb/opal-config.bak || exit 1; }
;;

failed-upgrade)
Expand Down
Loading

0 comments on commit 5b18539

Please sign in to comment.