Package org.apache.abdera.factory

Examples of org.apache.abdera.factory.Factory


    @Test
    public void testPost() throws Exception {
        //System.out.println(">>>ContentNegotiationTest.testPost");
        // Testing of entry creation
        Factory factory = abdera.getFactory();
        String customerName = "Fred Farkle";
        Entry entry = factory.newEntry();
        entry.setTitle("customer " + customerName);
        entry.setUpdated(new Date());
        entry.addAuthor("Apache Tuscany");
        // ID created by collection.
        Content content = abdera.getFactory().newContent();
View Full Code Here


        Book b = new Book();
        b.setId(id);
        b.setName(name);
       
       
        Factory factory = Abdera.getNewFactory();
        JAXBContext jc = JAXBContext.newInstance(Book.class);
       
        Entry e = factory.getAbdera().newEntry();
        e.setTitle(b.getName());
        e.setId(Long.toString(b.getId()));
       
       
        StringWriter writer = new StringWriter();
        jc.createMarshaller().marshal(b, writer);
       
        e.setContentElement(factory.newContent());
        e.getContentElement().setContentType(Content.Type.XML);
        e.getContentElement().setValue(writer.toString());
       
        return e;
    }  
View Full Code Here

       
        return doGetBookAsFeed(uParam);
    }
   
    private Feed doGetBookAsFeed(@Context UriInfo uParam) {
        Factory factory = Abdera.getNewFactory();
        Feed f = factory.newFeed();
        f.setBaseUri(uParam.getAbsolutePath().toString());
        f.setTitle("Collection of Books");
        f.setId("http://www.books.com");
        f.addAuthor("BookStore Management Company");
        try {
View Full Code Here

        if (isFeed && isCollection) {
            reportError("Atom feed can only be created from a collection wrapper", null);
        } else if (!isFeed && isCollection) {
            reportError("Atom entry can only be created from a single object", null);
        }
        Factory factory = Abdera.getNewFactory();
       
        Element atomElement = null;
        try {
            if (isFeed && !isCollection) {
                atomElement = createFeedFromCollectionWrapper(factory, o, cls);
View Full Code Here

        // Does the resource already exist?  If so this is an update (PUT) not a create (POST)
        boolean alreadyExists = resourceExists(suggestedPath);

        AbderaClient abderaClient = new AbderaClient(abdera);
        final Factory factory = abdera.getFactory();
        boolean isCollection = resource instanceof Collection;

        ExtensibleElement element;
        if (isCollection) {
            Feed feed = factory.newFeed();
            feed.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
//            feed.setId(encodeURL(suggestedPath));
            feed.setTitle(suggestedPath);
            feed.setSubtitle(resource.getDescription());
            feed.addAuthor(username);
            feed.setUpdated(new Date());
            element = feed;
        } else {
            Entry entry = factory.newEntry();
            entry.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
//            entry.setId(encodeURL(suggestedPath));
            entry.setTitle(suggestedPath);
            entry.setSummary(resource.getDescription());
            entry.addAuthor(username);
View Full Code Here

        if (Pattern.matches("\\p{Alnum}*[~!@#$%^&*()\\+=\\-;<>\\s?\\[\\]{},/\\\\\"\',]+\\p{Alnum}*",
                relativePath)) {
            throw new RegistryException("Invalid characters have been used in the resource name.");
        }
        AbderaClient abderaClient = new AbderaClient(abdera);
        final Factory factory = abdera.getFactory();
        Entry entry = factory.newEntry();
        entry.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
        entry.setTitle(suggestedPath);
        entry.setSummary(resource.getDescription());
        entry.addAuthor(username);
        entry.setUpdated(new Date());
View Full Code Here

    }

    public void addAssociation(String sourcePath, String associationPaths, String associationType)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        final Factory factory = abdera.getFactory();
        Element el = factory.newElement(APPConstants.QN_ASSOC);
        el.setAttributeValue(APPConstants.ASSOC_TYPE, associationType);
        el.setText(associationPaths);
        ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
                encodeURL(sourcePath +
                        RegistryConstants.URL_SEPARATOR +
View Full Code Here

    public void removeAssociation(String sourcePath, String associationPaths,
                                  String associationType)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        final Factory factory = abdera.getFactory();
        Element el = factory.newElement(APPConstants.QN_ASSOC);
        el.setAttributeValue(APPConstants.ASSOC_TYPE, associationType);
        el.setText(associationPaths);
        RequestOptions requestOptions = getAuthorization();
        requestOptions.setHeader("Destination", associationPaths);
        requestOptions.setHeader("AssociationType", associationType);
View Full Code Here

  private FOMFactory getFomFactory(ParserOptions options) {
    FOMFactory factory =
      (options != null && options.getFactory() != null) ?
        (FOMFactory)options.getFactory() : null;
    if (factory == null) {
      Factory f = getFactory();
      factory = (f instanceof FOMFactory) ?
        (FOMFactory)f : new FOMFactory();
    }
    return factory;
  }
View Full Code Here

    /**
     * Constructor the user will be using inside javaScript
     */
    public Scriptable jsConstructor() {
        Abdera abdera = new Abdera();
        Factory factory = abdera.getFactory();
        feed = factory.newFeed();
        return this;
    }
View Full Code Here

TOP

Related Classes of org.apache.abdera.factory.Factory

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.