Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ArtifactResponse get(String projectId, String refId, String id, Map<Strin
NodeService nodeService = getNodeService(projectId);
ElementJson elementJson = getElement(nodeService, projectId, refId, id, params);

ArtifactJson artifact = getExistingArtifact(ArtifactJson.getArtifacts(elementJson), params);
ArtifactJson artifact = getExistingArtifact(ArtifactJson.getArtifacts(elementJson), params, elementJson);
byte[] data = artifactStorage.get(artifact.getLocation(), elementJson, artifact.getMimeType());
ArtifactResponse response = new ArtifactResponse();
response.setData(data);
Expand Down Expand Up @@ -99,7 +99,7 @@ public ElementsResponse disassociate(String projectId, String refId, String id,
ElementJson elementJson = getElement(nodeService, projectId, refId, id, params);

List<ArtifactJson> artifacts = ArtifactJson.getArtifacts(elementJson);
ArtifactJson artifact = getExistingArtifact(artifacts, params);
ArtifactJson artifact = getExistingArtifact(artifacts, params, elementJson);
artifacts.remove(artifact);
ArtifactJson.setArtifacts(elementJson, artifacts);
ElementsRequest elementsRequest = new ElementsRequest();
Expand All @@ -124,7 +124,7 @@ private ElementJson attachOrUpdateArtifact(ElementJson elementJson, String artif
List<ArtifactJson> artifacts = ArtifactJson.getArtifacts(elementJson);
ArtifactJson artifact;
try {
artifact = getExistingArtifact(artifacts, mimeType, null);
artifact = getExistingArtifact(artifacts, mimeType, null, elementJson);
} catch(NotFoundException ex) {
artifact = new ArtifactJson();
artifacts.add(artifact);
Expand All @@ -140,11 +140,11 @@ private ElementJson attachOrUpdateArtifact(ElementJson elementJson, String artif
return elementJson;
}

private ArtifactJson getExistingArtifact(List<ArtifactJson> artifacts, Map<String, String> params) {
return getExistingArtifact(artifacts, params.get(ArtifactConstants.MIMETYPE_PARAM), params.get(ArtifactConstants.EXTENSION_PARAM));
private ArtifactJson getExistingArtifact(List<ArtifactJson> artifacts, Map<String, String> params, ElementJson element) {
return getExistingArtifact(artifacts, params.get(ArtifactConstants.MIMETYPE_PARAM), params.get(ArtifactConstants.EXTENSION_PARAM), element);
}

private ArtifactJson getExistingArtifact(List<ArtifactJson> artifacts, String mimeType, String extension) {
private ArtifactJson getExistingArtifact(List<ArtifactJson> artifacts, String mimeType, String extension, ElementJson element) {
if(mimeType == null && extension == null) {
throw new BadRequestException("Missing mimetype or extension");
}
Expand All @@ -155,7 +155,7 @@ private ArtifactJson getExistingArtifact(List<ArtifactJson> artifacts, String mi
if(existing.isPresent()) {
return existing.get();
}
throw new NotFoundException("Artifact not found");
throw new NotFoundException(element);
}

private String getFileExtension(MultipartFile file) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=4.0.9
version=4.0.10
group=org.openmbee.mms

springBootVersion=2.6.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class LdapSecurityConfig {
@Value("${ldap.provider.base:#{null}}")
private String providerBase;

@Value("${ldap.user.dn.pattern:uid={0}}")
private String userDnPattern;
@Value("#{'${ldap.user.dn.pattern:uid={0}}'.split(';')}")
private List<String> userDnPattern;

@Value("${ldap.user.attributes.username:uid}")
private String userAttributesUsername;
Expand Down Expand Up @@ -99,7 +99,8 @@ public void configureLdapAuth(AuthenticationManagerBuilder auth,
We redefine our own LdapAuthoritiesPopulator which need ContextSource().
We need to delegate the creation of the contextSource out of the builder-configuration.
*/
auth.ldapAuthentication().userDnPatterns(userDnPattern).groupSearchBase(groupSearchBase)
String[] a = userDnPattern.toArray(new String[0]);
auth.ldapAuthentication().userDnPatterns(a).groupSearchBase(groupSearchBase)
.groupRoleAttribute(groupRoleAttribute).groupSearchFilter(groupSearchFilter)
.rolePrefix("")
.ldapAuthoritiesPopulator(ldapAuthoritiesPopulator)
Expand Down
2 changes: 1 addition & 1 deletion permissions/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Permissions acceptable values

{
"users / groups": {
"action": "ADD / REMOVE",
"action": "MODIFY / REPLACE / REMOVE",
"permissions": [
{
"name": "USERNAME",
Expand Down