Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Move classes around for clarity, get rid of unused code
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/chemistry/trunk@783850 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Florent Guillaume committed Jun 11, 2009
1 parent 0311afb commit ce3bbda
Show file tree
Hide file tree
Showing 66 changed files with 599 additions and 1,336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
package org.apache.chemistry;

import java.math.BigDecimal;
import java.net.URI;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -48,69 +51,70 @@ public class PropertyType {
* A string property, represented as a {@link String}.
*/
public static final PropertyType STRING = register(new PropertyType(
"string", STRING_ORD));
"string", STRING_ORD, String.class));

/**
* A decimal property, represented as a {@link java.math.BigDecimal
* BigDecimal}.
* A decimal property, represented as a {@link BigDecimal}.
*/
public static final PropertyType DECIMAL = register(new PropertyType(
"decimal", DECIMAL_ORD));
"decimal", DECIMAL_ORD, BigDecimal.class));

/**
* An integer property, represented as a {@link Integer}.
*/
public static final PropertyType INTEGER = register(new PropertyType(
"integer", INTEGER_ORD));
"integer", INTEGER_ORD, Integer.class));

/**
* A boolean property, represented as a {@link Boolean}.
*/
public static final PropertyType BOOLEAN = register(new PropertyType(
"boolean", BOOLEAN_ORD));
"boolean", BOOLEAN_ORD, Boolean.class));

/**
* A date-time property, represented as a {@link java.util.Calendar
* Calendar}.
* A date-time property, represented as a {@link Calendar}.
*/
public static final PropertyType DATETIME = register(new PropertyType(
"datetime", DATETIME_ORD));
"datetime", DATETIME_ORD, Calendar.class));

/**
* A URI property, represented as a {@link java.net.URI URI}.
* A URI property, represented as a {@link URI}.
*/
public static final PropertyType URI = register(new PropertyType("uri",
URI_ORD));
URI_ORD, URI.class));

/**
* An ID property, represented as a {@link String}.
*/
public static final PropertyType ID = register(new PropertyType("id",
ID_ORD));
ID_ORD, String.class));

/**
* An XML property, represented as a String.
*/
public static final PropertyType XML = register(new PropertyType("xml",
XML_ORD));
XML_ORD, String.class));

/**
* An HTML property, represented as a String.
*/
public static final PropertyType HTML = register(new PropertyType("html",
HTML_ORD));
HTML_ORD, String.class));

private final String name;

private final int ordinal;

private final Class<?> klass;

/**
* Protected constructor. The {@link #register} static method should be used
* by implementors to register new property types or subclasses of it.
*/
protected PropertyType(String name, int ordinal) {
protected PropertyType(String name, int ordinal, Class<?> klass) {
this.name = name;
this.ordinal = ordinal;
this.klass = klass;
}

/**
Expand Down Expand Up @@ -140,7 +144,9 @@ protected static synchronized <T extends PropertyType> T register(
* @param name the name
* @return the property type, or {@code null} if not found
*/
public static synchronized PropertyType get(String name) {
// not synchronized, for speed, as we assume this won't be called while
// registration is in progress
public static PropertyType get(String name) {
return all.get(name);
}

Expand All @@ -159,6 +165,13 @@ public int ordinal() {
return ordinal;
}

/**
* The Java class associated to this property type.
*/
public Class<?> klass() {
return klass;
}

@Override
public String toString() {
return this.getClass().getSimpleName() + '(' + name + ')';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Bogdan Stefanescu, Nuxeo
* Florent Guillaume, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -45,12 +45,11 @@
import org.apache.chemistry.Unfiling;
import org.apache.chemistry.VersioningState;
import org.apache.chemistry.atompub.CMIS;
import org.apache.chemistry.atompub.client.ContentManagerException;
import org.apache.chemistry.atompub.client.app.Connector;
import org.apache.chemistry.atompub.client.app.Request;
import org.apache.chemistry.atompub.client.app.Response;
import org.apache.chemistry.atompub.client.common.atom.ReadContext;
import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
import org.apache.chemistry.atompub.client.connector.Connector;
import org.apache.chemistry.atompub.client.connector.Request;
import org.apache.chemistry.atompub.client.connector.Response;
import org.apache.chemistry.atompub.client.stax.ReadContext;
import org.apache.chemistry.atompub.client.stax.XmlProperty;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Authors:
* Bogdan Stefanescu, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Authors:
* Bogdan Stefanescu, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -29,10 +29,9 @@
import org.apache.chemistry.Type;
import org.apache.chemistry.Unfiling;
import org.apache.chemistry.atompub.CMIS;
import org.apache.chemistry.atompub.client.ContentManagerException;
import org.apache.chemistry.atompub.client.app.Request;
import org.apache.chemistry.atompub.client.app.Response;
import org.apache.chemistry.atompub.client.common.atom.ReadContext;
import org.apache.chemistry.atompub.client.connector.Request;
import org.apache.chemistry.atompub.client.connector.Response;
import org.apache.chemistry.atompub.client.stax.ReadContext;

/**
*
Expand Down Expand Up @@ -66,7 +65,7 @@ public List<Folder> getAncestors() {
public List<CMISObject> getChildren(BaseType type) {
// TODO type
String href = entry.getLink(CMIS.LINK_CHILDREN);
Response resp = entry.getConnector().get(new Request(href));
Response resp = entry.connection.getConnector().get(new Request(href));
if (!resp.isOk()) {
throw new ContentManagerException(
"Remote server returned error code: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Bogdan Stefanescu, Nuxeo
* Florent Guillaume, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.io.Serializable;
import java.net.URI;
Expand All @@ -32,11 +32,10 @@
import org.apache.chemistry.RelationshipDirection;
import org.apache.chemistry.Type;
import org.apache.chemistry.atompub.CMIS;
import org.apache.chemistry.atompub.client.ContentManagerException;
import org.apache.chemistry.atompub.client.app.Connector;
import org.apache.chemistry.atompub.client.app.Request;
import org.apache.chemistry.atompub.client.app.Response;
import org.apache.chemistry.atompub.client.common.atom.ReadContext;
import org.apache.chemistry.atompub.client.connector.Connector;
import org.apache.chemistry.atompub.client.connector.Request;
import org.apache.chemistry.atompub.client.connector.Response;
import org.apache.chemistry.atompub.client.stax.ReadContext;
import org.apache.chemistry.impl.base.BaseObject;

/**
Expand Down Expand Up @@ -70,10 +69,6 @@ protected static APPObject construct(APPObjectEntry entry) {
}
}

public Connector getConnector() {
return entry.getConnector();
}

/*
* ----- Object Services -----
*/
Expand All @@ -85,7 +80,7 @@ public void move(Folder targetFolder, Folder sourceFolder) {

public void delete() {
Request req = new Request(entry.getEditLink());
Response resp = getConnector().delete(req);
Response resp = entry.connection.getConnector().delete(req);
if (!resp.isOk()) {
throw new ContentManagerException(
"Remote server returned error code: "
Expand All @@ -106,7 +101,7 @@ public Folder getParent() {
if (href == null) {
return null;
}
APPObjectEntry e = (APPObjectEntry) getConnector().getObject(
APPObjectEntry e = (APPObjectEntry) entry.connection.getConnector().getObject(
new ReadContext(entry.getConnection()), href);
Type t = entry.getConnection().getRepository().getType(e.getTypeId());
APPFolder f = new APPFolder(e, t);
Expand Down Expand Up @@ -185,7 +180,7 @@ protected void create() throws ContentManagerException {
}
Request req = new Request(href);
req.setHeader("Content-Type", "application/atom+xml;type=entry");
Response resp = getConnector().postObject(req, entry);
Response resp = entry.connection.getConnector().postObject(req, entry);
if (!resp.isOk()) {
throw new ContentManagerException(
"Remote server returned error code: "
Expand All @@ -203,7 +198,7 @@ protected void update() throws ContentManagerException {
}
Request req = new Request(href);
req.setHeader("Content-Type", "application/atom+xml;type=entry");
Response resp = getConnector().putObject(req, entry);
Response resp = entry.connection.getConnector().putObject(req, entry);
if (!resp.isOk()) {
throw new ContentManagerException(
"Remote server returned error code: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Bogdan Stefanescu, Nuxeo
* Florent Guillaume, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.io.IOException;
import java.io.Serializable;
Expand All @@ -32,10 +32,9 @@
import org.apache.chemistry.Property;
import org.apache.chemistry.PropertyDefinition;
import org.apache.chemistry.atompub.CMIS;
import org.apache.chemistry.atompub.client.app.Connector;
import org.apache.chemistry.atompub.client.common.atom.ValueAdapter;
import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
import org.apache.chemistry.atompub.client.common.xml.XMLWriter;
import org.apache.chemistry.atompub.client.stax.ValueAdapter;
import org.apache.chemistry.atompub.client.stax.XmlProperty;
import org.apache.chemistry.xml.stax.XMLWriter;

/**
*
Expand Down Expand Up @@ -90,10 +89,6 @@ public String getEditLink() {
return href == null ? getLink("self") : href;
}

public Connector getConnector() {
return connection.getConnector();
}

// -----

public APPConnection getConnection() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
* Bogdan Stefanescu, Nuxeo
* Florent Guillaume, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.util.HashMap;

import javax.xml.stream.XMLStreamException;

import org.apache.chemistry.Type;
import org.apache.chemistry.atompub.client.common.atom.AbstractObjectReader;
import org.apache.chemistry.atompub.client.common.atom.ReadContext;
import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
import org.apache.chemistry.atompub.client.common.xml.StaxReader;
import org.apache.chemistry.atompub.Atom;
import org.apache.chemistry.atompub.client.stax.AbstractObjectReader;
import org.apache.chemistry.atompub.client.stax.ReadContext;
import org.apache.chemistry.atompub.client.stax.XmlProperty;
import org.apache.chemistry.xml.stax.StaxReader;

/**
*
Expand Down Expand Up @@ -61,8 +62,8 @@ protected void readAtomElement(ReadContext ctx, StaxReader reader,
APPObjectEntry object) throws XMLStreamException {
String name = reader.getLocalName();
if ("link".equals(name)) {
String rel = reader.getAttributeValue(ATOM_NS, "rel");
String href = reader.getAttributeValue(ATOM_NS, "href");
String rel = reader.getAttributeValue(Atom.ATOM_NS, "rel");
String href = reader.getAttributeValue(Atom.ATOM_NS, "href");
object.addLink(rel, href);
// } else if ("id".equals(name)) {
// object.id = new URI(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* Authors:
* Bogdan Stefanescu, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.io.IOException;

import org.apache.chemistry.ObjectEntry;
import org.apache.chemistry.atompub.client.common.atom.ObjectEntryWriter;
import org.apache.chemistry.atompub.client.common.xml.XMLWriter;
import org.apache.chemistry.atompub.client.stax.ObjectEntryWriter;
import org.apache.chemistry.xml.stax.XMLWriter;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* Authors:
* Bogdan Stefanescu, Nuxeo
*/
package org.apache.chemistry.atompub.client.app.model;
package org.apache.chemistry.atompub.client;

import java.util.ArrayList;
import java.util.List;

import org.apache.chemistry.ObjectEntry;
import org.apache.chemistry.atompub.client.common.atom.AbstractFeedReader;
import org.apache.chemistry.atompub.client.common.atom.EntryReader;
import org.apache.chemistry.atompub.client.common.xml.StaxReader;
import org.apache.chemistry.atompub.client.stax.AbstractFeedReader;
import org.apache.chemistry.atompub.client.stax.EntryReader;
import org.apache.chemistry.xml.stax.StaxReader;

/**
*
Expand Down
Loading

0 comments on commit ce3bbda

Please sign in to comment.