diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationIdGenerator.java b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationIdGenerator.java new file mode 100644 index 000000000..3a8ca31ed --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/categorization/CategorizationIdGenerator.java @@ -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 Tobias Osmers + * @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; + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupIdResolver.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupIdResolver.java new file mode 100644 index 000000000..6eb87c591 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/GroupIdResolver.java @@ -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 Tobias Osmers + * @version created on 3/15/17 + */ +public class GroupMembershipIdGenerator extends ObjectIdGenerator { + @Override + public Class getScope() { + return GroupMembership.class; + } + + @Override + public boolean canUseFor(final ObjectIdGenerator gen) { + return gen instanceof GroupMembershipIdGenerator; + } + + @Override + public ObjectIdGenerator forScope(final Class scope) { + return this; + } + + @Override + public ObjectIdGenerator 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()); + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/PartyIdResolver.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/PartyIdResolver.java new file mode 100644 index 000000000..e8a5fa327 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/PartyIdResolver.java @@ -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 Tobias Osmers + * @version created on 3/15/17 + */ +public class PermissionIdGenerator extends ObjectIdGenerator { + @Override + public Class getScope() { + return Permission.class; + } + + @Override + public boolean canUseFor(final ObjectIdGenerator gen) { + return gen instanceof PermissionIdGenerator; + } + + @Override + public ObjectIdGenerator forScope(final Class scope) { + return this; + } + + @Override + public ObjectIdGenerator 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()); + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionIdResolver.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionIdResolver.java new file mode 100644 index 000000000..63f81b085 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/PermissionIdResolver.java @@ -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 Tobias Osmers + * @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; + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipIdGenerator.java b/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipIdGenerator.java new file mode 100644 index 000000000..0cebea7a6 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/security/RoleMembershipIdGenerator.java @@ -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 Tobias Osmers + * @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; + } +} diff --git a/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignmentIdGenerator.java b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignmentIdGenerator.java new file mode 100644 index 000000000..66bf20a31 --- /dev/null +++ b/ccm-core/src/com/arsdigita/portation/modules/core/workflow/TaskAssignmentIdGenerator.java @@ -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 Tobias Osmers + * @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; + } +}