Commit 7440e214 authored by Romain Bioteau's avatar Romain Bioteau
Browse files

BS-14684 Access to custom permission mapping file

parent e57fd7da
......@@ -33,6 +33,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
public class BonitaHomeHandler {
private static final String TENANT_ID = "1";
public static final String BONITA_HOME = "bonita_home";
private final IProject project;
......@@ -41,11 +42,11 @@ public class BonitaHomeHandler {
}
public void cleanTenant() {
final File bonitaServerFile = Paths.get(getRoot(), "engine-server", "work", "tenants", "1").toFile();
final File bonitaServerFile = Paths.get(getRoot(), "engine-server", "work", "tenants", TENANT_ID).toFile();
PlatformUtil.delete(bonitaServerFile, null);
final File bonitaClientFile = Paths.get(getRoot(), "engine-client", "work", "tenants", "1").toFile();
final File bonitaClientFile = Paths.get(getRoot(), "engine-client", "work", "tenants", TENANT_ID).toFile();
PlatformUtil.delete(bonitaClientFile, null);
final File bonitaWebClientFile = Paths.get(getRoot(), "client", "tenants", "1").toFile();
final File bonitaWebClientFile = Paths.get(getRoot(), "client", "tenants", TENANT_ID).toFile();
PlatformUtil.delete(bonitaWebClientFile, null);
final File platformTomcatConfig = Paths.get(getRoot(), "client", "platform", "conf", "platform-tenant-config.properties").toFile();
PlatformUtil.delete(platformTomcatConfig, null);
......@@ -147,6 +148,6 @@ public class BonitaHomeHandler {
}
public IFile getCustomPermissionMappingFile() {
return project.getFile(BONITA_HOME + "/client/tenants/1/conf/custom-permissions-mapping.properties");
return project.getFile(BONITA_HOME + "/client/tenants/" + TENANT_ID + "/conf/custom-permissions-mapping.properties");
}
}
......@@ -14,8 +14,11 @@
*/
package org.bonitasoft.studio.common.perspectives;
import java.util.Objects;
import org.bonitasoft.studio.common.RestAPIExtensionNature;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
......@@ -23,7 +26,6 @@ import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPerspectiveFactory;
/**
*
* Must extends this class to enable the automatic switch between perspectives depending of the editor type
*
* @author Baptiste Mesta
......@@ -31,27 +33,29 @@ import org.eclipse.ui.IPerspectiveFactory;
*/
public abstract class AbstractPerspectiveFactory implements IPerspectiveFactory {
/**
* returns true if the perspective must be activated when opening the editor part given in param
*
* @param part
* the editor part that is brought to top
* @return
* true if perspective must be activated, false otherwise
*/
public abstract boolean isRelevantFor(IEditorPart part);
/**
*
* @return the id of the perspective
*/
public abstract String getID();
private static final String CUSTOM_PERMISSIONS_MAPPING_FILE = "custom-permissions-mapping.properties";
/**
* returns true if the perspective must be activated when opening the editor part given in param
*
* @param part
* the editor part that is brought to top
* @return
* true if perspective must be activated, false otherwise
*/
public abstract boolean isRelevantFor(IEditorPart part);
/**
* @return the id of the perspective
*/
public abstract String getID();
protected boolean isInsideprojectWithREStApiExtensionNature(final IEditorPart part) {
final IEditorInput editorInput = part.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
try {
return ((IFileEditorInput) editorInput).getFile().getProject().hasNature(RestAPIExtensionNature.NATURE_ID);
final IFile file = ((IFileEditorInput) editorInput).getFile();
return file.getProject().hasNature(RestAPIExtensionNature.NATURE_ID) || Objects.equals(file.getName(), CUSTOM_PERMISSIONS_MAPPING_FILE);
} catch (final CoreException e) {
BonitaStudioLog.error(e);
}
......
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