http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/util/AttributableOperations.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/util/AttributableOperations.java b/common/src/main/java/org/apache/syncope/common/util/AttributableOperations.java deleted file mode 100644 index 44427cc..0000000 --- a/common/src/main/java/org/apache/syncope/common/util/AttributableOperations.java +++ /dev/null @@ -1,508 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.commons.lang3.SerializationUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.mod.AbstractAttributableMod; -import org.apache.syncope.common.mod.AbstractSubjectMod; -import org.apache.syncope.common.mod.AttributeMod; -import org.apache.syncope.common.mod.MembershipMod; -import org.apache.syncope.common.mod.ReferenceMod; -import org.apache.syncope.common.mod.RoleMod; -import org.apache.syncope.common.mod.UserMod; -import org.apache.syncope.common.to.AbstractAttributableTO; -import org.apache.syncope.common.to.AbstractSubjectTO; -import org.apache.syncope.common.to.AttributeTO; -import org.apache.syncope.common.to.MembershipTO; -import org.apache.syncope.common.to.RoleTO; -import org.apache.syncope.common.to.UserTO; - -/** - * Utility class for manipulating classes extending AbstractAttributableTO and AbstractAttributableMod. - * - * @see AbstractAttributableTO - * @see AbstractAttributableMod - */ -public final class AttributableOperations { - - private AttributableOperations() { - // empty constructor for static utility classes - } - - private static void populate(final Map<String, AttributeTO> updatedAttrs, - final Map<String, AttributeTO> originalAttrs, final AbstractAttributableMod result) { - - populate(updatedAttrs, originalAttrs, result, false); - } - - private static void populate(final Map<String, AttributeTO> updatedAttrs, - final Map<String, AttributeTO> originalAttrs, final AbstractAttributableMod result, - final boolean virtuals) { - - for (Map.Entry<String, AttributeTO> entry : updatedAttrs.entrySet()) { - AttributeMod mod = new AttributeMod(); - mod.setSchema(entry.getKey()); - - Set<String> updatedValues = new HashSet<String>(entry.getValue().getValues()); - - Set<String> originalValues = originalAttrs.containsKey(entry.getKey()) - ? new HashSet<String>(originalAttrs.get(entry.getKey()).getValues()) - : Collections.<String>emptySet(); - - if (!originalAttrs.containsKey(entry.getKey())) { - // SYNCOPE-459: take care of user virtual attributes without any value - updatedValues.remove(""); - mod.getValuesToBeAdded().addAll(new ArrayList<String>(updatedValues)); - - if (virtuals) { - result.getVirAttrsToUpdate().add(mod); - } else { - result.getAttrsToUpdate().add(mod); - } - } else if (!updatedValues.equals(originalValues)) { - // avoid unwanted inputs - updatedValues.remove(""); - if (!entry.getValue().isReadonly()) { - mod.getValuesToBeAdded().addAll(updatedValues); - - if (!mod.isEmpty()) { - if (virtuals) { - result.getVirAttrsToRemove().add(mod.getSchema()); - } else { - result.getAttrsToRemove().add(mod.getSchema()); - } - } - } - - mod.getValuesToBeRemoved().addAll(originalValues); - - if (!mod.isEmpty()) { - if (virtuals) { - result.getVirAttrsToUpdate().add(mod); - } else { - result.getAttrsToUpdate().add(mod); - } - } - } - } - } - - private static void diff( - final AbstractAttributableTO updated, - final AbstractAttributableTO original, - final AbstractAttributableMod result, - final boolean incremental) { - - // 1. check same id - if (updated.getId() != original.getId()) { - throw new IllegalArgumentException("AttributableTO's id must be the same"); - } - result.setId(updated.getId()); - - // 2. attributes - Map<String, AttributeTO> updatedAttrs = new HashMap<String, AttributeTO>(updated.getAttrMap()); - Map<String, AttributeTO> originalAttrs = new HashMap<String, AttributeTO>(original.getAttrMap()); - - Set<String> originalAttrNames = new HashSet<String>(originalAttrs.keySet()); - originalAttrNames.removeAll(updatedAttrs.keySet()); - - if (!incremental) { - result.getAttrsToRemove().clear(); - result.getAttrsToRemove().addAll(originalAttrNames); - } - - Set<String> emptyUpdatedAttrs = new HashSet<String>(); - for (Map.Entry<String, AttributeTO> entry : updatedAttrs.entrySet()) { - if (entry.getValue().getValues() == null || entry.getValue().getValues().isEmpty()) { - - emptyUpdatedAttrs.add(entry.getKey()); - } - } - for (String emptyUpdatedAttr : emptyUpdatedAttrs) { - updatedAttrs.remove(emptyUpdatedAttr); - result.getAttrsToRemove().add(emptyUpdatedAttr); - } - - populate(updatedAttrs, originalAttrs, result); - - // 3. derived attributes - updatedAttrs = updated.getDerAttrMap(); - originalAttrs = original.getDerAttrMap(); - - originalAttrNames = new HashSet<String>(originalAttrs.keySet()); - originalAttrNames.removeAll(updatedAttrs.keySet()); - - if (!incremental) { - result.getDerAttrsToRemove().clear(); - result.getDerAttrsToRemove().addAll(originalAttrNames); - } - - Set<String> updatedAttrNames = new HashSet<String>(updatedAttrs.keySet()); - updatedAttrNames.removeAll(originalAttrs.keySet()); - result.getDerAttrsToAdd().clear(); - result.getDerAttrsToAdd().addAll(updatedAttrNames); - - // 4. virtual attributes - updatedAttrs = updated.getVirAttrMap(); - originalAttrs = original.getVirAttrMap(); - - originalAttrNames = new HashSet<String>(originalAttrs.keySet()); - originalAttrNames.removeAll(updatedAttrs.keySet()); - - if (!incremental) { - result.getVirAttrsToRemove().clear(); - result.getVirAttrsToRemove().addAll(originalAttrNames); - } - - populate(updatedAttrs, originalAttrs, result, true); - - // 5. resources - if (original instanceof AbstractSubjectTO && updated instanceof AbstractSubjectTO - && result instanceof AbstractSubjectMod) { - - Set<String> updatedRes = new HashSet<String>(((AbstractSubjectTO) updated).getResources()); - Set<String> originalRes = new HashSet<String>(((AbstractSubjectTO) original).getResources()); - - updatedRes.removeAll(originalRes); - ((AbstractSubjectMod) result).getResourcesToAdd().clear(); - ((AbstractSubjectMod) result).getResourcesToAdd().addAll(updatedRes); - - originalRes.removeAll(((AbstractSubjectTO) updated).getResources()); - - if (!incremental) { - ((AbstractSubjectMod) result).getResourcesToRemove().clear(); - ((AbstractSubjectMod) result).getResourcesToRemove().addAll(originalRes); - } - } - } - - /** - * Calculate modifications needed by first in order to be equal to second. - * - * @param updated updated UserTO - * @param original original UserTO - * @return UserMod containing differences - */ - public static UserMod diff(final UserTO updated, final UserTO original) { - return diff(updated, original, false); - } - - /** - * Calculate modifications needed by first in order to be equal to second. - * - * @param updated updated UserTO - * @param original original UserTO - * @param incremental perform incremental diff (without removing existing info) - * @return UserMod containing differences - */ - public static UserMod diff(final UserTO updated, final UserTO original, final boolean incremental) { - UserMod result = new UserMod(); - - diff(updated, original, result, incremental); - - // 1. password - if (updated.getPassword() != null && (original.getPassword() == null - || !original.getPassword().equals(updated.getPassword()))) { - - result.setPassword(updated.getPassword()); - } - - // 2. username - if (original.getUsername() != null && !original.getUsername().equals(updated.getUsername())) { - result.setUsername(updated.getUsername()); - } - - // 3. security question / answer - if (updated.getSecurityQuestion() == null) { - result.setSecurityQuestion(null); - result.setSecurityAnswer(null); - } else if (!updated.getSecurityQuestion().equals(original.getSecurityQuestion()) - || StringUtils.isNotBlank(updated.getSecurityAnswer())) { - - result.setSecurityQuestion(updated.getSecurityQuestion()); - result.setSecurityAnswer(updated.getSecurityAnswer()); - } - - // 4. memberships - Map<Long, MembershipTO> updatedMembs = updated.getMembershipMap(); - Map<Long, MembershipTO> originalMembs = original.getMembershipMap(); - - for (Map.Entry<Long, MembershipTO> entry : updatedMembs.entrySet()) { - MembershipMod membMod = new MembershipMod(); - membMod.setRole(entry.getValue().getRoleId()); - - if (originalMembs.containsKey(entry.getKey())) { - // if memberships are actually same, just make the isEmpty() call below succeed - if (entry.getValue().equals(originalMembs.get(entry.getKey()))) { - membMod.setRole(0); - } else { - diff(entry.getValue(), originalMembs.get(entry.getKey()), membMod, false); - } - } else { - for (AttributeTO attr : entry.getValue().getAttrs()) { - AttributeMod attrMod = new AttributeMod(); - attrMod.setSchema(attr.getSchema()); - attrMod.getValuesToBeAdded().addAll(attr.getValues()); - - if (!attrMod.isEmpty()) { - membMod.getAttrsToUpdate().add(attrMod); - membMod.getAttrsToRemove().add(attrMod.getSchema()); - } - } - for (AttributeTO attr : entry.getValue().getDerAttrs()) { - membMod.getDerAttrsToAdd().add(attr.getSchema()); - } - for (AttributeTO attr : entry.getValue().getVirAttrs()) { - AttributeMod attrMod = new AttributeMod(); - attrMod.setSchema(attr.getSchema()); - attrMod.getValuesToBeAdded().addAll(attr.getValues()); - - if (!attrMod.isEmpty()) { - membMod.getVirAttrsToUpdate().add(attrMod); - membMod.getAttrsToRemove().add(attrMod.getSchema()); - } - } - } - - if (!membMod.isEmpty()) { - result.getMembershipsToAdd().add(membMod); - } - } - - if (!incremental) { - Set<Long> originalRoles = new HashSet<Long>(originalMembs.keySet()); - originalRoles.removeAll(updatedMembs.keySet()); - for (Long roleId : originalRoles) { - result.getMembershipsToRemove().add(originalMembs.get(roleId).getId()); - } - } - - return result; - } - - /** - * Calculate modifications needed by first in order to be equal to second. - * - * @param updated updated RoleTO - * @param original original RoleTO - * @return RoleMod containing differences - */ - public static RoleMod diff(final RoleTO updated, final RoleTO original) { - return diff(updated, original, false); - } - - /** - * Calculate modifications needed by first in order to be equal to second. - * - * @param updated updated RoleTO - * @param original original RoleTO - * @param incremental perform incremental diff (without removing existing info) - * @return RoleMod containing differences - */ - public static RoleMod diff(final RoleTO updated, final RoleTO original, final boolean incremental) { - RoleMod result = new RoleMod(); - - diff(updated, original, result, incremental); - - // 1. inheritance - result.setInheritOwner(updated.isInheritOwner()); - result.setInheritTemplates(updated.isInheritTemplates()); - result.setInheritAccountPolicy(updated.isInheritAccountPolicy()); - result.setInheritPasswordPolicy(updated.isInheritPasswordPolicy()); - result.setInheritAttributes(updated.isInheritAttrs()); - result.setInheritDerAttrs(updated.isInheritDerAttrs()); - result.setInheritVirAttrs(updated.isInheritVirAttrs()); - - // 2. policies - result.setAccountPolicy(new ReferenceMod(updated.getAccountPolicy())); - result.setPasswordPolicy(new ReferenceMod(updated.getPasswordPolicy())); - - // 3. name - if (!original.getName().equals(updated.getName())) { - result.setName(updated.getName()); - } - - // 4. entitlements - Set<String> updatedEnts = new HashSet<String>(updated.getEntitlements()); - Set<String> originalEnts = new HashSet<String>(original.getEntitlements()); - if (updatedEnts.equals(originalEnts)) { - result.setModEntitlements(false); - result.getEntitlements().clear(); - } else { - result.setModEntitlements(true); - result.getEntitlements().addAll(updated.getEntitlements()); - } - - // 5. templates - Set<String> updatedTemplates = new HashSet<String>(updated.getRAttrTemplates()); - Set<String> originalTemplates = new HashSet<String>(original.getRAttrTemplates()); - if (updatedTemplates.equals(originalTemplates)) { - result.setModRAttrTemplates(false); - result.getRAttrTemplates().clear(); - } else { - result.setModRAttrTemplates(true); - result.getRAttrTemplates().addAll(updated.getRAttrTemplates()); - } - updatedTemplates = new HashSet<String>(updated.getRDerAttrTemplates()); - originalTemplates = new HashSet<String>(original.getRDerAttrTemplates()); - if (updatedTemplates.equals(originalTemplates)) { - result.setModRDerAttrTemplates(false); - result.getRDerAttrTemplates().clear(); - } else { - result.setModRDerAttrTemplates(true); - result.getRDerAttrTemplates().addAll(updated.getRDerAttrTemplates()); - } - updatedTemplates = new HashSet<String>(updated.getRVirAttrTemplates()); - originalTemplates = new HashSet<String>(original.getRVirAttrTemplates()); - if (updatedTemplates.equals(originalTemplates)) { - result.setModRVirAttrTemplates(false); - result.getRVirAttrTemplates().clear(); - } else { - result.setModRVirAttrTemplates(true); - result.getRVirAttrTemplates().addAll(updated.getRVirAttrTemplates()); - } - updatedTemplates = new HashSet<String>(updated.getMAttrTemplates()); - originalTemplates = new HashSet<String>(original.getMAttrTemplates()); - if (updatedTemplates.equals(originalTemplates)) { - result.setModMAttrTemplates(false); - result.getMAttrTemplates().clear(); - } else { - result.setModMAttrTemplates(true); - result.getMAttrTemplates().addAll(updated.getMAttrTemplates()); - } - updatedTemplates = new HashSet<String>(updated.getMDerAttrTemplates()); - originalTemplates = new HashSet<String>(original.getMDerAttrTemplates()); - if (updatedTemplates.equals(originalTemplates)) { - result.setModMDerAttrTemplates(false); - result.getMDerAttrTemplates().clear(); - } else { - result.setModMDerAttrTemplates(true); - result.getMDerAttrTemplates().addAll(updated.getMDerAttrTemplates()); - } - updatedTemplates = new HashSet<String>(updated.getMVirAttrTemplates()); - originalTemplates = new HashSet<String>(original.getMVirAttrTemplates()); - if (updatedTemplates.equals(originalTemplates)) { - result.setModMVirAttrTemplates(false); - result.getMVirAttrTemplates().clear(); - } else { - result.setModMVirAttrTemplates(true); - result.getMVirAttrTemplates().addAll(updated.getMVirAttrTemplates()); - } - - // 6. owner - result.setUserOwner(new ReferenceMod(updated.getUserOwner())); - result.setRoleOwner(new ReferenceMod(updated.getRoleOwner())); - - return result; - } - - private static List<AttributeTO> getUpdateValues(final Map<String, AttributeTO> attrs, - final Set<String> attrsToBeRemoved, final Set<AttributeMod> attrsToBeUpdated) { - - Map<String, AttributeTO> rwattrs = new HashMap<String, AttributeTO>(attrs); - for (String attrName : attrsToBeRemoved) { - rwattrs.remove(attrName); - } - for (AttributeMod attrMod : attrsToBeUpdated) { - if (rwattrs.containsKey(attrMod.getSchema())) { - AttributeTO attrTO = rwattrs.get(attrMod.getSchema()); - attrTO.getValues().removeAll(attrMod.getValuesToBeRemoved()); - attrTO.getValues().addAll(attrMod.getValuesToBeAdded()); - } else { - AttributeTO attrTO = new AttributeTO(); - attrTO.setSchema(attrMod.getSchema()); - attrTO.getValues().addAll(attrMod.getValuesToBeAdded()); - - rwattrs.put(attrMod.getSchema(), attrTO); - } - } - - return new ArrayList<AttributeTO>(rwattrs.values()); - } - - private static <T extends AbstractAttributableTO, K extends AbstractAttributableMod> void apply(final T to, - final K mod, final T result) { - - // 1. attributes - result.getAttrs().addAll(getUpdateValues(to.getAttrMap(), - mod.getAttrsToRemove(), mod.getAttrsToUpdate())); - - // 2. derived attributes - Map<String, AttributeTO> attrs = to.getDerAttrMap(); - for (String attrName : mod.getDerAttrsToRemove()) { - attrs.remove(attrName); - } - for (String attrName : mod.getDerAttrsToAdd()) { - AttributeTO attrTO = new AttributeTO(); - attrTO.setSchema(attrName); - - attrs.put(attrName, attrTO); - } - result.getDerAttrs().addAll(attrs.values()); - - // 3. virtual attributes - result.getVirAttrs().addAll(getUpdateValues(to.getVirAttrMap(), - mod.getVirAttrsToRemove(), mod.getVirAttrsToUpdate())); - - // 4. resources - if (result instanceof AbstractSubjectTO && mod instanceof AbstractSubjectMod) { - ((AbstractSubjectTO) result).getResources().removeAll(((AbstractSubjectMod) mod).getResourcesToRemove()); - ((AbstractSubjectTO) result).getResources().addAll(((AbstractSubjectMod) mod).getResourcesToAdd()); - } - } - - public static UserTO apply(final UserTO userTO, final UserMod userMod) { - // 1. check same id - if (userTO.getId() != userMod.getId()) { - throw new IllegalArgumentException("UserTO and UserMod ids must be the same"); - } - - UserTO result = SerializationUtils.clone(userTO); - apply(userTO, userMod, result); - - // 1. password - result.setPassword(userMod.getPassword()); - - // 2. username - if (userMod.getUsername() != null) { - result.setUsername(userMod.getUsername()); - } - // 3. memberships - Map<Long, MembershipTO> membs = result.getMembershipMap(); - for (Long membId : userMod.getMembershipsToRemove()) { - result.getMemberships().remove(membs.get(membId)); - } - for (MembershipMod membMod : userMod.getMembershipsToAdd()) { - MembershipTO membTO = new MembershipTO(); - membTO.setRoleId(membMod.getRole()); - - apply(membTO, membMod, membTO); - } - - return result; - } -}
http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/util/BeanUtils.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/util/BeanUtils.java b/common/src/main/java/org/apache/syncope/common/util/BeanUtils.java deleted file mode 100644 index eb25ae1..0000000 --- a/common/src/main/java/org/apache/syncope/common/util/BeanUtils.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.util; - -import static org.springframework.beans.BeanUtils.getPropertyDescriptor; -import static org.springframework.beans.BeanUtils.getPropertyDescriptors; - -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import org.springframework.beans.BeansException; -import org.springframework.beans.FatalBeanException; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -/** - * Overrides Spring's BeanUtils not using collection setters but instead getters + addAll() / putAll(), - * in a JAXB friendly way. - * - * Refer to <a href="https://issues.apache.org/jira/browse/SYNCOPE-246">SYNCOPE-246</a> for more information. - * - * @see org.springframework.beans.BeanUtils - */ -public final class BeanUtils { - - private BeanUtils() { - // Empty private constructor for static utility classes - } - - /** - * Copy the property values of the given source bean into the target bean. - * <p> - * Note: The source and target classes do not have to match or even be derived - * from each other, as long as the properties match. Any bean properties that the - * source bean exposes but the target bean does not will silently be ignored. - * </p><p> - * This is just a convenience method. For more complex transfer needs, - * consider using a full BeanWrapper. - * </p> - * @param source the source bean - * @param target the target bean - * @throws BeansException if the copying failed - * @see org.springframework.beans.BeanWrapper - */ - public static void copyProperties(final Object source, final Object target) throws BeansException { - copyProperties(source, target, null, (String[]) null); - } - - /** - * Copy the property values of the given source bean into the given target bean, - * only setting properties defined in the given "editable" class (or interface). - * <p> - * Note: The source and target classes do not have to match or even be derived - * from each other, as long as the properties match. Any bean properties that the - * source bean exposes but the target bean does not will silently be ignored. - * </p><p> - * This is just a convenience method. For more complex transfer needs, - * consider using a full BeanWrapper. - * </p> - * - * @param source the source bean - * @param target the target bean - * @param editable the class (or interface) to restrict property setting to - * @throws BeansException if the copying failed - * @see org.springframework.beans.BeanWrapper - */ - public static void copyProperties(final Object source, final Object target, final Class<?> editable) - throws BeansException { - - copyProperties(source, target, editable, (String[]) null); - } - - /** - * Copy the property values of the given source bean into the given target bean, - * ignoring the given "ignoreProperties". - * <p> - * Note: The source and target classes do not have to match or even be derived - * from each other, as long as the properties match. Any bean properties that the - * source bean exposes but the target bean does not will silently be ignored. - * </p><p> - * This is just a convenience method. For more complex transfer needs, - * consider using a full BeanWrapper. - * </p> - * - * @param source the source bean - * @param target the target bean - * @param ignoreProperties array of property names to ignore - * @throws BeansException if the copying failed - * @see org.springframework.beans.BeanWrapper - */ - public static void copyProperties(final Object source, final Object target, final String... ignoreProperties) - throws BeansException { - - copyProperties(source, target, null, ignoreProperties); - } - - /** - * Copy the property values of the given source bean into the given target bean. - * <p> - * Note: The source and target classes do not have to match or even be derived - * from each other, as long as the properties match. Any bean properties that the - * source bean exposes but the target bean does not will silently be ignored. - * </p> - * - * @param source the source bean - * @param target the target bean - * @param editable the class (or interface) to restrict property setting to - * @param ignoreProperties array of property names to ignore - * @throws BeansException if the copying failed - * @see org.springframework.beans.BeanWrapper - */ - @SuppressWarnings("unchecked") - private static void copyProperties(final Object source, final Object target, final Class<?> editable, - final String... ignoreProperties) throws BeansException { - - Assert.notNull(source, "Source must not be null"); - Assert.notNull(target, "Target must not be null"); - - Class<?> actualEditable = target.getClass(); - if (editable != null) { - if (!editable.isInstance(target)) { - throw new IllegalArgumentException("Target class [" + target.getClass().getName() - + "] not assignable to Editable class [" + editable.getName() + "]"); - } - actualEditable = editable; - } - PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable); - List<String> ignoreList = (ignoreProperties == null) - ? Collections.<String>emptyList() : Arrays.asList(ignoreProperties); - - for (PropertyDescriptor targetPd : targetPds) { - if (ignoreProperties == null || (!ignoreList.contains(targetPd.getName()))) { - PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName()); - if (sourcePd != null) { - Method readMethod = sourcePd.getReadMethod(); - if (readMethod != null) { - Method writeMethod = targetPd.getWriteMethod(); - - try { - // Diverts from Spring's BeanUtils: if no write method is found and property is collection, - // try to use addAll() / putAll(). - if (writeMethod == null) { - Object value = readMethod.invoke(source); - Method targetReadMethod = targetPd.getReadMethod(); - if (targetReadMethod != null) { - if (!Modifier.isPublic(targetReadMethod.getDeclaringClass().getModifiers())) { - targetReadMethod.setAccessible(true); - } - Object destValue = targetReadMethod.invoke(target); - - if (value instanceof Collection && destValue instanceof Collection) { - ((Collection) destValue).clear(); - ((Collection) destValue).addAll((Collection) value); - } else if (value instanceof Map && destValue instanceof Map) { - ((Map) destValue).clear(); - ((Map) destValue).putAll((Map) value); - } - } - } else if (ClassUtils.isAssignable( - writeMethod.getParameterTypes()[0], readMethod.getReturnType())) { - - if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) { - readMethod.setAccessible(true); - } - Object value = readMethod.invoke(source); - if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) { - writeMethod.setAccessible(true); - } - writeMethod.invoke(target, value); - } - } catch (Throwable ex) { - throw new FatalBeanException( - "Could not copy property '" + targetPd.getName() + "' from source to target", ex); - } - } - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java b/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java deleted file mode 100644 index e95f9c3..0000000 --- a/common/src/main/java/org/apache/syncope/common/util/CollectionWrapper.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import org.apache.syncope.common.wrap.AbstractWrappable; -import org.apache.syncope.common.to.LoggerTO; -import org.apache.syncope.common.types.AuditLoggerName; -import org.apache.syncope.common.types.LoggerLevel; - -public final class CollectionWrapper { - - private CollectionWrapper() { - // empty constructor for static utility class - } - - public static <E, T extends AbstractWrappable<E>> List<T> wrap(final E element, final Class<T> reference) { - return Collections.singletonList(AbstractWrappable.getInstance(reference, element)); - } - - public static <E, T extends AbstractWrappable<E>> List<T> wrap( - final Collection<E> collection, final Class<T> reference) { - - List<T> response = new ArrayList<T>(); - for (E element : collection) { - response.add(AbstractWrappable.getInstance(reference, element)); - } - return response; - } - - public static <T extends AbstractWrappable<String>> List<String> unwrap(final Collection<T> collection) { - List<String> response = new ArrayList<String>(); - for (T item : collection) { - response.add(item.getElement()); - } - return response; - } - - public static List<AuditLoggerName> wrapLogger(final Collection<LoggerTO> logger) { - List<AuditLoggerName> respons = new ArrayList<AuditLoggerName>(); - for (LoggerTO l : logger) { - try { - respons.add(AuditLoggerName.fromLoggerName(l.getName())); - } catch (Exception ignore) { - // ignore - } - } - return respons; - } - - public static List<LoggerTO> unwrapLogger(final Collection<AuditLoggerName> auditNames) { - List<LoggerTO> respons = new ArrayList<LoggerTO>(); - for (AuditLoggerName l : auditNames) { - LoggerTO loggerTO = new LoggerTO(); - loggerTO.setName(l.toLoggerName()); - loggerTO.setLevel(LoggerLevel.DEBUG); - respons.add(loggerTO); - } - return respons; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/util/LoggerEventUtils.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/util/LoggerEventUtils.java b/common/src/main/java/org/apache/syncope/common/util/LoggerEventUtils.java deleted file mode 100644 index b416dae..0000000 --- a/common/src/main/java/org/apache/syncope/common/util/LoggerEventUtils.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.util; - -import java.util.AbstractMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.common.to.EventCategoryTO; -import org.apache.syncope.common.types.AuditElements; -import org.apache.syncope.common.types.AuditElements.EventCategoryType; -import org.apache.syncope.common.types.AuditElements.Result; - -public class LoggerEventUtils { - - public static Map.Entry<EventCategoryTO, Result> parseEventCategory(final String event) { - final EventCategoryTO eventCategoryTO = new EventCategoryTO(); - - Result condition = null; - - if (StringUtils.isNotEmpty(event)) { - final String[] elements = event.substring(1, event.length() - 1).split("\\]:\\["); - - if (elements.length == 1) { - eventCategoryTO.setType(EventCategoryType.CUSTOM); - condition = Result.SUCCESS; - eventCategoryTO.getEvents().add(event); - } else { - EventCategoryType type; - - if (EventCategoryType.PROPAGATION.toString().equals(elements[0])) { - type = EventCategoryType.PROPAGATION; - } else if (EventCategoryType.SYNCHRONIZATION.toString().equals(elements[0])) { - type = EventCategoryType.SYNCHRONIZATION; - } else if (EventCategoryType.PUSH.toString().equals(elements[0])) { - type = EventCategoryType.PUSH; - } else { - try { - type = EventCategoryType.valueOf(elements[0]); - } catch (Exception e) { - type = EventCategoryType.CUSTOM; - } - } - - eventCategoryTO.setType(type); - - eventCategoryTO.setCategory(StringUtils.isNotEmpty(elements[1]) ? elements[1] : null); - - eventCategoryTO.setSubcategory(StringUtils.isNotEmpty(elements[2]) ? elements[2] : null); - - if (elements.length > 3 && StringUtils.isNotEmpty(elements[3])) { - eventCategoryTO.getEvents().add(elements[3]); - } - - if (elements.length > 4) { - condition = Result.valueOf(elements[4].toUpperCase()); - } - } - } - - return new AbstractMap.SimpleEntry< EventCategoryTO, Result>(eventCategoryTO, condition); - } - - /** - * Build event string with the following syntax [type]:[category]:[subcategory]:[event]:[maybe result value cond]. - * - * @param type event type. - * @param category event category. - * @param subcategory event subcategory. - * @param event event. - * @param resultValueCondition result value condition. - * @return event string. - */ - public static String buildEvent( - final AuditElements.EventCategoryType type, - final String category, - final String subcategory, - final String event, - final AuditElements.Result resultValueCondition) { - - final StringBuilder eventBuilder = new StringBuilder(); - - eventBuilder.append('['); - if (type != null) { - if (StringUtils.isNotBlank(type.toString())) { - eventBuilder.append(type.toString()); - } else { - eventBuilder.append(type.name()); - } - } - eventBuilder.append(']'); - - eventBuilder.append(":"); - - eventBuilder.append('['); - if (StringUtils.isNotBlank(category)) { - eventBuilder.append(category); - } - eventBuilder.append(']'); - - eventBuilder.append(":"); - - eventBuilder.append('['); - if (StringUtils.isNotBlank(subcategory)) { - eventBuilder.append(subcategory); - } - eventBuilder.append(']'); - - eventBuilder.append(":"); - - eventBuilder.append('['); - if (StringUtils.isNotBlank(event)) { - eventBuilder.append(event); - } - eventBuilder.append(']'); - - if (resultValueCondition != null) { - eventBuilder.append(":"); - - eventBuilder.append('['); - eventBuilder.append(resultValueCondition); - eventBuilder.append(']'); - } - - return eventBuilder.toString(); - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/AbstractWrappable.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/AbstractWrappable.java b/common/src/main/java/org/apache/syncope/common/wrap/AbstractWrappable.java deleted file mode 100644 index da52a8f..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/AbstractWrappable.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import org.apache.syncope.common.AbstractBaseBean; - -public abstract class AbstractWrappable<E> extends AbstractBaseBean { - - private static final long serialVersionUID = 1712808704911635170L; - - private E element; - - public static <E, T extends AbstractWrappable<E>> T getInstance(final Class<T> reference, final E element) { - try { - T instance = reference.newInstance(); - instance.setElement(element); - return instance; - } catch (Exception e) { - throw new IllegalArgumentException("Could not instantiate " + reference.getName(), e); - } - } - - public E getElement() { - return element; - } - - public void setElement(final E element) { - this.element = element; - } -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/CorrelationRuleClass.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/CorrelationRuleClass.java b/common/src/main/java/org/apache/syncope/common/wrap/CorrelationRuleClass.java deleted file mode 100644 index 11d99ff..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/CorrelationRuleClass.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "correlationRuleClass") -@XmlType -public class CorrelationRuleClass extends AbstractWrappable<String> { - - private static final long serialVersionUID = -6715106427060816725L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/EntitlementTO.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/EntitlementTO.java b/common/src/main/java/org/apache/syncope/common/wrap/EntitlementTO.java deleted file mode 100644 index 5cde09d..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/EntitlementTO.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "entitlement") -@XmlType -public class EntitlementTO extends AbstractWrappable<String> { - - private static final long serialVersionUID = 7133614577172038452L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/JobClass.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/JobClass.java b/common/src/main/java/org/apache/syncope/common/wrap/JobClass.java deleted file mode 100644 index 340b400..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/JobClass.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "jobClass") -@XmlType -public class JobClass extends AbstractWrappable<String> { - - private static final long serialVersionUID = -1953799905627918822L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/MailTemplate.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/MailTemplate.java b/common/src/main/java/org/apache/syncope/common/wrap/MailTemplate.java deleted file mode 100644 index 7763488..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/MailTemplate.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "mailTemplate") -@XmlType -public class MailTemplate extends AbstractWrappable<String> { - - private static final long serialVersionUID = 7232619557172031478L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/PropagationActionClass.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/PropagationActionClass.java b/common/src/main/java/org/apache/syncope/common/wrap/PropagationActionClass.java deleted file mode 100644 index 89628bf..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/PropagationActionClass.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "propagationActionClass") -@XmlType -public class PropagationActionClass extends AbstractWrappable<String> { - - private static final long serialVersionUID = 2187654394121198308L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/PushActionClass.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/PushActionClass.java b/common/src/main/java/org/apache/syncope/common/wrap/PushActionClass.java deleted file mode 100644 index 1f7b782..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/PushActionClass.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "pushActionClass") -@XmlType -public class PushActionClass extends AbstractWrappable<String> { - - private static final long serialVersionUID = 1669581609310071906L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/ReportletConfClass.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/ReportletConfClass.java b/common/src/main/java/org/apache/syncope/common/wrap/ReportletConfClass.java deleted file mode 100644 index 4328e69..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/ReportletConfClass.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "reportletConfClass") -@XmlType -public class ReportletConfClass extends AbstractWrappable<String> { - - private static final long serialVersionUID = 1343357929074360450L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/ResourceName.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/ResourceName.java b/common/src/main/java/org/apache/syncope/common/wrap/ResourceName.java deleted file mode 100644 index 58eda4e..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/ResourceName.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "resourceName") -@XmlType -public class ResourceName extends AbstractWrappable<String> { - - private static final long serialVersionUID = -175720097924079573L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/SubjectId.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/SubjectId.java b/common/src/main/java/org/apache/syncope/common/wrap/SubjectId.java deleted file mode 100644 index 760e4bd..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/SubjectId.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -public class SubjectId extends AbstractWrappable<Long> { - - private static final long serialVersionUID = -8664228651057889297L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/SyncActionClass.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/SyncActionClass.java b/common/src/main/java/org/apache/syncope/common/wrap/SyncActionClass.java deleted file mode 100644 index 48ff9bb..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/SyncActionClass.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "syncActionClass") -@XmlType -public class SyncActionClass extends AbstractWrappable<String> { - - private static final long serialVersionUID = 1669581609310071905L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/Validator.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/Validator.java b/common/src/main/java/org/apache/syncope/common/wrap/Validator.java deleted file mode 100644 index 39c2c5e..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/Validator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - -@XmlRootElement(name = "validator") -@XmlType -public class Validator extends AbstractWrappable<String> { - - private static final long serialVersionUID = 7233619557177034453L; - -} http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/main/java/org/apache/syncope/common/wrap/package-info.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/syncope/common/wrap/package-info.java b/common/src/main/java/org/apache/syncope/common/wrap/package-info.java deleted file mode 100644 index a70f6eb..0000000 --- a/common/src/main/java/org/apache/syncope/common/wrap/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -@XmlSchema(namespace = SyncopeConstants.NAMESPACE) -package org.apache.syncope.common.wrap; - -import javax.xml.bind.annotation.XmlSchema; -import org.apache.syncope.common.SyncopeConstants; http://git-wip-us.apache.org/repos/asf/syncope/blob/2d194636/common/src/test/java/org/apache/syncope/common/JSONTest.java ---------------------------------------------------------------------- diff --git a/common/src/test/java/org/apache/syncope/common/JSONTest.java b/common/src/test/java/org/apache/syncope/common/JSONTest.java deleted file mode 100644 index 5029b06..0000000 --- a/common/src/test/java/org/apache/syncope/common/JSONTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.syncope.common; - -import static org.junit.Assert.assertEquals; - -import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.StringWriter; -import org.apache.syncope.common.report.UserReportletConf; -import org.apache.syncope.common.to.ReportTO; -import org.apache.syncope.common.to.WorkflowFormPropertyTO; -import org.junit.Test; - -public class JSONTest { - - @Test - public void map() throws IOException { - WorkflowFormPropertyTO prop = new WorkflowFormPropertyTO(); - prop.getEnumValues().put("key1", "value1"); - prop.getEnumValues().put("key2", "value2"); - - ObjectMapper mapper = new ObjectMapper(); - - StringWriter writer = new StringWriter(); - mapper.writeValue(writer, prop); - - WorkflowFormPropertyTO unserializedProp = mapper.readValue(writer.toString(), WorkflowFormPropertyTO.class); - assertEquals(prop, unserializedProp); - } - - @Test - public void reportletConfImplementations() throws IOException { - ReportTO report = new ReportTO(); - report.setName("testReportForCreate"); - report.getReportletConfs().add(new UserReportletConf("first")); - report.getReportletConfs().add(new UserReportletConf("second")); - - ObjectMapper mapper = new ObjectMapper(); - - StringWriter writer = new StringWriter(); - mapper.writeValue(writer, report); - - ReportTO actual = mapper.readValue(writer.toString(), ReportTO.class); - assertEquals(report, actual); - } -}
