Package com.bradmcevoy.property.PropertySource

Examples of com.bradmcevoy.property.PropertySource.PropertyMetaData


        }
    }

    public PropertyMetaData getPropertyMetaData( QName name ) {
        if( name.getNamespaceURI().equals( NS_EXAMPLE ) ) {
            return new PropertyMetaData( PropertyAccessibility.WRITABLE, String.class );
        } else {
            return PropertyMetaData.UNKNOWN;
        }
    }
View Full Code Here


    }

    public ValueAndType getProperty(QName field, Resource resource) throws NotAuthorizedException {
        log.debug("num property sources: " + propertySources.size());
        for (PropertySource source : propertySources) {
            PropertyMetaData meta = source.getPropertyMetaData(field, resource);
            if (meta != null && !meta.isUnknown()) {
                Object val = source.getProperty(field, resource);
                return new ValueAndType(val, meta.getValueType());
            }
        }
        return null;
    }
View Full Code Here

            if (field.getLocalPart().equals("href")) {
                knownProperties.put(field, new ValueAndType(href, String.class));
            } else {
                boolean found = false;
                for (PropertySource source : propertySources) {
                    PropertyMetaData meta = source.getPropertyMetaData(field, resource);
                    if (meta != null && !meta.isUnknown()) {
                        Object val;
                        try {
                            val = source.getProperty( field, resource );
                            knownProperties.put(field, new ValueAndType(val, meta.getValueType()));
                        } catch( NotAuthorizedException ex ) {
                            unknownProperties.add(new NameAndError(field, "Not authorised"));
                        }
                        found = true;
                        break;
View Full Code Here

    Map<Status, List<NameAndError>> errorProps = new EnumMap<Status, List<NameAndError>>(Status.class);
    for (Entry<QName, String> entry : parseResult.getFieldsToSet().entrySet()) {
      QName name = entry.getKey();
      boolean found = false;
      for (PropertySource source : propertySources) {
        PropertyMetaData meta = source.getPropertyMetaData(entry.getKey(), r);
        if (meta != null && !meta.isUnknown()) {
          found = true;
          if (meta.isWritable()) {
            Object val = parse(name, entry.getValue(), meta.getValueType());
            try {
              log.trace("setProperties: setProperty: name: {} source: []", name, source);
              source.setProperty(name, val, r);
              knownProps.put(name, new ValueAndType(null, meta.getValueType()));
              break;
            } catch (NotAuthorizedException e) {
              log.trace("setProperties: NotAuthorised to write property: {}", name, e);
              addErrorProp(errorProps, Response.Status.SC_UNAUTHORIZED, name, "Not authorised");
              break;
            } catch (PropertySetException ex) {
              log.trace("setProperties: PropertySetException when writing property {}", name, ex);
              addErrorProp(errorProps, ex.getStatus(), name, ex.getErrorNotes());
              break;
            }
          } else {
            log.debug("property is not writable in source: " + source.getClass());
            addErrorProp(errorProps, Response.Status.SC_FORBIDDEN, name, "Property is read only");
            break;
          }
        } else {
          //log.debug( "not found in: " + source.getClass().getCanonicalName() );
        }
      }
      if (!found) {
        log.debug("property not found: " + entry.getKey());
        addErrorProp(errorProps, Status.SC_NOT_FOUND, entry.getKey(), "Unknown property");
      }
    }
    if (parseResult.getFieldsToRemove() != null) {
      for (QName name : parseResult.getFieldsToRemove()) {
        boolean found = false;
        for (PropertySource source : propertySources) {
          PropertyMetaData meta = source.getPropertyMetaData(name, r);
          if (meta != null && !meta.isUnknown()) {
            found = true;
            if (meta.isWritable()) {
              try {
                log.trace("clearProperty");
                source.clearProperty(name, r);
                knownProps.put(name, new ValueAndType(null, meta.getValueType()));
                break;
              } catch (NotAuthorizedException e) {
                addErrorProp(errorProps, Response.Status.SC_UNAUTHORIZED, name, "Not authorised");
                break;
              } catch (PropertySetException ex) {
View Full Code Here

        StandardProperty pa = writersMap.get( name.getLocalPart() );
        if( pa == null ) {
            return PropertyMetaData.UNKNOWN;
        } else {
            if( r instanceof PropFindableResource ) {
                return new PropertyMetaData( PropertyAccessibility.READ_ONLY, pa.getValueClass() );
            } else {
                return PropertyMetaData.UNKNOWN;
            }
        }
    }
View Full Code Here

        }
    }

    public PropertyMetaData getPropertyMetaData( QName name ) {
        if( name.getNamespaceURI().equals( NS_EXAMPLE ) ) {
            return new PropertyMetaData( PropertyAccessibility.WRITABLE, String.class );
        } else {
            return PropertyMetaData.UNKNOWN;
        }
    }
View Full Code Here

TOP

Related Classes of com.bradmcevoy.property.PropertySource.PropertyMetaData

Copyright © 2018 www.massapicom. 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.