Commit 16576f09 authored by Romain Bioteau's avatar Romain Bioteau

fix(resources) additional resources path in bar

parent b3c8139e
......@@ -45,7 +45,7 @@ radioButtonSingle=Single
areYouSureMessage=Are you sure you want to remove the document\: {0} ?
documentPropertySectionDescription=A document is an attachment containing information related to the process. Specify the documents attached to the process.
AddSimple=Add...
documentRepository=Document assets
documentRepository=Resources
documentType=Document
documentReferenceType=Document reference
returnType=Return type
......
......@@ -50,7 +50,7 @@ public class AdditionalResourcesFileEditingSupport extends EditingSupport {
Resource resource = (Resource) element;
if (value instanceof DocumentFileStore) {
DocumentFileStore document = (DocumentFileStore) value;
resource.setProjectPath(document.getName());
resource.setProjectPath("attachments/"+document.getName());
if (resource.getBarPath() == null || resource.getBarPath().isEmpty()) {
resource.setBarPath(document.getName());
}
......
......@@ -33,7 +33,7 @@ public class AdditionalResourceProjectPathValidator implements IValidator<Resour
if (Strings.isNullOrEmpty(projectPath)) {
return ValidationStatus.error(org.bonitasoft.studio.ui.i18n.Messages.required);
}
return repositoryAccessor.getRepositoryStore(DocumentRepositoryStore.class).getChild(projectPath, false) != null
return repositoryAccessor.getCurrentRepository().getProject().getFile(projectPath).exists()
? ValidationStatus.ok()
: ValidationStatus.error(Messages.unknownResource);
}
......
......@@ -31,7 +31,7 @@ import com.google.common.io.Files;
public class AdditionalResourcesBARResourcesProvider implements BARResourcesProvider {
private static final String CONF_PREFIX = "conf/";
private static final String MISC_PREFIX = "misc/";
@Override
public void addResourcesForConfiguration(BusinessArchiveBuilder builder,
......@@ -43,10 +43,10 @@ public class AdditionalResourcesBARResourcesProvider implements BARResourcesProv
}
private void addResourceInBar(BusinessArchiveBuilder builder, Resource resource) throws Exception {
IProject project = RepositoryManager.getInstance().getCurrentRepository().getProject();
if(resource.getProjectPath() == null || resource.getProjectPath().isEmpty()) {
throw new Exception("projectPath cannot be null for an additional resource.");
}
IProject project = RepositoryManager.getInstance().getCurrentRepository().getProject();
File file = project.getFile(resource.getProjectPath()).getLocation().toFile();
if(!file.exists()) {
throw new FileNotFoundException(file.getAbsolutePath());
......@@ -62,7 +62,7 @@ public class AdditionalResourcesBARResourcesProvider implements BARResourcesProv
barPath = barPath.trim().substring(1);
}
//Avoid resource name conflict using conf/ folder in bar.
builder.addExternalResource(new BarResource(CONF_PREFIX + barPath, Files.toByteArray(file)));
builder.addExternalResource(new BarResource(MISC_PREFIX + barPath, Files.toByteArray(file)));
}
}
......@@ -22,7 +22,7 @@
autoinsert="true"
context="groovy"
enabled="true"
>def additionalResources = apiAccessor.processAPI.getProcessResources(processDefinitionId, 'resources/conf/*')</template>
>def additionalResources = apiAccessor.processAPI.getProcessResources(processDefinitionId, 'resources/misc/.*')</template>
</templates>
......@@ -161,6 +161,6 @@ public class ExportBarIT {
assertThat(businessArchive.getResource("resources/customPages/custompage_instantiationForm.zip")).isNotEmpty();
assertThat(businessArchive.getResource("resources/customPages/custompage_overviewPage.zip")).isNotEmpty();
assertThat(businessArchive.getResource("resources/customPages/custompage_stepForm.zip")).isNotEmpty();
assertThat(businessArchive.getResource("resources/conf/config.properties")).isNotEmpty();
assertThat(businessArchive.getResource("resources/misc/config.properties")).isNotEmpty();
}
}
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