diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionContactsModel.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionContactsModel.java
index fbbd055..a370f34 100644
--- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionContactsModel.java
+++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionContactsModel.java
@@ -1,6 +1,7 @@
package org.scientificcms.contenttypes.sciproject.ui;
-import org.librecms.assets.ContactableEntity;
+import org.librecms.assets.Organization;
+import org.librecms.assets.Person;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,8 +40,10 @@ public class SciProjectDescriptionContactsModel {
this.contacts = new ArrayList<>(contacts);
}
- public String getContactableType() {
- return ContactableEntity.class.getName();
+ public String getContactableTypes() {
+ return String.join(
+ ",", Person.class.getName(), Organization.class.getName()
+ );
}
public String getBaseUrl() {
diff --git a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStep.java b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStep.java
index bce5017..1b0d502 100644
--- a/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStep.java
+++ b/sci-types-project/src/main/java/org/scientificcms/contenttypes/sciproject/ui/SciProjectDescriptionStep.java
@@ -18,11 +18,14 @@
*/
package org.scientificcms.contenttypes.sciproject.ui;
+import org.libreccm.api.Identifier;
+import org.libreccm.api.IdentifierParser;
import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.ui.BaseUrl;
import org.librecms.assets.ContactableEntity;
import org.librecms.assets.Person;
+import org.librecms.contentsection.Asset;
import org.librecms.contentsection.AssetRepository;
import org.librecms.contentsection.ContentItemRepository;
import org.librecms.ui.contentsections.ContentSectionNotFoundException;
@@ -83,8 +86,8 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@Inject
private AssetRepository assetRepo;
-
- @Inject
+
+ @Inject
private BaseUrl baseUrl;
@Inject
@@ -99,9 +102,12 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
@Inject
private GlobalizationHelper globalizationHelper;
+ @Inject
+ private IdentifierParser identifierParser;
+
@Context
private HttpServletRequest request;
-
+
@Inject
private ItemPermissionChecker itemPermissionChecker;
@@ -362,15 +368,34 @@ public class SciProjectDescriptionStep extends AbstractMvcAuthoringStep {
}
if (itemPermissionChecker.canEditItem(getProject())) {
- final Optional result = assetRepo
- .findByUuidAndType(contactableUuid, ContactableEntity.class);
+ final Optional result;
+ final Identifier identifier = identifierParser.parseIdentifier(
+ contactableUuid
+ );
+ switch (identifier.getType()) {
+ case ID:
+ result = assetRepo.findById(
+ Long.parseLong(identifier.getIdentifier())
+ );
+ break;
+ case UUID:
+ result = assetRepo.findByUuid(
+ identifier.getIdentifier()
+ );
+ break;
+ default:
+ models.put("contactableNotFound", contactableUuid);
+ return showStep(sectionIdentifier, documentPath);
+ }
- if (!result.isPresent()) {
+ if (!result.isPresent()
+ || !(result.get() instanceof ContactableEntity)) {
models.put("contactableNotFound", contactableUuid);
return showStep(sectionIdentifier, documentPath);
}
- final ContactableEntity contactable = result.get();
+ final ContactableEntity contactable = (ContactableEntity) result
+ .get();
projectManager.addContact(contactable, getProject(), type);
return buildRedirectPathForStep();
diff --git a/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml b/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml
index ac185fe..5b0737a 100644
--- a/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml
+++ b/sci-types-project/src/main/resources/WEB-INF/views/org/scientificcms/contenttypes/sciproject/ui/sciproject-description.xhtml
@@ -13,6 +13,12 @@
#{SciProjectMessageBundle['description_step.header']}
+
+
+ #{SciProjectMessageBundle.getMessage('description_step.errors.contactable_not_found', [contactableNotFound])}
+
+
+
#{SciProjectMessageBundle['contacts.none']}
-
-
@@ -153,10 +157,9 @@
diff --git a/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle.properties b/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle.properties
index 1fc73ae..0c0df04 100644
--- a/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle.properties
+++ b/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle.properties
@@ -171,3 +171,4 @@ authoringsteps.projectdescription.description=Detailed description of the resear
authoringsteps.projectdescription.label=Description
memberships.none=No memberships assigned yet.
contacts.none=No contacts assigned yet.
+description_step.errors.contactable_not_found=Selected contactable entity {0} not found.
diff --git a/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties b/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties
index 8e54560..53f06d7 100644
--- a/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties
+++ b/sci-types-project/src/main/resources/org/scientificcms/contenttypes/sciproject/ui/SciProjectBundle_de.properties
@@ -171,3 +171,4 @@ authoringsteps.projectdescription.description=Ausf\u00fchrliche Beschreibung des
authoringsteps.projectdescription.label=Beschreibung
memberships.none=Es wurden noch keine Mitglieder hinzugef\u00fcgt.
contacts.none=Es wurden noch keine Kontakte hinzugef\u00fcgt.
+description_step.errors.contactable_not_found=Die als Kontakt ausgew\u00e4hlte Entity {0} wurde nicht gefunden.