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> 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 if ((firstValue instanceof Float) || (firstValue instanceof Double)
                        || (firstValue instanceof Byte) || (firstValue instanceof Short)
                        || (firstValue instanceof Integer) || (firstValue instanceof Long)) {
                    // we accept all kinds of integers
                    // as well as floats and doubles
                    List<BigDecimal> list = new ArrayList<BigDecimal>(values.size());
                    for (Object v : values) {
                        list.add(new BigDecimal(v.toString()));
                    }

                    propertyData = bof.createPropertyDecimalData(id, list);
                } 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

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

    }

    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition td, List<String> requestedIds, boolean fillOptionalPropertyData) {
        // build properties collection

        BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
        Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
        so.fillProperties(properties, objectFactory, requestedIds);

        String typeId = so.getTypeId();
        if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, requestedIds)) {
            if (td == null) {
                log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
                        + " is unknown");
            } else {
                String baseTypeId = td.getBaseTypeId().value();
                properties.put(PropertyIds.BASE_TYPE_ID, objectFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID,
                        baseTypeId));
            }
        }
        List<PropertyData<?>> propertiesList = new ArrayList<PropertyData<?>>(properties.values());

        if (fillOptionalPropertyData) {  // add query name, local name, display name
            fillOptionalPropertyData(td, propertiesList);
        }

        Properties props = objectFactory.createPropertiesData(propertiesList);
        return props;
    }
View Full Code Here

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

    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition td,
            Map<String, String> requestedIds, Map<String, String> requestedFuncs) {
        // build properties collection

        List<String> idList = new ArrayList<String>(requestedIds.keySet());
        BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
        Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
        so.fillProperties(properties, objectFactory, idList);

        String typeId = so.getTypeId();
        if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, idList)) {
            if (td == null) {
                log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
                        + " is unknown");
            } else {
                String baseTypeId = td.getBaseTypeId().value();
                properties.put(PropertyIds.BASE_TYPE_ID, objectFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID,
                        baseTypeId));
            }
        }


        Map<String, PropertyData<?>> mappedProperties = new HashMap<String, PropertyData<?>>();
        if (requestedIds.containsKey("*")) {
            for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet()) {
                // map property id to property query name
                String queryName = td.getPropertyDefinitions().get(prop.getKey()).getQueryName();
                String localName = td.getPropertyDefinitions().get(prop.getKey()).getLocalName();
                String displayName = td.getPropertyDefinitions().get(prop.getKey()).getDisplayName();
                AbstractPropertyData<?> ad = (AbstractPropertyData<?>) prop.getValue(); // a bit dirty
                ad.setQueryName(queryName);
                ad.setLocalName(localName);
                ad.setDisplayName(displayName);
                mappedProperties.put(queryName, prop.getValue());
            }
        } else {
            // replace all ids with query names or alias:
            for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet()) {
                String queryNameOrAlias = requestedIds.get(prop.getKey());
                String localName = td.getPropertyDefinitions().get(prop.getKey()).getLocalName();
                String displayName = td.getPropertyDefinitions().get(prop.getKey()).getDisplayName();
                AbstractPropertyData<?> ad = (AbstractPropertyData<?>) prop.getValue(); // a bit dirty
                ad.setQueryName(queryNameOrAlias);
                ad.setLocalName(localName);
                ad.setDisplayName(displayName);
                mappedProperties.put(queryNameOrAlias, prop.getValue());
            }
        }
        // add functions:
        BindingsObjectFactory objFactory = new BindingsObjectFactoryImpl();
        for (Entry<String, String> funcEntry : requestedFuncs.entrySet()) {
            PropertyInteger pi = objFactory.createPropertyIntegerData(funcEntry.getKey(), BigInteger.valueOf(100));
              // fixed dummy value
            mappedProperties.put(funcEntry.getValue(), pi);
        }

        Properties props = new PropertiesImpl(mappedProperties.values());
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();
        RepositoryService repSvc = binding.getRepositoryService();
       
        ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repSvc, repoId);
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

    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition td, List<String> requestedIds,
            boolean fillOptionalPropertyData) {
        // build properties collection

        BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
        Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
        so.fillProperties(properties, objectFactory, requestedIds);

        String typeId = so.getTypeId();
        if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, requestedIds)) {
            if (td == null) {
                log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
                        + " is unknown");
            } else {
                String baseTypeId = td.getBaseTypeId().value();
                properties.put(PropertyIds.BASE_TYPE_ID,
                        objectFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID, baseTypeId));
            }
        }

        // fill not-set properties from type definition (as spec requires)
        Map<String, PropertyDefinition<?>> propDefs = td.getPropertyDefinitions();
        for (PropertyDefinition<?> propDef : propDefs.values()) {
            if (!properties.containsKey(propDef.getId()) && FilterParser.isContainedInFilter(propDef.getId(), requestedIds))
                properties.put(propDef.getId(), getEmptyValue(propDef));
        }

        List<PropertyData<?>> propertiesList = new ArrayList<PropertyData<?>>(properties.values());

        if (fillOptionalPropertyData) { // add query name, local name, display
                                        // name
            fillOptionalPropertyData(td, propertiesList);
        }

        Properties props = objectFactory.createPropertiesData(propertiesList);
        return props;
    }
