- adds new export content for import to tests resources
- exchanges Jackson back- and managed-reference annotations with identityInfo, ignore and identityReference annotations 
- adds necessary ObjectIdGenerator and ObjectIdResolver implementations
- does not yet implement the generateId-Method of every ObjectIdResolver

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4640 8810af33-2d31-482b-a856-94f89814c4df
tosmers 2017-03-23 18:48:52 +00:00
parent 129f204f79
commit 834952bc85
43 changed files with 48481 additions and 47565 deletions

View File

@ -19,6 +19,8 @@
package org.libreccm.categorization; package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
@ -96,6 +98,8 @@ import javax.persistence.FetchType;
+ "WHERE c.category = :category " + "WHERE c.category = :category "
+ "AND c.index = TRUE") + "AND c.index = TRUE")
}) })
@JsonIdentityInfo(generator = CategorizationIdGenerator.class,
property = "customCatId")
public class Categorization implements Serializable, Relation, Portable { public class Categorization implements Serializable, Relation, Portable {
private static final long serialVersionUID = 201504301320L; private static final long serialVersionUID = 201504301320L;
@ -113,7 +117,7 @@ public class Categorization implements Serializable, Relation, Portable {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "CATEGORY_ID") @JoinColumn(name = "CATEGORY_ID")
@JsonBackReference(value = "category-categorization") @JsonIdentityReference(alwaysAsId = true)
private Category category; private Category category;
/** /**
@ -121,7 +125,7 @@ public class Categorization implements Serializable, Relation, Portable {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "OBJECT_ID") @JoinColumn(name = "OBJECT_ID")
@JsonBackReference(value = "object-categorization") @JsonIdentityReference(alwaysAsId = true)
private CcmObject categorizedObject; private CcmObject categorizedObject;
/** /**

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class CategorizationIdGenerator extends ObjectIdGenerator<String> {
@Override
public Class<?> getScope() {
return Categorization.class;
}
@Override
public boolean canUseFor(ObjectIdGenerator<?> gen) {
return gen instanceof CategorizationIdGenerator;
}
@Override
public ObjectIdGenerator<String> forScope(Class<?> scope) {
return this;
}
@Override
public ObjectIdGenerator<String> newForSerialization(Object context) {
return this;
}
@Override
public IdKey key(Object key) {
if (key == null) {
return null;
}
return new IdKey(Categorization.class, Categorization.class, key);
}
@Override
public String generateId(Object forPojo) {
if (!(forPojo instanceof Categorization)) {
throw new IllegalArgumentException(
"Only Categorization instances are supported.");
}
final Categorization categorization = (Categorization) forPojo;
return String.format("{%s}{%s}",
categorization.getCategory().getUuid(),
categorization.getCategorizedObject().getUuid());
}
}

View File

@ -18,23 +18,16 @@
*/ */
package org.libreccm.categorization; package org.libreccm.categorization;
import static org.libreccm.categorization.CategorizationConstants.*; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import static org.libreccm.core.CoreConstants.*; import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import org.libreccm.security.RecursivePermissions; import org.libreccm.security.RecursivePermissions;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.persistence.AssociationOverride; import javax.persistence.AssociationOverride;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
@ -54,6 +47,14 @@ import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import static org.libreccm.categorization.CategorizationConstants.CAT_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/** /**
* The category entity represents a single category. Each category is part of a * The category entity represents a single category. Each category is part of a
@ -138,6 +139,9 @@ import javax.xml.bind.annotation.XmlRootElement;
) )
}) })
@XmlRootElement(name = "category", namespace = CAT_XML_NS) @XmlRootElement(name = "category", namespace = CAT_XML_NS)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = CategoryIdResolver.class,
property = "uuid")
public class Category extends CcmObject implements Serializable, Portable { public class Category extends CcmObject implements Serializable, Portable {
private static final long serialVersionUID = -7250208963391878547L; private static final long serialVersionUID = -7250208963391878547L;
@ -218,7 +222,7 @@ public class Category extends CcmObject implements Serializable, Portable {
@RecursivePermissions @RecursivePermissions
@OneToMany(mappedBy = "category", fetch = FetchType.LAZY) @OneToMany(mappedBy = "category", fetch = FetchType.LAZY)
@XmlElementWrapper(name = "objects", namespace = CAT_XML_NS) @XmlElementWrapper(name = "objects", namespace = CAT_XML_NS)
@JsonManagedReference(value = "category-categorization") @JsonIgnore
private List<Categorization> objects; private List<Categorization> objects;
/** /**
@ -228,7 +232,7 @@ public class Category extends CcmObject implements Serializable, Portable {
@OneToMany(mappedBy = "parentCategory", fetch = FetchType.LAZY) @OneToMany(mappedBy = "parentCategory", fetch = FetchType.LAZY)
@XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS) @XmlElementWrapper(name = "subcategories", namespace = CAT_XML_NS)
@XmlElement(name = "category") @XmlElement(name = "category")
@JsonManagedReference(value = "subcategory-parentcategory") @JsonIgnore
private List<Category> subCategories; private List<Category> subCategories;
/** /**
@ -237,7 +241,7 @@ public class Category extends CcmObject implements Serializable, Portable {
*/ */
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PARENT_CATEGORY_ID") @JoinColumn(name = "PARENT_CATEGORY_ID")
@JsonBackReference(value = "subcategory-parentcategory") @JsonIdentityReference(alwaysAsId = true)
private Category parentCategory; private Category parentCategory;
/** /**

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.categorization;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
@RequestScoped
public class CategoryIdResolver implements ObjectIdResolver {
@Inject
private CategoryRepository categoryRepository;
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey,
Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(Object context) {
return new CategoryIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof CategoryIdResolver;
}
}

View File

@ -18,8 +18,9 @@
*/ */
package org.libreccm.core; package org.libreccm.core;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.IndexedEmbedded;
@ -83,6 +84,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
//persistence system we can't yet refactor it to make PMD happy. Also I think //persistence system we can't yet refactor it to make PMD happy. Also I think
//this is a false warning. //this is a false warning.
@SuppressWarnings("PMD.TooManyMethods") @SuppressWarnings("PMD.TooManyMethods")
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = CcmObjectIdResolver.class,
property = "uuid")
public class CcmObject implements Identifiable, Serializable { public class CcmObject implements Identifiable, Serializable {
private static final long serialVersionUID = 201504261329L; private static final long serialVersionUID = 201504261329L;
@ -122,7 +126,7 @@ public class CcmObject implements Identifiable, Serializable {
@IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"}) @IndexedEmbedded(includePaths = {"grantedPrivilege", "grantee.name"})
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS) @XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
@XmlElement(name = "permission", namespace = CORE_XML_NS) @XmlElement(name = "permission", namespace = CORE_XML_NS)
@JsonManagedReference(value = "object-permission") @JsonIgnore
private List<Permission> permissions; private List<Permission> permissions;
/** /**
@ -131,7 +135,7 @@ public class CcmObject implements Identifiable, Serializable {
@OneToMany(mappedBy = "categorizedObject") @OneToMany(mappedBy = "categorizedObject")
@XmlElementWrapper(name = "categories", namespace = CORE_XML_NS) @XmlElementWrapper(name = "categories", namespace = CORE_XML_NS)
@XmlElement(name = "category", namespace = CORE_XML_NS) @XmlElement(name = "category", namespace = CORE_XML_NS)
@JsonManagedReference(value = "object-categorization") @JsonIgnore
private List<Categorization> categories; private List<Categorization> categories;
public CcmObject() { public CcmObject() {

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.core;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class CcmObjectIdResolver implements ObjectIdResolver {
@Override
public void bindItem(ObjectIdGenerator.IdKey idKey,
Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(Object context) {
return new CcmObjectIdResolver();
}
@Override
public boolean canUseFor(ObjectIdResolver resolverType) {
return resolverType instanceof CcmObjectIdResolver;
}
}

View File

@ -18,7 +18,9 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import javax.persistence.Entity; import javax.persistence.Entity;
@ -33,7 +35,6 @@ import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -89,6 +90,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
}) })
}) })
@XmlRootElement(name = "user-group", namespace = CORE_XML_NS) @XmlRootElement(name = "user-group", namespace = CORE_XML_NS)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = GroupIdResolver.class,
property = "name")
public class Group extends Party implements Serializable, Portable { public class Group extends Party implements Serializable, Portable {
private static final long serialVersionUID = -4800759206452780739L; private static final long serialVersionUID = -4800759206452780739L;
@ -100,7 +104,7 @@ public class Group extends Party implements Serializable, Portable {
@OneToMany(mappedBy = "group") @OneToMany(mappedBy = "group")
@XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS) @XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "group-membership", namespace = CORE_XML_NS) @XmlElement(name = "group-membership", namespace = CORE_XML_NS)
@JsonManagedReference(value = "group-groupmembership") @JsonIgnore
private Set<GroupMembership> memberships = new HashSet<>(); private Set<GroupMembership> memberships = new HashSet<>();
public Group() { public Group() {

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class GroupIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new GroupIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver objectIdResolver) {
return objectIdResolver instanceof GroupIdResolver;
}
}

View File

@ -44,6 +44,7 @@ public class GroupMarshaller extends AbstractMarshaller<Group> {
@Override @Override
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
protected void insertIntoDb(Group portableObject) { protected void insertIntoDb(Group portableObject) {
portableObject.setPartyId(portableObject.getPartyId() * -1);
groupRepository.save(portableObject); groupRepository.save(portableObject);
} }
} }

View File

@ -18,8 +18,8 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import javax.persistence.Column; import javax.persistence.Column;
@ -54,6 +54,8 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
query = "SELECT m FROM GroupMembership m " query = "SELECT m FROM GroupMembership m "
+ "WHERE m.member = :member AND m.group = :group")}) + "WHERE m.member = :member AND m.group = :group")})
@XmlRootElement(name = "group-membership", namespace = CORE_XML_NS) @XmlRootElement(name = "group-membership", namespace = CORE_XML_NS)
@JsonIdentityInfo(generator = GroupMembershipIdGenerator.class,
property = "customMemId")
public class GroupMembership implements Serializable, Portable { public class GroupMembership implements Serializable, Portable {
private static final long serialVersionUID = 83192968306850665L; private static final long serialVersionUID = 83192968306850665L;
@ -67,13 +69,13 @@ public class GroupMembership implements Serializable, Portable {
@ManyToOne @ManyToOne
@JoinColumn(name = "GROUP_ID") @JoinColumn(name = "GROUP_ID")
@XmlTransient @XmlTransient
@JsonBackReference(value = "group-groupmembership") @JsonIdentityReference(alwaysAsId = true)
private Group group; private Group group;
@ManyToOne @ManyToOne
@JoinColumn(name = "MEMBER_ID") @JoinColumn(name = "MEMBER_ID")
@XmlTransient @XmlTransient
@JsonBackReference(value = "user-groupmembership") @JsonIdentityReference(alwaysAsId = true)
private User member; private User member;
public long getMembershipId() { public long getMembershipId() {

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class GroupMembershipIdGenerator extends ObjectIdGenerator<String> {
@Override
public Class<?> getScope() {
return GroupMembership.class;
}
@Override
public boolean canUseFor(final ObjectIdGenerator<?> gen) {
return gen instanceof GroupMembershipIdGenerator;
}
@Override
public ObjectIdGenerator<String> forScope(final Class<?> scope) {
return this;
}
@Override
public ObjectIdGenerator<String> newForSerialization(final Object context) {
return this;
}
@Override
public IdKey key(final Object key) {
if (key == null) {
return null;
}
return new IdKey(GroupMembership.class, GroupMembership.class, key);
}
@Override
public String generateId(final Object forPojo) {
if (!(forPojo instanceof GroupMembership)) {
throw new IllegalArgumentException(
"Only GroupMembership instances are supported.");
}
final GroupMembership membership = (GroupMembership) forPojo;
return String.format("{%s}{%s}",
membership.getGroup().getName(),
membership.getMember().getName());
}
}

View File

@ -45,10 +45,7 @@ public class GroupMembershipMarshaller extends AbstractMarshaller<GroupMembershi
@Override @Override
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
protected void insertIntoDb(GroupMembership portableObject) { protected void insertIntoDb(GroupMembership portableObject) {
if (portableObject.getMembershipId() == 0) { portableObject.setMembershipId(portableObject.getMembershipId() * -1);
entityManager.persist(portableObject);
} else {
entityManager.merge(portableObject); entityManager.merge(portableObject);
} }
}
} }

View File

@ -18,7 +18,9 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@ -38,7 +40,6 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -73,6 +74,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
attributeNodes = @NamedAttributeNode( attributeNodes = @NamedAttributeNode(
value = "roleMemberships")) value = "roleMemberships"))
}) })
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = PartyIdResolver.class,
property = "name")
public class Party implements Serializable { public class Party implements Serializable {
private static final long serialVersionUID = 3319997992281332204L; private static final long serialVersionUID = 3319997992281332204L;
@ -97,7 +101,7 @@ public class Party implements Serializable {
@OneToMany(mappedBy = "member") @OneToMany(mappedBy = "member")
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS) @XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "role-membership", namespace = CORE_XML_NS) @XmlElement(name = "role-membership", namespace = CORE_XML_NS)
@JsonManagedReference(value = "party-rolemembership") @JsonIgnore
private Set<RoleMembership> roleMemberships = new HashSet<>(); private Set<RoleMembership> roleMemberships = new HashSet<>();
protected Party() { protected Party() {

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class PartyIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new PartyIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof PartyIdResolver;
}
}

View File

@ -18,7 +18,8 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.hibernate.search.annotations.ContainedIn; import org.hibernate.search.annotations.ContainedIn;
import org.hibernate.search.annotations.Field; import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.IndexedEmbedded; import org.hibernate.search.annotations.IndexedEmbedded;
@ -34,6 +35,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
@ -41,7 +43,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@ -49,8 +50,6 @@ import java.util.Objects;
import static org.libreccm.core.CoreConstants.CORE_XML_NS; import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; import static org.libreccm.core.CoreConstants.DB_SCHEMA;
import javax.persistence.OneToOne;
/** /**
* A permission grants a privilege on an object or system wide to {@link Role}. * A permission grants a privilege on an object or system wide to {@link Role}.
* *
@ -100,6 +99,9 @@ import javax.persistence.OneToOne;
}) })
@XmlRootElement(name = "permission", namespace = CORE_XML_NS) @XmlRootElement(name = "permission", namespace = CORE_XML_NS)
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@JsonIdentityInfo(generator = PermissionIdGenerator.class,
resolver = PermissionIdResolver.class,
property = "customPermId")
public class Permission implements Serializable, Portable { public class Permission implements Serializable, Portable {
private static final long serialVersionUID = -5178045844045517958L; private static final long serialVersionUID = -5178045844045517958L;
@ -127,7 +129,7 @@ public class Permission implements Serializable, Portable {
@ManyToOne @ManyToOne
@JoinColumn(name = "OBJECT_ID") @JoinColumn(name = "OBJECT_ID")
@ContainedIn @ContainedIn
@JsonBackReference(value = "object-permission") @JsonIdentityReference(alwaysAsId = true)
private CcmObject object; private CcmObject object;
/** /**
@ -136,7 +138,7 @@ public class Permission implements Serializable, Portable {
@ManyToOne @ManyToOne
@IndexedEmbedded @IndexedEmbedded
@JoinColumn(name = "GRANTEE_ID") @JoinColumn(name = "GRANTEE_ID")
@JsonBackReference(value = "role-permission") @JsonIdentityReference(alwaysAsId = true)
private Role grantee; private Role grantee;
/** /**

View File

@ -0,0 +1,83 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class PermissionIdGenerator extends ObjectIdGenerator<String> {
@Override
public Class<?> getScope() {
return Permission.class;
}
@Override
public boolean canUseFor(final ObjectIdGenerator<?> gen) {
return gen instanceof PermissionIdGenerator;
}
@Override
public ObjectIdGenerator<String> forScope(final Class<?> scope) {
return this;
}
@Override
public ObjectIdGenerator<String> newForSerialization(final Object context) {
return this;
}
@Override
public IdKey key(final Object key) {
if (key == null) {
return null;
}
return new IdKey(Permission.class, Permission.class, key);
}
@Override
public String generateId(final Object forPojo) {
if (!(forPojo instanceof Permission)) {
throw new IllegalArgumentException(
"Only Permission instances are supported.");
}
final Permission permission = (Permission) forPojo;
String id = permission.getGrantedPrivilege() +
permission.getPermissionId();
boolean a = false, b = false;
if (permission.getObject() != null) {
id += permission.getObject().getUuid();
a = true;
}
if (permission.getGrantee() != null) {
id += permission.getGrantee().getName();
b = true;
}
// if (!(a || b)) {
// throw new IllegalStateException();
// }
return id;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class PermissionIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new PermissionIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof PermissionIdResolver;
}
}

View File

@ -18,7 +18,10 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.hibernate.search.annotations.Field;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
@ -46,7 +49,6 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -55,8 +57,6 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import org.hibernate.search.annotations.Field;
import static org.libreccm.core.CoreConstants.CORE_XML_NS; import static org.libreccm.core.CoreConstants.CORE_XML_NS;
import static org.libreccm.core.CoreConstants.DB_SCHEMA; import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@ -134,6 +134,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@XmlRootElement(name = "role", namespace = CORE_XML_NS) @XmlRootElement(name = "role", namespace = CORE_XML_NS)
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings({"PMD.ShortClassName", "PMD.TooManyMethods"}) @SuppressWarnings({"PMD.ShortClassName", "PMD.TooManyMethods"})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = RoleIdResolver.class,
property = "name")
public class Role implements Serializable, Portable { public class Role implements Serializable, Portable {
private static final long serialVersionUID = -7121296514181469687L; private static final long serialVersionUID = -7121296514181469687L;
@ -160,28 +163,6 @@ public class Role implements Serializable, Portable {
@XmlElement(name = "name", namespace = CORE_XML_NS) @XmlElement(name = "name", namespace = CORE_XML_NS)
private String name; private String name;
/**
* All memberships of the roles.
*/
@OneToMany(mappedBy = "role")
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
@JsonManagedReference(value = "role-rolemembership")
private Set<RoleMembership> memberships = new HashSet<>();
/**
* Permissions granted to the role.
*/
@OneToMany(mappedBy = "grantee")
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
@XmlElement(name = "permission", namespace = CORE_XML_NS)
@JsonManagedReference(value = "role-permission")
private List<Permission> permissions = new ArrayList<>();
@OneToMany(mappedBy = "role")
@JsonManagedReference(value = "role-taskassignment")
private List<TaskAssignment> assignedTasks = new ArrayList<>();
/** /**
* An optional description for a role. * An optional description for a role.
*/ */
@ -196,6 +177,28 @@ public class Role implements Serializable, Portable {
@XmlElement(name = "description", namespace = CORE_XML_NS) @XmlElement(name = "description", namespace = CORE_XML_NS)
private LocalizedString description = new LocalizedString(); private LocalizedString description = new LocalizedString();
/**
* All memberships of the roles.
*/
@OneToMany(mappedBy = "role")
@XmlElementWrapper(name = "role-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "role-membership", namespace = CORE_XML_NS)
@JsonIgnore
private Set<RoleMembership> memberships = new HashSet<>();
/**
* Permissions granted to the role.
*/
@OneToMany(mappedBy = "grantee")
@XmlElementWrapper(name = "permissions", namespace = CORE_XML_NS)
@XmlElement(name = "permission", namespace = CORE_XML_NS)
@JsonIgnore
private List<Permission> permissions = new ArrayList<>();
@OneToMany(mappedBy = "role")
@JsonIgnore
private List<TaskAssignment> assignedTasks = new ArrayList<>();
public Role() { public Role() {
super(); super();
} }

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class RoleIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new RoleIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof RoleIdResolver;
}
}

View File

@ -18,8 +18,8 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import javax.persistence.Column; import javax.persistence.Column;
@ -55,6 +55,8 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
+ "WHERE m.member = :member AND m.role = :role") + "WHERE m.member = :member AND m.role = :role")
}) })
@XmlRootElement(name = "role-membership", namespace = CORE_XML_NS) @XmlRootElement(name = "role-membership", namespace = CORE_XML_NS)
@JsonIdentityInfo(generator = RoleMembershipIdGenerator.class,
property = "customMemId")
public class RoleMembership implements Serializable, Portable { public class RoleMembership implements Serializable, Portable {
private static final long serialVersionUID = -3049727720697964793L; private static final long serialVersionUID = -3049727720697964793L;
@ -68,13 +70,13 @@ public class RoleMembership implements Serializable, Portable {
@ManyToOne @ManyToOne
@JoinColumn(name = "ROLE_ID") @JoinColumn(name = "ROLE_ID")
@XmlTransient @XmlTransient
@JsonBackReference(value = "role-rolemembership") @JsonIdentityReference(alwaysAsId = true)
private Role role; private Role role;
@ManyToOne @ManyToOne
@JoinColumn(name = "MEMBER_ID") @JoinColumn(name = "MEMBER_ID")
@XmlTransient @XmlTransient
@JsonBackReference(value = "party-rolemembership") @JsonIdentityReference(alwaysAsId = true)
private Party member; private Party member;
public long getMembershipId() { public long getMembershipId() {

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class RoleMembershipIdGenerator extends ObjectIdGenerator<String> {
@Override
public Class<?> getScope() {
return RoleMembership.class;
}
@Override
public boolean canUseFor(final ObjectIdGenerator<?> gen) {
return gen instanceof RoleMembershipIdGenerator;
}
@Override
public ObjectIdGenerator<String> forScope(final Class<?> scope) {
return this;
}
@Override
public ObjectIdGenerator<String> newForSerialization(final Object context) {
return this;
}
@Override
public IdKey key(final Object key) {
if (key == null) {
return null;
}
return new IdKey(RoleMembership.class, RoleMembership.class, key);
}
@Override
public String generateId(final Object forPojo) {
if (!(forPojo instanceof RoleMembership)) {
throw new IllegalArgumentException(
"Only RoleMembership instances are supported.");
}
final RoleMembership membership = (RoleMembership) forPojo;
return String.format("{%s}{%s}",
membership.getRole().getName(),
membership.getMember().getName());
}
}

View File

@ -59,9 +59,6 @@ public class RoleMembershipMarshaller extends AbstractMarshaller<RoleMembership>
final RoleMembership roleMembership = save(portableObject); final RoleMembership roleMembership = save(portableObject);
LOGGER.debug("Saved RoleMembership with id {}.", LOGGER.debug("Saved RoleMembership with id {}.",
roleMembership.getMembershipId()); roleMembership.getMembershipId());
// } else {
// entityManager.merge(portableObject);
// }
} }
@Transactional(Transactional.TxType.REQUIRES_NEW) @Transactional(Transactional.TxType.REQUIRES_NEW)

View File

@ -18,7 +18,10 @@
*/ */
package org.libreccm.security; package org.libreccm.security;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.EmailAddress; import org.libreccm.core.EmailAddress;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
@ -46,7 +49,6 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -126,6 +128,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
//Supressing a few warnings from PMD because they misleading here. //Supressing a few warnings from PMD because they misleading here.
//User is perfectly fine class name, and the complexity is not to high... //User is perfectly fine class name, and the complexity is not to high...
@SuppressWarnings({"PMD.ShortClassName", "PMD.LongVariable"}) @SuppressWarnings({"PMD.ShortClassName", "PMD.LongVariable"})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = UserIdResolver.class,
property = "name")
public class User extends Party implements Serializable, Portable { public class User extends Party implements Serializable, Portable {
private static final long serialVersionUID = 4035223413596611393L; private static final long serialVersionUID = 4035223413596611393L;
@ -203,7 +208,7 @@ public class User extends Party implements Serializable, Portable {
@OneToMany(mappedBy = "member") @OneToMany(mappedBy = "member")
@XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS) @XmlElementWrapper(name = "group-memberships", namespace = CORE_XML_NS)
@XmlElement(name = "group-membership", namespace = CORE_XML_NS) @XmlElement(name = "group-membership", namespace = CORE_XML_NS)
@JsonManagedReference(value = "user-groupmembership") @JsonIgnore
private Set<GroupMembership> groupMemberships = new HashSet<>(); private Set<GroupMembership> groupMemberships = new HashSet<>();
protected User() { protected User() {

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.security;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class UserIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new UserIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof UserIdResolver;
}
}

View File

@ -18,8 +18,9 @@
*/ */
package org.libreccm.workflow; package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import org.libreccm.security.User; import org.libreccm.security.User;
@ -81,6 +82,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
@SuppressWarnings({"PMD.CyclomaticComplexity", @SuppressWarnings({"PMD.CyclomaticComplexity",
"PMD.StdCyclomaticComplexity", "PMD.StdCyclomaticComplexity",
"PMD.ModifiedCyclomaticComplexity"}) "PMD.ModifiedCyclomaticComplexity"})
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = AssignableTaskIdResolver.class,
property = "uuid")
public class AssignableTask extends Task implements Serializable, Portable { public class AssignableTask extends Task implements Serializable, Portable {
private static final long serialVersionUID = 4188064584389893019L; private static final long serialVersionUID = 4188064584389893019L;
@ -130,7 +134,7 @@ public class AssignableTask extends Task implements Serializable, Portable {
* The roles to which task is assigned. * The roles to which task is assigned.
*/ */
@OneToMany(mappedBy = "task") @OneToMany(mappedBy = "task")
@JsonManagedReference(value = "assignabletask-taskassignment") @JsonIgnore
private List<TaskAssignment> assignments; private List<TaskAssignment> assignments;
public AssignableTask() { public AssignableTask() {

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class AssignableTaskIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new AssignableTaskIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof AssignableTaskIdResolver;
}
}

View File

@ -18,8 +18,9 @@
*/ */
package org.libreccm.workflow; package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIdentityInfo; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.ObjectIdGenerators; import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.core.Identifiable; import org.libreccm.core.Identifiable;
@ -98,6 +99,9 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
+ "WHERE t.workflow = :workflow " + "WHERE t.workflow = :workflow "
+ "AND t.taskState = org.libreccm.workflow.TaskState.FINISHED") + "AND t.taskState = org.libreccm.workflow.TaskState.FINISHED")
}) })
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = TaskIdResolver.class,
property = "uuid")
public class Task implements Identifiable, Serializable { public class Task implements Identifiable, Serializable {
private static final long serialVersionUID = 8161343036908150426L; private static final long serialVersionUID = 8161343036908150426L;
@ -159,16 +163,14 @@ public class Task implements Identifiable, Serializable {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "WORKFLOW_ID") @JoinColumn(name = "WORKFLOW_ID")
@JsonBackReference(value = "workflow-task") @JsonIdentityReference(alwaysAsId = true)
private Workflow workflow; private Workflow workflow;
/** /**
* Tasks which the depends of this task. * Tasks which the depends of this task.
*/ */
@ManyToMany(mappedBy = "dependsOn") @ManyToMany(mappedBy = "dependsOn")
@JsonIdentityInfo( @JsonIgnore
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "taskId")
private List<Task> dependentTasks; private List<Task> dependentTasks;
/** /**
@ -181,9 +183,7 @@ public class Task implements Identifiable, Serializable {
@JoinColumn(name = "DEPENDS_ON_TASK_ID")}, @JoinColumn(name = "DEPENDS_ON_TASK_ID")},
inverseJoinColumns = { inverseJoinColumns = {
@JoinColumn(name = "DEPENDENT_TASK_ID")}) @JoinColumn(name = "DEPENDENT_TASK_ID")})
@JsonIdentityInfo( @JsonIdentityReference(alwaysAsId = true)
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "taskId")
private List<Task> dependsOn; private List<Task> dependsOn;
/** /**

View File

@ -18,8 +18,8 @@
*/ */
package org.libreccm.workflow; package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonIdentityReference;
import org.libreccm.portation.Portable; import org.libreccm.portation.Portable;
import org.libreccm.security.Role; import org.libreccm.security.Role;
@ -43,6 +43,8 @@ import static org.libreccm.core.CoreConstants.DB_SCHEMA;
*/ */
@Entity @Entity
@Table(name = "WORKFLOW_TASK_ASSIGNMENTS", schema = DB_SCHEMA) @Table(name = "WORKFLOW_TASK_ASSIGNMENTS", schema = DB_SCHEMA)
@JsonIdentityInfo(generator = TaskAssignmentIdGenerator.class,
property = "customAssignId")
public class TaskAssignment implements Serializable, Portable { public class TaskAssignment implements Serializable, Portable {
private static final long serialVersionUID = -4427537363301565707L; private static final long serialVersionUID = -4427537363301565707L;
@ -60,7 +62,7 @@ public class TaskAssignment implements Serializable, Portable {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "TASK_ID") @JoinColumn(name = "TASK_ID")
@JsonBackReference(value = "assignabletask-taskassignment") @JsonIdentityReference(alwaysAsId = true)
private AssignableTask task; private AssignableTask task;
/** /**
@ -68,7 +70,7 @@ public class TaskAssignment implements Serializable, Portable {
*/ */
@ManyToOne @ManyToOne
@JoinColumn(name = "ROLE_ID") @JoinColumn(name = "ROLE_ID")
@JsonBackReference(value = "role-taskassignment") @JsonIdentityReference(alwaysAsId = true)
private Role role; private Role role;
public long getTaskAssignmentId() { public long getTaskAssignmentId() {

View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class TaskAssignmentIdGenerator extends ObjectIdGenerator<String> {
@Override
public Class<?> getScope() {
return TaskAssignment.class;
}
@Override
public boolean canUseFor(final ObjectIdGenerator<?> gen) {
return gen instanceof TaskAssignmentIdGenerator;
}
@Override
public ObjectIdGenerator<String> forScope(final Class<?> scope) {
return this;
}
@Override
public ObjectIdGenerator<String> newForSerialization(final Object context) {
return this;
}
@Override
public IdKey key(final Object key) {
if (key == null) {
return null;
}
return new IdKey(TaskAssignment.class, TaskAssignment.class, key);
}
@Override
public String generateId(final Object forPojo) {
if (!(forPojo instanceof TaskAssignment)) {
throw new IllegalArgumentException(
"Only RoleMembership instances are supported.");
}
final TaskAssignment assignment = (TaskAssignment) forPojo;
return String.format("{%s}{%s}",
assignment.getTask().getUuid(),
assignment.getRole().getName());
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class TaskIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new TaskIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof TaskIdResolver;
}
}

View File

@ -18,18 +18,13 @@
*/ */
package org.libreccm.workflow; package org.libreccm.workflow;
import static org.libreccm.core.CoreConstants.*; import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import org.libreccm.core.CcmObject; import org.libreccm.core.CcmObject;
import org.libreccm.core.Identifiable;
import org.libreccm.l10n.LocalizedString; import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Portable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.persistence.AssociationOverride; import javax.persistence.AssociationOverride;
import javax.persistence.Column; import javax.persistence.Column;
@ -51,8 +46,13 @@ import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.libreccm.core.Identifiable; import java.io.Serializable;
import org.libreccm.portation.Portable; import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import static org.libreccm.core.CoreConstants.DB_SCHEMA;
/** /**
* A workflow is a collection of tasks which are performed on an object. Tasks * A workflow is a collection of tasks which are performed on an object. Tasks
@ -73,6 +73,9 @@ import org.libreccm.portation.Portable;
query = "SELECT w FROM Workflow w " query = "SELECT w FROM Workflow w "
+ "WHERE W.object = :object") + "WHERE W.object = :object")
}) })
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class,
resolver = WorkflowIdResolver.class,
property = "uuid")
public class Workflow implements Identifiable, Serializable, Portable { public class Workflow implements Identifiable, Serializable, Portable {
private static final long serialVersionUID = 4322500264543325829L; private static final long serialVersionUID = 4322500264543325829L;
@ -157,7 +160,7 @@ public class Workflow implements Identifiable, Serializable, Portable {
* The tasks belonging to this workflow. * The tasks belonging to this workflow.
*/ */
@OneToMany(mappedBy = "workflow") @OneToMany(mappedBy = "workflow")
@JsonManagedReference(value = "workflow-task") @JsonIgnore
private List<Task> tasks; private List<Task> tasks;
public Workflow() { public Workflow() {

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2015 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.workflow;
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
import com.fasterxml.jackson.annotation.ObjectIdResolver;
/**
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
* @version created on 3/23/17
*/
public class WorkflowIdResolver implements ObjectIdResolver {
@Override
public void bindItem(final ObjectIdGenerator.IdKey id,
final Object pojo) {
// According to the Jackson JavaDoc, this method can be used to keep
// track of objects directly in a resolver implementation. We don't need
// this here therefore this method is empty.
}
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
// Find the user for the id (don't confuse that with the primary key!).
return null;
}
@Override
public ObjectIdResolver newForDeserialization(final Object context) {
return new WorkflowIdResolver();
}
@Override
public boolean canUseFor(final ObjectIdResolver resolverType) {
return resolverType instanceof WorkflowIdResolver;
}
}

View File

@ -24,6 +24,7 @@ import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.persistence.CleanupUsingScript; import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.CreateSchema; import org.jboss.arquillian.persistence.CreateSchema;
import org.jboss.arquillian.persistence.PersistenceTest; import org.jboss.arquillian.persistence.PersistenceTest;
import org.jboss.arquillian.persistence.TestExecutionPhase;
import org.jboss.arquillian.transaction.api.annotation.TransactionMode; import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
import org.jboss.arquillian.transaction.api.annotation.Transactional; import org.jboss.arquillian.transaction.api.annotation.Transactional;
import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.ShrinkWrap;
@ -39,9 +40,7 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.libreccm.tests.categories.IntegrationTest; import org.libreccm.tests.categories.IntegrationTest;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import org.jboss.arquillian.persistence.TestExecutionPhase;
import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies; import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
@ -127,79 +126,75 @@ public class CoreDataImportTest {
// TEST SECTION // TEST SECTION
@Test @Test
@InSequence(105) @InSequence(115)
public void categoriesShouldBeImported() { public void roleMembershipsShouldBeImported() {
Assert.assertFalse(importHelper.importRoleMemberships()); Assert.assertFalse(importHelper.importRoleMemberships());
} }
//@Test @Test
@InSequence(110) @InSequence(110)
public void categorizationsShouldBeImported() { public void groupMembershipsShouldBeImported() {
importHelper.importGroupMemberships(); Assert.assertFalse(importHelper.importGroupMemberships());
} }
//@Test @Test
@InSequence(115) @InSequence(115)
public void usersShouldBeImported() { public void groupsShouldBeImported() {
importHelper.importGroups(); Assert.assertFalse(importHelper.importGroups());
} }
//@Test //@Test
@InSequence(120) @InSequence(120)
public void groupsShouldBeImported() { public void usersShouldBeImported() {
importHelper.importUsers(); importHelper.importUsers();
} }
//@Test //@Test
@InSequence(125) @InSequence(125)
public void groupMembershipsShouldBeImported() { public void taskAssignmentsMembershipsShouldBeImported() {
importHelper.importTaskAssignments(); importHelper.importTaskAssignments();
} }
//@Test //@Test
@InSequence(130) @InSequence(130)
public void rolesShouldBeImported() { public void assignableTasksShouldBeImported() {
importHelper.importAssignableTasks(); importHelper.importAssignableTasks();
} }
//@Test //@Test
@InSequence(135) @InSequence(135)
public void roleMembershipsShouldBeImported() { public void workflowTemplatesShouldBeImported() {
importHelper.importWorkflowTemplates(); importHelper.importWorkflowTemplates();
} }
//@Test //@Test
@InSequence(140) @InSequence(140)
public void workflowTemplatesShouldBeImported() { public void workflowsShouldBeImported() {
importHelper.importWorkflows(); importHelper.importWorkflows();
} }
//@Test //@Test
@InSequence(145) @InSequence(145)
public void workflowsShouldBeImported() { public void categorizationsShouldBeImported() {
importHelper.importCategorizations(); importHelper.importCategorizations();
} }
//@Test //@Test
@InSequence(150) @InSequence(150)
public void assignableTasksShouldBeImported() { public void PermissionsShouldBeImported() {
importHelper.importPermissions(); importHelper.importPermissions();
} }
//@Test //@Test
@InSequence(155) @InSequence(155)
public void taskAssignmentsShouldBeImported() { public void categoriesShouldBeImported() {
importHelper.importCategories(); importHelper.importCategories();
} }
//@Test //@Test
@InSequence(160) @InSequence(160)
public void permissionsShouldBeImported() { public void rolesShouldBeImported() {
importHelper.importRoles(); importHelper.importRoles();
} }
} }

View File

@ -55,8 +55,8 @@ import javax.inject.Inject;
*/ */
@RequestScoped @RequestScoped
class ImportHelper { class ImportHelper {
private String repoPath = "/home/jensp/pwi/libreccm/ccm/"; //private String repoPath = "/home/jensp/pwi/libreccm/ccm/";
//private String repoPath = ""; private String repoPath = "/home/tosmers/Svn/libreccm/";
private String projectPath = "ccm_ng/ccm-core/src/test/resources/" + private String projectPath = "ccm_ng/ccm-core/src/test/resources/" +
"portation/trunk-iaw-exports"; "portation/trunk-iaw-exports";
private boolean indentation = false; private boolean indentation = false;
@ -99,40 +99,40 @@ class ImportHelper {
private PermissionMarshaller permissionMarshaller; private PermissionMarshaller permissionMarshaller;
void importCategories() { boolean importCategories() {
categoryMarshaller.prepare(Format.XML, repoPath + projectPath, categoryMarshaller.prepare(Format.XML, repoPath + projectPath,
"categories.xml", indentation); "categories.xml", indentation);
categoryMarshaller.importFile(); return categoryMarshaller.importFile();
} }
void importCategorizations() { boolean importCategorizations() {
categorizationMarshaller.prepare(Format.XML, repoPath + projectPath, categorizationMarshaller.prepare(Format.XML, repoPath + projectPath,
"categorizations.xml", indentation); "categorizations.xml", indentation);
categorizationMarshaller.importFile(); return categorizationMarshaller.importFile();
} }
void importUsers() { boolean importUsers() {
userMarshaller.prepare(Format.XML, repoPath + projectPath, userMarshaller.prepare(Format.XML, repoPath + projectPath,
"users.xml", indentation); "users.xml", indentation);
userMarshaller.importFile(); return userMarshaller.importFile();
} }
void importGroups() { boolean importGroups() {
groupMarshaller.prepare(Format.XML, repoPath + projectPath, groupMarshaller.prepare(Format.XML, repoPath + projectPath,
"groups.xml", indentation); "groups.xml", indentation);
groupMarshaller.importFile(); return groupMarshaller.importFile();
} }
void importGroupMemberships() { boolean importGroupMemberships() {
groupMembershipMarshaller.prepare(Format.XML, repoPath + projectPath, groupMembershipMarshaller.prepare(Format.XML, repoPath + projectPath,
"groupMemberships.xml", indentation); "groupMemberships.xml", indentation);
groupMembershipMarshaller.importFile(); return groupMembershipMarshaller.importFile();
} }
void importRoles() { boolean importRoles() {
roleMarshaller.prepare(Format.XML, repoPath + projectPath, roleMarshaller.prepare(Format.XML, repoPath + projectPath,
"roles.xml", indentation); "roles.xml", indentation);
roleMarshaller.importFile(); return roleMarshaller.importFile();
} }
boolean importRoleMemberships() { boolean importRoleMemberships() {
@ -141,34 +141,34 @@ class ImportHelper {
return roleMembershipMarshaller.importFile(); return roleMembershipMarshaller.importFile();
} }
void importWorkflowTemplates() { boolean importWorkflowTemplates() {
workflowTemplateMarshaller.prepare(Format.XML, repoPath + projectPath, workflowTemplateMarshaller.prepare(Format.XML, repoPath + projectPath,
"workflowTemplates.xml", indentation); "workflowTemplates.xml", indentation);
workflowTemplateMarshaller.importFile(); return workflowTemplateMarshaller.importFile();
} }
void importWorkflows() { boolean importWorkflows() {
workflowMarshaller.prepare(Format.XML, repoPath + projectPath, workflowMarshaller.prepare(Format.XML, repoPath + projectPath,
"workflows.xml", indentation); "workflows.xml", indentation);
workflowMarshaller.importFile(); return workflowMarshaller.importFile();
} }
void importAssignableTasks() { boolean importAssignableTasks() {
assignableTaskMarshaller.prepare(Format.XML, repoPath + projectPath, assignableTaskMarshaller.prepare(Format.XML, repoPath + projectPath,
"assignableTasks.xml", indentation); "assignableTasks.xml", indentation);
assignableTaskMarshaller.importFile(); return assignableTaskMarshaller.importFile();
} }
void importTaskAssignments() { boolean importTaskAssignments() {
taskAssignmentMarshaller.prepare(Format.XML, repoPath + projectPath, taskAssignmentMarshaller.prepare(Format.XML, repoPath + projectPath,
"taskAssignments.xml", indentation); "taskAssignments.xml", indentation);
taskAssignmentMarshaller.importFile(); return taskAssignmentMarshaller.importFile();
} }
void importPermissions() { boolean importPermissions() {
permissionMarshaller.prepare(Format.XML, repoPath + projectPath, permissionMarshaller.prepare(Format.XML, repoPath + projectPath,
"permissions.xml", indentation); "permissions.xml", indentation);
permissionMarshaller.importFile(); return permissionMarshaller.importFile();
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,8 @@
<GroupMembership><membershipId>1</membershipId></GroupMembership> <GroupMembership><customMemId>{Site-wide Administrators}{Ariela Trümper}</customMemId><membershipId>7135036</membershipId><group>Site-wide Administrators</group><member>Ariela Trümper</member></GroupMembership>
<GroupMembership><membershipId>2</membershipId></GroupMembership> <GroupMembership><customMemId>{Site-wide Administrators}{Hartmut Schekerka}</customMemId><membershipId>7135037</membershipId><group>Site-wide Administrators</group><member>Hartmut Schekerka</member></GroupMembership>
<GroupMembership><membershipId>3</membershipId></GroupMembership> <GroupMembership><customMemId>{content Administration}{Hartmut Schekerka}</customMemId><membershipId>7135038</membershipId><group>content Administration</group><member>Hartmut Schekerka</member></GroupMembership>
<GroupMembership><membershipId>4</membershipId></GroupMembership> <GroupMembership><customMemId>{Portal Homepage}{Public Users}</customMemId><membershipId>7135039</membershipId><group>Portal Homepage</group><member>Public Users</member></GroupMembership>
<GroupMembership><membershipId>5</membershipId></GroupMembership> <GroupMembership><customMemId>{Site-wide Administrators}{Nessim Hemmer}</customMemId><membershipId>7135033</membershipId><group>Site-wide Administrators</group><member>Nessim Hemmer</member></GroupMembership>
<GroupMembership><membershipId>6</membershipId></GroupMembership> <GroupMembership><customMemId>{Site-wide Administrators}{Peter Boy}</customMemId><membershipId>7135034</membershipId><group>Site-wide Administrators</group><member>Peter Boy</member></GroupMembership>
<GroupMembership><membershipId>7</membershipId></GroupMembership> <GroupMembership><customMemId>{Site-wide Administrators}{Jörg Sommer}</customMemId><membershipId>7135035</membershipId><group>Site-wide Administrators</group><member>Jörg Sommer</member></GroupMembership>
<GroupMembership><membershipId>8</membershipId></GroupMembership> <GroupMembership><customMemId>{projects Administration}{Hartmut Schekerka}</customMemId><membershipId>7135040</membershipId><group>projects Administration</group><member>Hartmut Schekerka</member></GroupMembership>

View File

@ -1,16 +1,16 @@
<Group><partyId>541003</partyId><name>projects Administration</name><memberships><membershipId>8</membershipId></memberships></Group> <Group><name>projects Administration</name><partyId>541003</partyId></Group>
<Group><partyId>1061</partyId><name>content Administration</name><memberships><membershipId>6</membershipId></memberships></Group> <Group><name>content Administration</name><partyId>1061</partyId></Group>
<Group><partyId>541006</partyId><name>projects Viewers</name></Group> <Group><name>projects Viewers</name><partyId>541006</partyId></Group>
<Group><partyId>1064</partyId><name>content Viewers</name></Group> <Group><name>content Viewers</name><partyId>1064</partyId></Group>
<Group><partyId>1339004</partyId><name>homepages Viewers</name></Group> <Group><name>homepages Viewers</name><partyId>1339004</partyId></Group>
<Group><partyId>3439036</partyId><name>publications Viewers</name></Group> <Group><name>publications Viewers</name><partyId>3439036</partyId></Group>
<Group><partyId>5619069</partyId><name>euss Administration</name></Group> <Group><name>euss Administration</name><partyId>5619069</partyId></Group>
<Group><partyId>-300</partyId><name>Site-wide Administrators</name><roleMemberships><membershipId>157</membershipId></roleMemberships><roleMemberships><membershipId>152</membershipId></roleMemberships><roleMemberships><membershipId>130</membershipId></roleMemberships><roleMemberships><membershipId>153</membershipId></roleMemberships><roleMemberships><membershipId>123</membershipId></roleMemberships><roleMemberships><membershipId>136</membershipId></roleMemberships><roleMemberships><membershipId>158</membershipId></roleMemberships><roleMemberships><membershipId>109</membershipId></roleMemberships><roleMemberships><membershipId>154</membershipId></roleMemberships><roleMemberships><membershipId>112</membershipId></roleMemberships><roleMemberships><membershipId>116</membershipId></roleMemberships><roleMemberships><membershipId>140</membershipId></roleMemberships><memberships><membershipId>1</membershipId></memberships><memberships><membershipId>2</membershipId></memberships><memberships><membershipId>3</membershipId></memberships><memberships><membershipId>4</membershipId></memberships><memberships><membershipId>5</membershipId></memberships></Group> <Group><name>Site-wide Administrators</name><partyId>-300</partyId></Group>
<Group><partyId>5619070</partyId><name>euss Viewers</name></Group> <Group><name>euss Viewers</name><partyId>5619070</partyId></Group>
<Group><partyId>1339003</partyId><name>homepages Administration</name></Group> <Group><name>homepages Administration</name><partyId>1339003</partyId></Group>
<Group><partyId>3439035</partyId><name>publications Administration</name></Group> <Group><name>publications Administration</name><partyId>3439035</partyId></Group>
<Group><partyId>1937037</partyId><name>research Viewers</name></Group> <Group><name>research Viewers</name><partyId>1937037</partyId></Group>
<Group><partyId>1937036</partyId><name>research Administration</name></Group> <Group><name>research Administration</name><partyId>1937036</partyId></Group>
<Group><partyId>1271</partyId><name>Portal Workspace Groups</name></Group> <Group><name>Portal Workspace Groups</name><partyId>1271</partyId></Group>
<Group><partyId>1274</partyId><name>Portal Homepage</name></Group> <Group><name>Portal Homepage</name><partyId>1274</partyId></Group>
<Group><partyId>1278</partyId><name>Portal Homepage</name><memberships><membershipId>7</membershipId></memberships></Group> <Group><name>Portal Homepage</name><partyId>1278</partyId></Group>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long