Commit f934cebb authored by Romain Bioteau's avatar Romain Bioteau Committed by Romain Bioteau

fix(UIDesigner): Filter .metadata folder (#145)

* Filter at bos export
* Add to svn ignore

fixes [BS-14878](https://bonitasoft.atlassian.net/browse/BS-14878)
parent a342c60c
......@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.bonitasoft.studio.common.editor.EditorUtil;
import org.bonitasoft.studio.common.jface.databinding.validator.EmptyInputValidator;
......@@ -97,7 +98,7 @@ public class ExportRepositoryWizardPage extends WizardPage {
private final String defaultFileName;
private ViewerFilter[] filters = {};
private Set<Object> defaultSelectedFiles = new HashSet<Object>();
private Set<Object> defaultSelectedFiles = new HashSet<>();
public ExportRepositoryWizardPage(final List<IRepositoryStore<? extends IRepositoryFileStore>> stores, final boolean isZip, final String defaultFileName) {
super(ExportRepositoryWizardPage.class.getName());
......@@ -201,7 +202,7 @@ public class ExportRepositoryWizardPage extends WizardPage {
}
private Set<IRepositoryFileStore> getSelectedFileStores() {
final Set<IRepositoryFileStore> checkedArtifacts = new HashSet<IRepositoryFileStore>();
final Set<IRepositoryFileStore> checkedArtifacts = new HashSet<>();
for (final Object element : treeViewer.checkedElementsObservable()) {
if (element instanceof IRepositoryFileStore) {
checkedArtifacts.add((IRepositoryFileStore) element);
......@@ -292,7 +293,7 @@ public class ExportRepositoryWizardPage extends WizardPage {
operation.setDestinationPath(getDetinationPath());
final Set<IResource> resourcesToExport = computeResourcesToExport();
try {
final Set<IResource> toOpen = new HashSet<IResource>();
final Set<IResource> toOpen = new HashSet<>();
for (final IEditorReference ref : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) {
final IFile file = (IFile) EditorUtil.retrieveResourceFromEditorInput(ref.getEditorInput());
if (resourcesToExport.contains(file)) {
......@@ -309,13 +310,13 @@ public class ExportRepositoryWizardPage extends WizardPage {
}
protected Set<IResource> computeResourcesToExport() {
final Set<IResource> resourcesToExport = new HashSet<IResource>();
final Set<IResource> resourcesToExport = new HashSet<>();
for (final IRepositoryFileStore file : getSelectedFileStores()) {
IResource resource = file.getResource();
final IResource resource = file.getResource();
if (resource != null && resource.exists()) {
try {
addChildrenFile(resource,resourcesToExport);
} catch (CoreException e) {
} catch (final CoreException e) {
BonitaStudioLog.error(e);
}
resourcesToExport.addAll(file.getRelatedResources());
......@@ -325,16 +326,21 @@ public class ExportRepositoryWizardPage extends WizardPage {
}
private void addChildrenFile(IResource resource, Set<IResource> resourcesToExport) throws CoreException {
if(resource instanceof IFile){
if (resource instanceof IFile) {
resourcesToExport.add(resource);
}else if(resource instanceof IFolder){
for(IResource r : ((IFolder) resource).members()){
} else if (resource instanceof IFolder && !isMetadataFolder(resource)) {
for(final IResource r : ((IFolder) resource).members()){
addChildrenFile(r,resourcesToExport);
}
}
}
protected void createDestination(final Composite group) {
private boolean isMetadataFolder(IResource resource) {
final String resourceName = resource.getName();
return Pattern.matches(".metadata", resourceName);
}
protected void createDestination(final Composite group) {
final Label destPath = new Label(group, SWT.NONE);
destPath.setText(Messages.destinationPath + " *");
destPath.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
......
#Wed Nov 04 14:22:31 GMT+01:00 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5
org.eclipse.jdt.core.compiler.source=1.7
......@@ -33,13 +33,20 @@ Require-Bundle: org.eclipse.core.runtime,
org.bonitasoft.studio.engine;bundle-version="1.0.0",
org.bonitasoft.studio.test.swtbot.util;bundle-version="1.0.0",
org.eclipse.swtbot.junit4_x;bundle-version="2.0.5",
org.bonitasoft.studio.connectors.test
org.bonitasoft.studio.connectors.test,
assertj-core;bundle-version="1.5.0",
org.bonitasoft.studio.swtbot.framework;bundle-version="7.4.0",
org.bonitasoft.studio.designer;bundle-version="7.4.0",
org.bonitasoft.studio.preferences
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.bonitasoft.studio.exporter.tests,org.bonitasoft.st
udio.exporter.tests.api,org.bonitasoft.studio.exporter.tests.applicat
ion,org.bonitasoft.studio.exporter.tests.autologin,org.bonitasoft.stu
dio.exporter.tests.bpmn,org.bonitasoft.studio.exporter.tests.form
Export-Package: org.bonitasoft.studio.exporter.tests,
org.bonitasoft.studio.exporter.tests.api,
org.bonitasoft.studio.exporter.tests.application,
org.bonitasoft.studio.exporter.tests.autologin,
org.bonitasoft.studio.exporter.tests.bos,
org.bonitasoft.studio.exporter.tests.bpmn,
org.bonitasoft.studio.exporter.tests.form
Import-Package: net.htmlparser.jericho,
org.bonitasoft.engine.bpm.bar,
org.bonitasoft.engine.exception
package org.bonitasoft.studio.exporter.tests.bos;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
import java.util.zip.ZipFile;
import org.bonitasoft.studio.common.repository.Repository;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.designer.core.PageDesignerURLFactory;
import org.bonitasoft.studio.designer.core.operation.CreateFormOperation;
import org.bonitasoft.studio.designer.core.repository.WebPageFileStore;
import org.bonitasoft.studio.designer.core.repository.WebPageRepositoryStore;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.bonitasoft.studio.swtbot.framework.application.BotApplicationWorkbenchWindow;
import org.bonitasoft.studio.swtbot.framework.rule.SWTGefBotRule;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
public class ExportBosArchiveIT {
private SWTGefBot bot = new SWTGefBot();
@Rule
public SWTGefBotRule SWTswtGefBotRule = new SWTGefBotRule(bot);
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Test
public void should_not_export_ui_designer_metadata() throws Exception {
WebPageRepositoryStore repositoryStore = RepositoryManager.getInstance().getCurrentRepository().getRepositoryStore(WebPageRepositoryStore.class);
CreateFormOperation createFormOperation = new CreateFormOperation(
new PageDesignerURLFactory(InstanceScope.INSTANCE.getNode(BonitaStudioPreferencesPlugin.PLUGIN_ID)));
createFormOperation.run(Repository.NULL_PROGRESS_MONITOR);
String pageName = createFormOperation.getNewPageName();
String pageId = createFormOperation.getNewPageId();
assertThat(pageName).isNotEmpty();
assertThat(pageId).isNotEmpty();
assertThat(repositoryStore.getChild(pageId)).isNotNull();
File bosFile = temporaryFolder.newFile("exportWithoutMetadat.bos");
new BotApplicationWorkbenchWindow(bot).export().selectAll().setDestinationPath(bosFile.getAbsolutePath()).finish();
assertThat(bosFile).exists();
try (ZipFile zipFile = new ZipFile(bosFile);) {
assertThat(zipFile.getEntry(String.format("default/web_page/%s/%s.json", pageId, pageId))).isNotNull();
assertThat(zipFile.getEntry("default/web_page/.metadata")).isNull();
}
}
@After
public void tearDown() throws Exception {
WebPageRepositoryStore repositoryStore = RepositoryManager.getInstance().getCurrentRepository().getRepositoryStore(WebPageRepositoryStore.class);
for (WebPageFileStore fs : repositoryStore.getChildren()) {
fs.delete();
}
}
}
......@@ -26,7 +26,8 @@ Require-Bundle: org.eclipse.swtbot.eclipse.gef.finder,
org.junit;bundle-version="4.11.0",
org.bonitasoft.studio.preferences,
org.bonitasoft.studio.connectors.model.edit,
org.eclipse.ui.browser
org.eclipse.ui.browser,
org.bonitasoft.studio.exporter;bundle-version="7.4.0"
Import-Package: org.bonitasoft.studio.application.i18n,
org.bonitasoft.studio.configuration.i18n,
org.bonitasoft.studio.connector.model.i18n,
......@@ -51,6 +52,7 @@ Export-Package: org.bonitasoft.studio.swtbot.framework,
org.bonitasoft.studio.swtbot.framework.diagram.configuration,
org.bonitasoft.studio.swtbot.framework.diagram.data,
org.bonitasoft.studio.swtbot.framework.diagram.execution,
org.bonitasoft.studio.swtbot.framework.diagram.export,
org.bonitasoft.studio.swtbot.framework.diagram.general,
org.bonitasoft.studio.swtbot.framework.diagram.general.actors,
org.bonitasoft.studio.swtbot.framework.diagram.general.connectors,
......
......@@ -16,6 +16,7 @@ import org.bonitasoft.studio.swtbot.framework.application.menu.BotEditMenu;
import org.bonitasoft.studio.swtbot.framework.application.menu.BotOrganizationMenu;
import org.bonitasoft.studio.swtbot.framework.diagram.BotProcessDiagramPerspective;
import org.bonitasoft.studio.swtbot.framework.diagram.configuration.BotConfigureDialog;
import org.bonitasoft.studio.swtbot.framework.diagram.export.BotExportBOSDialog;
import org.bonitasoft.studio.test.swtbot.util.SWTBotTestUtil;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
......@@ -137,4 +138,9 @@ public class BotApplicationWorkbenchWindow extends AbstractBotMenu {
final Pool selectedProcess = ModelHelper.getFirstContainerOfType(ep.resolveSemanticElement(), Pool.class);
return new BotConfigureDialog(bot, selectedProcess.getName() + " (" + selectedProcess.getVersion() + ")");
}
public BotExportBOSDialog export() {
bot.toolbarButton("Export").click();
return new BotExportBOSDialog(bot);
}
}
/**
* 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.swtbot.framework.diagram.export;
import org.bonitasoft.studio.common.repository.Messages;
import org.bonitasoft.studio.swtbot.framework.BotWizardDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public class BotExportBOSDialog extends BotWizardDialog {
public BotExportBOSDialog(final SWTGefBot bot) {
super(bot, org.bonitasoft.studio.exporter.Messages.ExportButtonLabel);
}
public BotExportBOSDialog selectAll() {
bot.button(Messages.selectAll).click();
return this;
}
public BotExportBOSDialog setDestinationPath(String path) {
bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(path);
return this;
}
@Override
public void finish() {
bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)), 5000);
bot.button(IDialogConstants.FINISH_LABEL).click();
bot.waitUntil(Conditions.shellIsActive(Messages.exportLabel),15000);
final SWTBotShell activeShell = bot.activeShell();
bot.button(IDialogConstants.OK_LABEL).click();
bot.waitUntil(Conditions.shellCloses(activeShell));
}
}
......@@ -34,6 +34,7 @@ import org.bonitasoft.studio.diagram.test.TestConvertToMessage;
import org.bonitasoft.studio.diagram.test.TestMoveBetweenLane;
import org.bonitasoft.studio.diagram.test.TestSave;
import org.bonitasoft.studio.engine.test.bar.BarExporterTest;
import org.bonitasoft.studio.exporter.tests.bos.ExportBosArchiveIT;
import org.bonitasoft.studio.exporter.tests.bpmn.BPMNConnectorExportImportTest;
import org.bonitasoft.studio.exporter.tests.bpmn.BPMNEventSubProcessExportImportTest;
import org.bonitasoft.studio.exporter.tests.bpmn.BPMNExportTests;
......@@ -99,6 +100,7 @@ import org.junit.runners.Suite;
BPMNGatewayExportImportTest.class,
BPMNEventSubProcessExportImportTest.class,
BarExporterTest.class,
ExportBosArchiveIT.class,
TestRunWithDocument.class,
TestDocument.class,
DuplicateCommandTest.class,
......
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