Fixed NullPointerExceptions and other bugs in the PublicPersonalProfile
git-svn-id: https://svn.libreccm.org/ccm/trunk@2111 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
ca7cc4db35
commit
f23c30d8f9
|
|
@ -91,7 +91,7 @@ public class PublicPersonalProfile
|
|||
|
||||
/**
|
||||
*
|
||||
* @return The owner of the profile.
|
||||
* @return The owner of the profile. May be {@code null} if no owner is assigned to the profile.
|
||||
*/
|
||||
public GenericPerson getOwner() {
|
||||
/*
|
||||
|
|
@ -110,8 +110,12 @@ public class PublicPersonalProfile
|
|||
* return (GenericPerson) DomainObjectFactory.newInstance(dobj);
|
||||
}
|
||||
*/
|
||||
return (GenericPerson) getPublicPersonalProfileBundle().getOwner().
|
||||
getPrimaryInstance();
|
||||
final GenericPersonBundle bundle = getPublicPersonalProfileBundle().getOwner();
|
||||
if (bundle == null) {
|
||||
return null;
|
||||
} else {
|
||||
return (GenericPerson) bundle.getPrimaryInstance();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import javax.servlet.ServletException;
|
|||
* Generates the extra XML output for a profile for the embedded view.
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
* @version $Id: PublicPersonalProfileExtraXmlGenerator.java 1466 2012-01-23
|
||||
* 12:59:16Z jensp $
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator {
|
||||
|
||||
|
|
@ -77,6 +76,7 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
|
|||
|
||||
final GenericPerson owner = profile.getOwner();
|
||||
|
||||
if (owner != null) {
|
||||
final PublicPersonalProfileXmlGenerator generator =
|
||||
new PublicPersonalProfileXmlGenerator(
|
||||
owner);
|
||||
|
|
@ -95,6 +95,7 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
|
|||
contacts.getContactType());
|
||||
cGenerator.generateXML(state, contactsElem, "");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
final Element profileContent = element.newChildElement(
|
||||
|
|
@ -118,15 +119,14 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
|
|||
navItems.addKeyFilter(showItem);
|
||||
navItems.next();
|
||||
|
||||
if (navItems.getNavItem().getGeneratorClass()
|
||||
!= null) {
|
||||
if (navItems.getNavItem().getGeneratorClass() != null) {
|
||||
try {
|
||||
Object generatorObj =
|
||||
Class.forName(navItems.getNavItem().
|
||||
getGeneratorClass()).getConstructor().
|
||||
newInstance();
|
||||
|
||||
if (generatorObj instanceof ContentGenerator) {
|
||||
if ((generatorObj instanceof ContentGenerator) && profile.getOwner() != null) {
|
||||
final ContentGenerator generator =
|
||||
(ContentGenerator) generatorObj;
|
||||
|
||||
|
|
@ -192,6 +192,9 @@ public class PublicPersonalProfileExtraXmlGenerator implements ExtraXMLGenerator
|
|||
|
||||
private String getProfileUrl(final PublicPersonalProfile profile) {
|
||||
final GenericPerson owner = profile.getOwner();
|
||||
if (owner == null) {
|
||||
return null;
|
||||
}
|
||||
final GenericPersonContactCollection contacts = owner.getContacts();
|
||||
|
||||
String homepage = null;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,11 @@ public class PublicPersonalProfileXmlUtil {
|
|||
profileElem.addAttribute("url", String.format("%s/%s",
|
||||
appUrl,
|
||||
profile.getProfileUrl()));
|
||||
if (profile.getOwner() == null) {
|
||||
profileElem.addAttribute("title", String.format("Profile %s", profile.getOID().toString()));
|
||||
} else {
|
||||
profileElem.addAttribute("title", profile.getOwner().getFullName());
|
||||
}
|
||||
|
||||
//Get the related links of the profile
|
||||
final DataCollection links =
|
||||
|
|
|
|||
|
|
@ -100,12 +100,15 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
|
|||
// final GenericPerson owner = profile.getOwner();
|
||||
// final GenericPerson alias = owner.getAlias();
|
||||
|
||||
if (owner != null) {
|
||||
ownerSelect.addOption(new Option(owner.getID().toString(), owner.getFullName()));
|
||||
}
|
||||
|
||||
if (!persons.isEmpty()) {
|
||||
final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
||||
while(persons.next()) {
|
||||
GenericPerson person = (GenericPerson) DomainObjectFactory.newInstance(persons.getDataObject());
|
||||
while (persons.next()) {
|
||||
GenericPerson person = (GenericPerson) DomainObjectFactory.newInstance(persons.
|
||||
getDataObject());
|
||||
if (processed.contains(person.getParent().getID())) {
|
||||
continue;
|
||||
} else {
|
||||
|
|
@ -147,7 +150,7 @@ public class PublicPersonalProfilePropertyForm extends BasicPageForm implements
|
|||
if ((profile != null) && getSaveCancelSection().getSaveButton().isSelected(state)) {
|
||||
|
||||
final String ownerId = (String) data.get(PublicPersonalProfileBundle.OWNER);
|
||||
if (!profile.getOwner().getID().equals(new BigDecimal(ownerId))) {
|
||||
if ((profile.getOwner() != null) && !profile.getOwner().getID().equals(new BigDecimal(ownerId))) {
|
||||
final GenericPerson newOwner = new GenericPerson(new BigDecimal(ownerId));
|
||||
profile.setOwner(newOwner);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -790,6 +790,10 @@ public class PublicPersonalProfilesServlet extends BaseApplicationServlet {
|
|||
private void generateProfileOwnerXml(final Element profileElem,
|
||||
final GenericPerson owner,
|
||||
final PageState state) {
|
||||
if (owner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Element profileOwnerElem = profileElem.newChildElement(
|
||||
"profileOwner");
|
||||
if ((owner.getSurname() != null)
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ public class PersonalProjects implements ContentGenerator {
|
|||
new LinkedList<SciProjectBundle>();
|
||||
final DataCollection collection = (DataCollection) person.
|
||||
getGenericPersonBundle().get("organizationalunits");
|
||||
collection.addEqualsFilter("version", "live");
|
||||
DomainObject obj;
|
||||
while (collection.next()) {
|
||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||
|
|
@ -115,6 +116,7 @@ public class PersonalProjects implements ContentGenerator {
|
|||
final String language) {
|
||||
final DataCollection collection = (DataCollection) alias.
|
||||
getGenericPersonBundle().get("organizationalunits");
|
||||
collection.addEqualsFilter("version", "live");
|
||||
DomainObject obj;
|
||||
while (collection.next()) {
|
||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ public class PersonalPublications implements ContentGenerator {
|
|||
new LinkedList<PublicationBundle>();
|
||||
//final List<BigDecimal> processed = new ArrayList<BigDecimal>();
|
||||
final DataCollection collection = (DataCollection) author.getGenericPersonBundle().get("publication");
|
||||
collection.addEqualsFilter("version", "live");
|
||||
DomainObject obj;
|
||||
while (collection.next()) {
|
||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||
|
|
@ -152,6 +153,7 @@ public class PersonalPublications implements ContentGenerator {
|
|||
final List<PublicationBundle> publications,
|
||||
final String language) {
|
||||
final DataCollection collection = (DataCollection) alias.getGenericPersonBundle().get("publication");
|
||||
collection.addEqualsFilter("version", "live");
|
||||
DomainObject obj;
|
||||
while (collection.next()) {
|
||||
obj = DomainObjectFactory.newInstance(collection.getDataObject());
|
||||
|
|
|
|||
Loading…
Reference in New Issue