View Full Code Here

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

    public static Properties getPropertiesFromObject(StoredObject so, TypeDefinition td,
            Map<String, String> requestedIds, Map<String, String> requestedFuncs) {
        // build properties collection

        List<String> idList = new ArrayList<String>(requestedIds.keySet());
        BindingsObjectFactory objectFactory = new BindingsObjectFactoryImpl();
        Map<String, PropertyData<?>> properties = new HashMap<String, PropertyData<?>>();
        so.fillProperties(properties, objectFactory, idList);

        String typeId = so.getTypeId();
        if (FilterParser.isContainedInFilter(PropertyIds.BASE_TYPE_ID, idList)) {
            if (td == null) {
                log.warn("getPropertiesFromObject(), cannot get type definition, a type with id " + typeId
                        + " is unknown");
            } else {
                String baseTypeId = td.getBaseTypeId().value();
                properties.put(PropertyIds.BASE_TYPE_ID,
                        objectFactory.createPropertyIdData(PropertyIds.BASE_TYPE_ID, baseTypeId));
            }
        }

        Map<String, PropertyData<?>> mappedProperties = new HashMap<String, PropertyData<?>>();
        if (requestedIds.containsKey("*")) {
            for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet()) {
                // map property id to property query name
                String queryName = td.getPropertyDefinitions().get(prop.getKey()).getQueryName();
                String localName = td.getPropertyDefinitions().get(prop.getKey()).getLocalName();
                String displayName = td.getPropertyDefinitions().get(prop.getKey()).getDisplayName();
                AbstractPropertyData<?> ad = (AbstractPropertyData<?>) prop.getValue(); // a
                                                                                        // bit
                                                                                        // dirty
                ad.setQueryName(queryName);
                ad.setLocalName(localName);
                ad.setDisplayName(displayName);
                mappedProperties.put(queryName, prop.getValue());
            }
        } else {
            // replace all ids with query names or alias:
            for (Map.Entry<String, PropertyData<?>> prop : properties.entrySet()) {
                String queryNameOrAlias = requestedIds.get(prop.getKey());
                String localName = td.getPropertyDefinitions().get(prop.getKey()).getLocalName();
                String displayName = td.getPropertyDefinitions().get(prop.getKey()).getDisplayName();
                AbstractPropertyData<?> ad = (AbstractPropertyData<?>) prop.getValue(); // a
                                                                                        // bit
                                                                                        // dirty
                ad.setQueryName(queryNameOrAlias);
                ad.setLocalName(localName);
                ad.setDisplayName(displayName);
                mappedProperties.put(queryNameOrAlias, prop.getValue());
            }
        }
        // add functions:
        BindingsObjectFactory objFactory = new BindingsObjectFactoryImpl();
        for (Entry<String, String> funcEntry : requestedFuncs.entrySet()) {
            PropertyInteger pi = objFactory.createPropertyIntegerData(funcEntry.getKey(), BigInteger.valueOf(100));
            // fixed dummy value
            mappedProperties.put(funcEntry.getValue(), pi);
        }

        Properties props = new PropertiesImpl(mappedProperties.values());
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.