[UPDATE]
- adds IdGenerators and IdResolvers for the use of @JsonIdentityInfo git-svn-id: https://svn.libreccm.org/ccm/trunk@4633 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
d61efd3d30
commit
36e86ffda3
|
|
@ -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 com.arsdigita.portation.modules.core.categorization;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 3/15/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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.categorization;
|
||||
|
||||
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/15/17
|
||||
*/
|
||||
public class CategoryIdResolver 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 CategoryIdResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseFor(ObjectIdResolver resolverType) {
|
||||
return resolverType instanceof CategoryIdResolver;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 3/15/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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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 com.arsdigita.portation.modules.core.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 3/15/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;
|
||||
|
||||
return String.format("{%s}{%s}{%s}",
|
||||
permission.getGrantedPrivilege(),
|
||||
permission.getObject(),
|
||||
permission.getGrantee());
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.security;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 3/15/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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.workflow;
|
||||
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerator;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 3/15/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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 com.arsdigita.portation.modules.core.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/15/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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue