Package com.bradmcevoy.http.values

Examples of com.bradmcevoy.http.values.ValueAndType


            if( !properties.isEmpty() ) {
                XmlWriter.Element elPropStat = writer.begin(WebDavProtocol.NS_DAV.getPrefix(), "propstat" ).open();
                XmlWriter.Element elProp = writer.begin(WebDavProtocol.NS_DAV.getPrefix(), "prop" ).open();
                for( QName qname : properties.keySet() ) {
                    String prefix = mapOfNamespaces.get( qname.getNamespaceURI() );
                    ValueAndType val = properties.get( qname );
                    valueWriters.writeValue( writer, qname, prefix, val, href, mapOfNamespaces );
                }
                elProp.close();
                writer.writeProperty( WebDavProtocol.NS_DAV.getPrefix(), "status", status.toString() );
                elPropStat.close();
View Full Code Here


        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

        }
        Iterator<QName> it = requestedFields.iterator();
        while (it.hasNext()) {
            QName field = it.next();
            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

          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

        if (where != null && where.length() > 0) {
            boolean negate = where.startsWith("!");
            if (negate) {
                where = where.substring(1);
            }
            ValueAndType prop;
            QName qnWhere = parseQName(where);
            Iterator<PropFindResponse> it = results.iterator();
            boolean removeValue = negate;
            while (it.hasNext()) {
                PropFindResponse result = it.next();
View Full Code Here

     * @param qnWhere
     * @param result
     * @return
     */
    private boolean eval(QName qnWhere, PropFindResponse result) {
        ValueAndType prop = result.getKnownProperties().get(qnWhere);
        if (prop != null) {
            Object val = prop.getValue();
            if (val != null && val instanceof Boolean) {
                Boolean b = (Boolean) val;
                return b;
            } else {
                return false;
View Full Code Here

TOP

Related Classes of com.bradmcevoy.http.values.ValueAndType

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.