Examples of BindingsObjectFactory


Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

    public Acl convertAces(List<Ace> aces) {
        if (aces == null) {
            return null;
        }

        BindingsObjectFactory bof = getBindingsObjectFactory();

        List<Ace> providerAces = new ArrayList<Ace>();
        for (Ace ace : aces) {
            providerAces.add(bof.createAccessControlEntry(ace.getPrincipalId(), ace.getPermissions()));
        }

        return bof.createAccessControlList(providerAces);
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

        return bof.createAccessControlList(providerAces);
    }

    public Ace createAce(String principal, List<String> permissions) {
        BindingsObjectFactory bof = getBindingsObjectFactory();

        Ace ace = bof.createAccessControlEntry(principal, permissions);

        return ace;
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

        return ace;
    }

    public Acl createAcl(List<Ace> aces) {
        BindingsObjectFactory bof = getBindingsObjectFactory();

        Acl acl = bof.createAccessControlList(aces);

        return acl;
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

            type = session.getTypeDefinition(typeId.toString());
        }

        // some preparation
        BindingsObjectFactory bof = getBindingsObjectFactory();
        List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();

        // the big loop
        for (Map.Entry<String, ?> property : properties.entrySet()) {
            if ((property == null) || (property.getKey() == null)) {
                continue;
            }

            String id = property.getKey();
            Object value = property.getValue();

            if (value instanceof Property<?>) {
                Property<?> p = (Property<?>) value;
                if (!id.equals(p.getId())) {
                    throw new IllegalArgumentException("Property id mismatch: '" + id + "' != '" + p.getId() + "'!");
                }
                value = (p.getDefinition().getCardinality() == Cardinality.SINGLE ? p.getFirstValue() : p.getValues());
            }

            // get the property definition
            PropertyDefinition<?> definition = type.getPropertyDefinitions().get(id);
            if (definition == null) {
                throw new IllegalArgumentException("Property +'" + id + "' is not valid for this type!");
            }

            // check updatability
            if (updatabilityFilter != null) {
                if (!updatabilityFilter.contains(definition.getUpdatability())) {
                    continue;
                }
            }

            // single and multi value check
            List<?> values;
            if (value == null) {
                values = null;
            } else if (value instanceof List<?>) {
                if (definition.getCardinality() != Cardinality.MULTI) {
                    throw new IllegalArgumentException("Property '" + id + "' is not a multi value property!");
                }
                values = (List<?>) value;

                // check if the list is homogeneous and does not contain null
                // values
                Class<?> valueClazz = null;
                for (Object o : values) {
                    if (o == null) {
                        throw new IllegalArgumentException("Property '" + id + "' contains null values!");
                    }
                    if (valueClazz == null) {
                        valueClazz = o.getClass();
                    } else {
                        if (!valueClazz.isInstance(o)) {
                            throw new IllegalArgumentException("Property '" + id + "' is inhomogeneous!");
                        }
                    }
                }
            } else {
                if (definition.getCardinality() != Cardinality.SINGLE) {
                    throw new IllegalArgumentException("Property '" + id + "' is not a single value property!");
                }
                values = Collections.singletonList(value);
            }

            // assemble property
            PropertyData<?> propertyData = null;
            Object firstValue = (values == null || values.isEmpty() ? null : values.get(0));

            if (definition instanceof PropertyStringDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyStringData(id, (List<String>) null);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyStringData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a String property!");
                }
            } else if (definition instanceof PropertyIdDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyIdData(id, (List<String>) null);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyIdData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is an Id property!");
                }
            } else if (definition instanceof PropertyHtmlDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyHtmlData(id, (List<String>) values);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyHtmlData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a HTML property!");
                }
            } else if (definition instanceof PropertyUriDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyUriData(id, (List<String>) null);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyUriData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is an URI property!");
                }
            } else if (definition instanceof PropertyIntegerDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyIntegerData(id, (List<BigInteger>) null);
                } else if (firstValue instanceof BigInteger) {
                    propertyData = bof.createPropertyIntegerData(id, (List<BigInteger>) values);
                } else if ((firstValue instanceof Byte) || (firstValue instanceof Short)
                        || (firstValue instanceof Integer) || (firstValue instanceof Long)) {
                    // we accept all kinds of integers
                    List<BigInteger> list = new ArrayList<BigInteger>(values.size());
                    for (Object v : values) {
                        list.add(BigInteger.valueOf(((Number) v).longValue()));
                    }

                    propertyData = bof.createPropertyIntegerData(id, list);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is an Integer property!");
                }
            } else if (definition instanceof PropertyBooleanDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyBooleanData(id, (List<Boolean>) null);
                } else if (firstValue instanceof Boolean) {
                    propertyData = bof.createPropertyBooleanData(id, (List<Boolean>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a Boolean property!");
                }
            } else if (definition instanceof PropertyDecimalDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyDecimalData(id, (List<BigDecimal>) null);
                } else if (firstValue instanceof BigDecimal) {
                    propertyData = bof.createPropertyDecimalData(id, (List<BigDecimal>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
                }
            } else if (definition instanceof PropertyDateTimeDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyDateTimeData(id, (List<GregorianCalendar>) null);
                } else if (firstValue instanceof GregorianCalendar) {
                    propertyData = bof.createPropertyDateTimeData(id, (List<GregorianCalendar>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
                }
            }

            // do we have something?
            if (propertyData == null) {
                throw new IllegalArgumentException("Property '" + id + "' doesn't match the property defintion!");
            }

            propertyList.add(propertyData);
        }

        return bof.createPropertiesData(propertyList);
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

          // create an initial temporary service instance to fill the repository
         
          InMemoryService svc = new InMemoryService(inMemoryServiceParameters, storeManager);
                 
          BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();

          String levelsStr = parameters.get(ConfigConstants.FILLER_DEPTH);
          int levels = 1;
          if (null != levelsStr)
              levels = Integer.parseInt(levelsStr);
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

    private static ObjectGenerator createObjectGenerator(CmisBinding binding, String repoId, int docsPerFolder,
            int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
            String rootFolderId, boolean doCleanup) {

        BindingsObjectFactory objectFactory = binding.getObjectFactory();
        NavigationService navSvc = binding.getNavigationService();
        ObjectService objSvc = binding.getObjectService();

        ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repoId);
        gen.setUseUuidsForNames(true);
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

    public Acl convertAces(List<Ace> aces) {
        if (aces == null) {
            return null;
        }

        BindingsObjectFactory bof = getBindingsObjectFactory();

        List<Ace> bindingAces = new ArrayList<Ace>();
        for (Ace ace : aces) {
            bindingAces.add(bof.createAccessControlEntry(ace.getPrincipalId(), ace.getPermissions()));
        }

        return bof.createAccessControlList(bindingAces);
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

        return bof.createAccessControlList(bindingAces);
    }

    public Ace createAce(String principal, List<String> permissions) {
        BindingsObjectFactory bof = getBindingsObjectFactory();

        Ace ace = bof.createAccessControlEntry(principal, permissions);

        return ace;
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

        return ace;
    }

    public Acl createAcl(List<Ace> aces) {
        BindingsObjectFactory bof = getBindingsObjectFactory();

        Acl acl = bof.createAccessControlList(aces);

        return acl;
    }
View Full Code Here

Examples of org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory

            type = session.getTypeDefinition(typeId.toString());
        }

        // some preparation
        BindingsObjectFactory bof = getBindingsObjectFactory();
        List<PropertyData<?>> propertyList = new ArrayList<PropertyData<?>>();

        // the big loop
        for (Map.Entry<String, ?> property : properties.entrySet()) {
            if ((property == null) || (property.getKey() == null)) {
                continue;
            }

            String id = property.getKey();
            Object value = property.getValue();

            if (value instanceof Property<?>) {
                Property<?> p = (Property<?>) value;
                if (!id.equals(p.getId())) {
                    throw new IllegalArgumentException("Property id mismatch: '" + id + "' != '" + p.getId() + "'!");
                }
                value = (p.getDefinition().getCardinality() == Cardinality.SINGLE ? p.getFirstValue() : p.getValues());
            }

            // get the property definition
            PropertyDefinition<?> definition = type.getPropertyDefinitions().get(id);
            if (definition == null) {
                throw new IllegalArgumentException("Property '" + id + "' is not valid for this type!");
            }

            // check updatability
            if (updatabilityFilter != null) {
                if (!updatabilityFilter.contains(definition.getUpdatability())) {
                    continue;
                }
            }

            // single and multi value check
            List<?> values;
            if (value == null) {
                values = null;
            } else if (value instanceof List<?>) {
                if (definition.getCardinality() != Cardinality.MULTI) {
                    throw new IllegalArgumentException("Property '" + id + "' is not a multi value property!");
                }
                values = (List<?>) value;

                // check if the list is homogeneous and does not contain null
                // values
                Class<?> valueClazz = null;
                for (Object o : values) {
                    if (o == null) {
                        throw new IllegalArgumentException("Property '" + id + "' contains null values!");
                    }
                    if (valueClazz == null) {
                        valueClazz = o.getClass();
                    } else {
                        if (!valueClazz.isInstance(o)) {
                            throw new IllegalArgumentException("Property '" + id + "' is inhomogeneous!");
                        }
                    }
                }
            } else {
                if (definition.getCardinality() != Cardinality.SINGLE) {
                    throw new IllegalArgumentException("Property '" + id + "' is not a single value property!");
                }
                values = Collections.singletonList(value);
            }

            // assemble property
            PropertyData<?> propertyData = null;
            Object firstValue = (values == null || values.isEmpty() ? null : values.get(0));

            if (definition instanceof PropertyStringDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyStringData(id, (List<String>) null);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyStringData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a String property!");
                }
            } else if (definition instanceof PropertyIdDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyIdData(id, (List<String>) null);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyIdData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is an Id property!");
                }
            } else if (definition instanceof PropertyHtmlDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyHtmlData(id, (List<String>) values);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyHtmlData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a HTML property!");
                }
            } else if (definition instanceof PropertyUriDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyUriData(id, (List<String>) null);
                } else if (firstValue instanceof String) {
                    propertyData = bof.createPropertyUriData(id, (List<String>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is an URI property!");
                }
            } else if (definition instanceof PropertyIntegerDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyIntegerData(id, (List<BigInteger>) null);
                } else if (firstValue instanceof BigInteger) {
                    propertyData = bof.createPropertyIntegerData(id, (List<BigInteger>) values);
                } else if ((firstValue instanceof Byte) || (firstValue instanceof Short)
                        || (firstValue instanceof Integer) || (firstValue instanceof Long)) {
                    // we accept all kinds of integers
                    List<BigInteger> list = new ArrayList<BigInteger>(values.size());
                    for (Object v : values) {
                        list.add(BigInteger.valueOf(((Number) v).longValue()));
                    }

                    propertyData = bof.createPropertyIntegerData(id, list);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is an Integer property!");
                }
            } else if (definition instanceof PropertyBooleanDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyBooleanData(id, (List<Boolean>) null);
                } else if (firstValue instanceof Boolean) {
                    propertyData = bof.createPropertyBooleanData(id, (List<Boolean>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a Boolean property!");
                }
            } else if (definition instanceof PropertyDecimalDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyDecimalData(id, (List<BigDecimal>) null);
                } else if (firstValue instanceof BigDecimal) {
                    propertyData = bof.createPropertyDecimalData(id, (List<BigDecimal>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a Decimal property!");
                }
            } else if (definition instanceof PropertyDateTimeDefinition) {
                if (firstValue == null) {
                    propertyData = bof.createPropertyDateTimeData(id, (List<GregorianCalendar>) null);
                } else if (firstValue instanceof GregorianCalendar) {
                    propertyData = bof.createPropertyDateTimeData(id, (List<GregorianCalendar>) values);
                } else {
                    throw new IllegalArgumentException("Property '" + id + "' is a DateTime property!");
                }
            }

            // do we have something?
            if (propertyData == null) {
                throw new IllegalArgumentException("Property '" + id + "' doesn't match the property defintion!");
            }

            propertyList.add(propertyData);
        }

        return bof.createPropertiesData(propertyList);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.