Commit f7af64aa authored by Aurelien Pupier's avatar Aurelien Pupier
Browse files

Merge pull request #282 from bonitasoft/fix/BS-14070_tomcat_startup_after_switch_repo

BS-14070 Fix running state of engine
parents f5638635 9f4db1a0
......@@ -39,8 +39,10 @@ public class RepositoryNotifier {
}
public void postDelete(final IRepositoryFileStore fileStore) throws ResourceNotFoundException {
fileStore.getParentStore().refresh();
repository.handleFileStoreEvent(new FileStoreChangeEvent(EventType.POST_DELETE, fileStore));
if (fileStore != null) {
fileStore.getParentStore().refresh();
repository.handleFileStoreEvent(new FileStoreChangeEvent(EventType.POST_DELETE, fileStore));
}
}
public void postClose(final IRepositoryFileStore fileStore) throws ResourceNotFoundException {
......@@ -57,8 +59,10 @@ public class RepositoryNotifier {
}
public void postSave(final IRepositoryFileStore fileStore) {
fileStore.getParentStore().refresh();
repository.handleFileStoreEvent(new FileStoreChangeEvent(EventType.POST_SAVE, fileStore));
if (fileStore != null) {
fileStore.getParentStore().refresh();
repository.handleFileStoreEvent(new FileStoreChangeEvent(EventType.POST_SAVE, fileStore));
}
}
private void checkExists(final IRepositoryFileStore fileStore) throws ResourceNotFoundException {
......
......@@ -89,7 +89,8 @@ public class WorkspaceServerResource extends ServerResource {
@Post("text/plain")
public void dispatch(final String filePath) throws ResourceNotFoundException, LockedResourceException {
repositoryNotifier.dispatch(WorkspaceAPIEvent.valueOf(action), toFileStore(filePath));
final IRepositoryFileStore fileStore = toFileStore(filePath);
repositoryNotifier.dispatch(WorkspaceAPIEvent.valueOf(action), fileStore);
}
@Get
......
/**
* Copyright (C) 2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.engine;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.junit.Test;
public class BOSEngineManagerTest {
@Test
public void should_not_flag_engine_running_state_to_true_if_post_start_fails() throws Exception {
final BOSEngineManager engineManager = spy(new BOSEngineManager(new NullProgressMonitor()));
doReturn(false).when(engineManager).tomcatServerIsRunning();
doThrow(Exception.class).when(engineManager).getLoginAPI();
final boolean isRunning = engineManager.postEngineStart();
assertThat(isRunning).isFalse();
}
}
/**
* Copyright (C) 2012 BonitaSoft S.A.
* BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
* Copyright (C) 2012-2015 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
......@@ -133,13 +133,12 @@ public class BOSEngineManager {
monitor.beginTask(Messages.initializingProcessEngine, IProgressMonitor.UNKNOWN);
initBonitaHome();
BOSWebServerManager.getInstance().startServer(monitor);
postEngineStart();
isRunning = true;
isRunning = postEngineStart();
monitor.done();
}
}
protected void postEngineStart() {
protected boolean postEngineStart() {
//RESUME ENGINE IF PAUSED AT STARTUP
try {
final APISession apiSession = getLoginAPI().login(BONITA_TECHNICAL_USER, BONITA_TECHNICAL_USER_PASSWORD);
......@@ -147,15 +146,24 @@ public class BOSEngineManager {
if (tenantManagementAPI.isPaused()) {
tenantManagementAPI.resume();
}
executePostStartupContributions();
} catch (final Exception e) {
BonitaStudioLog.error(e);
return handlePostEngineStartException(e);
}
return true;
}
try {
executePostStartupContributions();
} catch (final Exception e) {
private boolean handlePostEngineStartException(final Exception e) {
if (tomcatServerIsRunning()) {
BonitaStudioLog.error(e);
} else {
BonitaStudioLog.warning("Tomcat server has been shutdown before first start ended.", EnginePlugin.PLUGIN_ID);
}
return false;
}
protected boolean tomcatServerIsRunning() {
return BOSWebServerManager.getInstance().serverIsStarted();
}
public synchronized void stop() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment