Added: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/DocumentEvent.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/DocumentEvent.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/DocumentEvent.java (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/DocumentEvent.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.observation;
+
+import org.apache.lenya.cms.publication.ResourceType;
+import org.apache.lenya.cms.repository.Session;
+
+/**
+ * Document-related event.
+ */
+public class DocumentEvent extends RepositoryEvent {
+
+ private String pubId;
+ private String area;
+ private String uuid;
+ private String language;
+ private ResourceType resourceType;
+
+
+ /**
+ * The change action.
+ */
+ public static final Object CHANGED = "changed";
+ /**
+ * The removal action.
+ */
+ public static final Object REMOVED = "removed";
+
+ /**
+ * Ctor.
+ * @param session The session.
+ * @param pubId The publication ID.
+ * @param area The area.
+ * @param uuid The UUID.
+ * @param language The language.
+ * @param resourceType The resource type.
+ * @param descriptor More information about the event, for example
+ * {@link #CHANGED} or {@link #REMOVED}.
+ */
+ public DocumentEvent(Session session, String pubId, String area, String uuid, String language,
+ ResourceType resourceType, Object descriptor) {
+ super(session, descriptor);
+ this.pubId = pubId;
+ this.area = area;
+ this.uuid = uuid;
+ this.language = language;
+ this.resourceType = resourceType;
+ }
+
+ /**
+ * @return The area.
+ */
+ public String getArea() {
+ return area;
+ }
+
+ /**
+ * @return The publication ID.
+ */
+ public String getPublicationId() {
+ return pubId;
+ }
+
+ /**
+ * @return The UUID.
+ */
+ public String getUuid() {
+ return uuid;
+ }
+
+ /**
+ * @return The language.
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * @return The resource type.
+ */
+ public ResourceType getResourceType() {
+ return this.resourceType;
+ }
+
+}
Added: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.observation;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.DocumentImpl;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.Session;
+
+/**
+ * Factory to create repository events.
+ */
+public class RepositoryEventFactory {
+
+ private static final Log logger = LogFactory.getLog(RepositoryEventFactory.class);
+
+ /**
+ * Creates a repository event for a node.
+ * @param session The session.
+ * @param descriptor The descriptor.
+ * @return An event.
+ */
+ public static final RepositoryEvent createEvent(Session session, Object descriptor) {
+ return new RepositoryEvent(session, descriptor);
+ }
+
+ /**
+ * Creates a repository event for a node.
+ * @param doc The document.
+ * @param descriptor The descriptor.
+ * @return An event.
+ */
+ public static final DocumentEvent createEvent(Document doc, Object descriptor) {
+ try {
+ Node node = ((DocumentImpl) doc).getRepositoryNode();
+ DocumentEvent event = new DocumentEvent(node.getRepositorySession(), doc.getPublication()
+ .getId(), doc.getArea(), doc.getUUID(), doc.getLanguage(), doc
+ .getResourceType(), descriptor);
+ event.setNodeUri(node.getSourceURI());
+ int[] revisions = node.getHistory().getRevisionNumbers();
+ if (revisions.length > 0) {
+ event.setRevision(revisions[0]);
+ }
+ return event;
+ } catch (DocumentException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ /**
+ * Creates a repository event for a node.
+ * @param node The node.
+ * @param descriptor The descriptor.
+ * @return An event.
+ */
+ public static final RepositoryEvent createEvent(Node node, Object descriptor) {
+ RepositoryEvent event;
+ Document doc = null;
+ if (!node.getSourceURI().endsWith("meta")) {
+ doc = getDocument(node);
+ }
+ if (doc != null) {
+ event = createEvent(doc, descriptor);
+ } else {
+ event = new RepositoryEvent(node.getRepositorySession(), descriptor);
+ event.setNodeUri(node.getSourceURI());
+ }
+ return event;
+ }
+
+ /**
+ * @param node The node.
+ * @return The document represented by the node or <code>null</code> if the node doesn't
+ * represent a document.
+ */
+ protected static final Document getDocument(Node node) {
+
+ final String sourceUri = node.getSourceURI();
+ if (sourceUri.endsWith(".xml")) {
+ return null;
+ }
+
+ Document doc = null;
+
+ if (!sourceUri.startsWith("lenya://")) {
+ throw new IllegalStateException("The source URI [" + sourceUri
+ + "] doesn't start with lenya://");
+ }
+
+ String path = sourceUri.substring("lenya://lenya/pubs/".length());
+
+ String[] steps = path.split("/");
+ String pubId = steps[0];
+ String area = steps[2];
+
+ try {
+
+ org.apache.lenya.cms.publication.Session session = (org.apache.lenya.cms.publication.Session) node.getRepositorySession();
+ Publication pub = session.getPublication(pubId);
+ String docPath = path.substring((pubId + "/content/" + area).length());
+
+ String uuid = docPath.substring(1, docPath.length() - "/en".length());
+ String language = docPath.substring(docPath.length() - "en".length());
+
+ doc = pub.getArea(area).getDocument(uuid, language);
+
+ if (doc == null) {
+ // this happens if the node was not a document node
+ logger.info("No document found for node [" + sourceUri + "]");
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return doc;
+ }
+
+}
Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryImpl.java Tue Feb 10 01:34:58 2009
@@ -266,7 +266,7 @@
String revisionString = tokenizer.nextToken();
int revision = Integer.valueOf(revisionString).intValue();
- Document document;
+ DocumentImpl document;
try {
Publication publication = getPublication(publicationId);
DocumentBuilder builder = publication.getDocumentBuilder();
@@ -282,7 +282,7 @@
return document;
}
- protected Document buildDocument(DocumentIdentifier identifier, int revision,
+ protected DocumentImpl buildDocument(DocumentIdentifier identifier, int revision,
DocumentBuilder builder) throws DocumentBuildException {
return createDocument(identifier, revision, builder);
}
Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java Tue Feb 10 01:34:58 2009
@@ -34,11 +34,13 @@
import org.apache.lenya.cms.metadata.MetaData;
import org.apache.lenya.cms.metadata.MetaDataCache;
import org.apache.lenya.cms.metadata.MetaDataException;
+import org.apache.lenya.cms.metadata.MetaDataWrapper;
+import org.apache.lenya.cms.observation.Observeable;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
import org.apache.lenya.cms.repository.ContentHolder;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.repository.NodeFactory;
-import org.apache.lenya.cms.repository.RepositoryException;
+import org.apache.lenya.cms.repository.RepositoryItem;
import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.cms.site.Link;
import org.apache.lenya.cms.site.SiteException;
@@ -48,7 +50,7 @@
* A typical CMS document.
* @version $Id$
*/
-public class DocumentImpl implements Document {
+public class DocumentImpl implements Document, RepositoryItem, Observeable {
private static final Log logger = LogFactory.getLog(DocumentImpl.class);
@@ -178,7 +180,7 @@
public long getLastModified() throws DocumentException {
try {
return getRepositoryNode().getLastModified();
- } catch (RepositoryException e) {
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
throw new DocumentException(e);
}
}
@@ -275,7 +277,7 @@
public boolean exists() throws ResourceNotFoundException {
try {
return getRepositoryNode().exists();
- } catch (RepositoryException e) {
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
throw new ResourceNotFoundException(e);
}
}
@@ -413,7 +415,12 @@
}
public MetaData getMetaData(String namespaceUri) throws MetaDataException {
- MetaData meta = getContentHolder().getMetaData(namespaceUri);
+ MetaData meta;
+ try {
+ meta = new MetaDataWrapper(getContentHolder().getMetaData(namespaceUri));
+ } catch (org.apache.lenya.cms.repository.metadata.MetaDataException e) {
+ throw new MetaDataException(e);
+ }
if (getRepositorySession().isModifiable()) {
return meta;
} else {
@@ -428,7 +435,11 @@
}
public String[] getMetaDataNamespaceUris() throws MetaDataException {
- return getContentHolder().getMetaDataNamespaceUris();
+ try {
+ return getContentHolder().getMetaDataNamespaceUris();
+ } catch (org.apache.lenya.cms.repository.metadata.MetaDataException e) {
+ throw new MetaDataException(e);
+ }
}
public String getMimeType() throws DocumentException {
@@ -446,7 +457,7 @@
public long getContentLength() {
try {
return getContentHolder().getContentLength();
- } catch (RepositoryException e) {
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
throw new RuntimeException(e);
}
}
@@ -517,7 +528,7 @@
if (isRevisionSpecified()) {
try {
return node.getHistory().getRevision(revision);
- } catch (RepositoryException e) {
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
throw new RuntimeException(e);
}
} else {
@@ -608,7 +619,7 @@
checkWritability();
try {
return getRepositoryNode().getOutputStream();
- } catch (RepositoryException e) {
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
throw new RuntimeException(e);
}
}
@@ -626,7 +637,7 @@
public InputStream getInputStream() {
try {
return getRepositoryNode().getInputStream();
- } catch (RepositoryException e) {
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
throw new RuntimeException(e);
}
}
@@ -664,12 +675,109 @@
}
public void checkin() throws RepositoryException {
- getRepositoryNode().checkin();
+ try {
+ getRepositoryNode().checkin();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public boolean isCheckedOutBySession(String sessionId, String userId) throws RepositoryException {
+ try {
+ return getRepositoryNode().isCheckedOutBySession(sessionId, userId);
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void checkout() throws RepositoryException {
+ try {
+ getRepositoryNode().checkout();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
}
- public boolean isCheckedOutBySession(org.apache.lenya.cms.publication.Session session)
- throws RepositoryException {
- return getRepositoryNode().isCheckedOutBySession((Session) session);
+ public String getCheckoutUserId() throws RepositoryException {
+ try {
+ return getRepositoryNode().getCheckoutUserId();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public boolean isCheckedOut() throws RepositoryException {
+ try {
+ return getRepositoryNode().isCheckedOut();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void lock() throws RepositoryException {
+ try {
+ getRepositoryNode().lock();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void registerDirty() throws RepositoryException {
+ try {
+ getRepositoryNode().registerDirty();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void unlock() throws RepositoryException {
+ try {
+ getRepositoryNode().unlock();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ private History history;
+
+ public History getHistory() {
+ if (this.history == null) {
+ this.history = new HistoryWrapper(getRepositoryNode().getHistory());
+ }
+ return this.history;
+ }
+
+ public boolean isLocked() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Document getRevision(int i) {
+ return area().getDocument(getUUID(), getLanguage(), i);
+ }
+
+ public void forceCheckIn() throws RepositoryException {
+ try {
+ getRepositoryNode().forceCheckIn();
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void rollback(int revision) throws RepositoryException {
+ try {
+ getRepositoryNode().rollback(revision);
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
+ }
+
+ public void checkout(boolean checkoutRestrictedToSession) throws RepositoryException {
+ try {
+ getRepositoryNode().checkout(checkoutRestrictedToSession);
+ } catch (org.apache.lenya.cms.repository.RepositoryException e) {
+ throw new RepositoryException(e);
+ }
}
}
\ No newline at end of file
Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Tue Feb 10 01:34:58 2009
@@ -192,8 +192,7 @@
}
Document document = areaObj.getDocument(uuid, language);
- Node node = document.getRepositoryNode();
- node.lock();
+ document.lock();
document.setResourceType(documentType);
document.setSourceExtension(extension);
@@ -496,8 +495,8 @@
protected void copyRevisions(Document sourceDoc, Document targetDoc)
throws PublicationException {
try {
- Node targetNode = targetDoc.getRepositoryNode();
- targetNode.copyRevisionsFrom(sourceDoc.getRepositoryNode());
+ Node targetNode = ((DocumentImpl) targetDoc).getRepositoryNode();
+ targetNode.copyRevisionsFrom(((DocumentImpl) sourceDoc).getRepositoryNode());
} catch (Exception e) {
throw new PublicationException(e);
}
Added: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/HistoryWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/HistoryWrapper.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/HistoryWrapper.java (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/HistoryWrapper.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+import org.apache.lenya.cms.repository.RepositoryException;
+
+public class HistoryWrapper implements History {
+
+ private org.apache.lenya.cms.repository.History delegate;
+
+ public HistoryWrapper(org.apache.lenya.cms.repository.History delegate) {
+ this.delegate = delegate;
+ }
+
+ public Revision getLatestRevision() {
+ return new RevisionWrapper(this.delegate.getLatestRevision());
+ }
+
+ public Revision getRevision(int number)
+ throws org.apache.lenya.cms.publication.RepositoryException {
+ try {
+ return new RevisionWrapper(this.delegate.getRevision(number));
+ } catch (RepositoryException e) {
+ throw new org.apache.lenya.cms.publication.RepositoryException(e);
+ }
+ }
+
+ public int[] getRevisionNumbers() {
+ return this.delegate.getRevisionNumbers();
+ }
+
+}
Added: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/IdentityWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/IdentityWrapper.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/IdentityWrapper.java (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/IdentityWrapper.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+import org.apache.lenya.transaction.Identity;
+
+public class IdentityWrapper implements Identity {
+
+ private org.apache.lenya.ac.Identity identity;
+
+ public IdentityWrapper(org.apache.lenya.ac.Identity identity) {
+ this.setIdentity(identity);
+ }
+
+ public void setIdentity(org.apache.lenya.ac.Identity identity) {
+ this.identity = identity;
+ }
+
+ public org.apache.lenya.ac.Identity getIdentity() {
+ return identity;
+ }
+
+ public String getUserId() {
+ return getIdentity().getUser().getId();
+ }
+
+}
Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RepositoryImpl.java Tue Feb 10 01:34:58 2009
@@ -22,13 +22,13 @@
import org.apache.commons.lang.Validate;
import org.apache.lenya.ac.Identity;
-import org.apache.lenya.cms.observation.ObservationRegistry;
import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.SharedItemStore;
-import org.apache.lenya.cms.repository.UUIDGenerator;
+import org.apache.lenya.cms.repository.RepositoryManager;
public class RepositoryImpl implements Repository {
+ private RepositoryManager repositoryManager;
+
public Session getSession(HttpServletRequest request) {
Validate.notNull(request);
SessionImpl session = (SessionImpl) request.getAttribute(Session.class.getName());
@@ -47,45 +47,19 @@
}
public Session startSession(Identity identity, boolean modifiable) {
- SessionImpl session = new SessionImpl(identity, modifiable);
+
+ IdentityWrapper wrapper = new IdentityWrapper(identity);
+ org.apache.lenya.cms.repository.Session repoSession;
try {
- session.setObservationRegistry(getObservationRegistry());
+ repoSession = this.repositoryManager
+ .createSession(wrapper, modifiable);
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
- session.setUuidGenerator(getUuidGenerator());
- session.setSharedItemStore(getSharedItemStore());
+ SessionImpl session = new SessionImpl(this, repoSession);
return session;
}
- private SharedItemStore sharedItemStore;
- private UUIDGenerator uuidGenerator;
- private ObservationRegistry observationRegistry;
-
- protected SharedItemStore getSharedItemStore() {
- return sharedItemStore;
- }
-
- public void setSharedItemStore(SharedItemStore sharedItemStore) {
- this.sharedItemStore = sharedItemStore;
- }
-
- protected UUIDGenerator getUuidGenerator() {
- return uuidGenerator;
- }
-
- public void setUuidGenerator(UUIDGenerator uuidGenerator) {
- this.uuidGenerator = uuidGenerator;
- }
-
- protected ObservationRegistry getObservationRegistry() {
- return observationRegistry;
- }
-
- public void setObservationRegistry(ObservationRegistry observationRegistry) {
- this.observationRegistry = observationRegistry;
- }
-
protected static Identity getIdentity(HttpServletRequest request) {
HttpSession session = request.getSession();
return (Identity) session.getAttribute(Identity.class.getName());
@@ -99,4 +73,12 @@
request.removeAttribute(Session.class.getName());
}
+ public void setRepositoryManager(RepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
+
+ public RepositoryManager getRepositoryManager() {
+ return repositoryManager;
+ }
+
}
Added: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RevisionWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RevisionWrapper.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RevisionWrapper.java (added)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/RevisionWrapper.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.publication;
+
+public class RevisionWrapper implements Revision {
+
+ private org.apache.lenya.cms.repository.Revision delegate;
+
+ public RevisionWrapper(org.apache.lenya.cms.repository.Revision delegate) {
+ this.delegate = delegate;
+ }
+
+ public int getNumber() {
+ return this.delegate.getNumber();
+ }
+
+ public long getTime() {
+ return this.delegate.getTime();
+ }
+
+ public String getUserId() {
+ return this.delegate.getUserId();
+ }
+
+}
Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/SessionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/SessionImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/SessionImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/SessionImpl.java Tue Feb 10 01:34:58 2009
@@ -27,12 +27,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lenya.ac.Identity;
+import org.apache.lenya.cms.observation.DocumentEvent;
import org.apache.lenya.cms.observation.ObservationRegistry;
import org.apache.lenya.cms.observation.RepositoryEvent;
+import org.apache.lenya.cms.observation.RepositoryEventFactory;
import org.apache.lenya.cms.observation.RepositoryListener;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.repository.Persistable;
-import org.apache.lenya.cms.repository.RepositoryException;
import org.apache.lenya.cms.repository.RepositoryItem;
import org.apache.lenya.cms.repository.RepositoryItemFactory;
import org.apache.lenya.cms.repository.RepositoryItemFactoryWrapper;
@@ -49,18 +50,26 @@
import org.apache.lenya.transaction.UnitOfWork;
import org.apache.lenya.transaction.UnitOfWorkImpl;
-public class SessionImpl implements Session, org.apache.lenya.cms.repository.Session {
+public class SessionImpl implements Session {
private static final Log logger = LogFactory.getLog(SessionImpl.class);
+
+ private org.apache.lenya.cms.repository.Session repositorySession;
+ private RepositoryImpl repository;
+ private DocumentFactory documentFactory;
+ private DocumentFactoryBuilder documentFactoryBuilder;
- public SessionImpl(RepositoryImpl repository) {
+
+ public SessionImpl(RepositoryImpl repository, org.apache.lenya.cms.repository.Session repoSession) {
Validate.notNull(repository, "repository");
+ Validate.notNull(repoSession, "repository session");
this.repository = repository;
+ this.repositorySession = repoSession;
}
- private RepositoryImpl repository;
- private DocumentFactory documentFactory;
- private DocumentFactoryBuilder documentFactoryBuilder;
+ protected org.apache.lenya.cms.repository.Session getRepositorySession() {
+ return this.repositorySession;
+ }
public Publication getPublication(String id) {
try {
@@ -89,55 +98,8 @@
return getDocumentFactory().getPublications();
}
- protected static final String UNMODIFIABLE_SESSION_ID = "unmodifiable";
- private Identity identity;
- private ObservationRegistry observationRegistry;
- private UUIDGenerator uuidGenerator;
-
- protected ObservationRegistry getObservationRegistry() {
- return observationRegistry;
- }
-
- protected void setObservationRegistry(ObservationRegistry observationRegistry)
- throws RepositoryException {
- if (this.observationRegistry != null) {
- throw new IllegalStateException("Observation registry already set.");
- }
- this.observationRegistry = observationRegistry;
- addListener(observationRegistry);
- }
-
- protected UUIDGenerator getUuidGenerator() {
- return uuidGenerator;
- }
-
- protected void setUuidGenerator(UUIDGenerator uuidGenerator) {
- this.uuidGenerator = uuidGenerator;
- }
-
- /**
- * Ctor.
- * @param identity The identity.
- * @param modifiable Determines if the repository items in this session can be modified.
- * @param manager The service manager.
- */
- protected SessionImpl(Identity identity, boolean modifiable) {
-
- this.identityMap = new IdentityMapImpl(logger);
- this.identity = identity;
- this.id = modifiable ? createUuid() : UNMODIFIABLE_SESSION_ID;
-
- if (modifiable) {
- this.unitOfWork = new UnitOfWorkImpl(this.identityMap, this.identity, logger);
- }
- }
-
- protected String createUuid() {
- return getUuidGenerator().nextUUID();
- }
-
public Identity getIdentity() {
- return this.identity;
+ return ((IdentityWrapper) getRepositorySession()).getIdentity();
}
private UnitOfWork unitOfWork;
@@ -153,172 +115,33 @@
return this.unitOfWork;
}
- private boolean committing = false;
-
- /**
- * Commits the transaction.
- * @throws RepositoryException if an error occurs.
- * @throws ConcurrentModificationException if a transactionable has been modified by another
- * session.
- */
- public synchronized void commit() throws RepositoryException, ConcurrentModificationException {
-
- savePersistables();
-
- this.committing = true;
+ public String getId() {
+ return getRepositorySession().getId();
+ }
+ public synchronized void commit() throws RepositoryException {
try {
- synchronized (TransactionLock.LOCK) {
-
- getUnitOfWork().commit();
- getSharedItemStore().clear();
- }
- } catch (ConcurrentModificationException e) {
- throw e;
- } catch (TransactionException e) {
+ getRepositorySession().commit();
+ } catch (Exception e) {
throw new RepositoryException(e);
}
-
- for (Iterator i = this.events.iterator(); i.hasNext();) {
- RepositoryEvent event = (RepositoryEvent) i.next();
- for (Iterator l = this.listeners.iterator(); l.hasNext();) {
- RepositoryListener listener = (RepositoryListener) l.next();
- listener.eventFired(event);
- }
- }
- this.events.clear();
- this.committing = false;
}
- /**
- * Save all persistable objects to their nodes.
- * @throws RepositoryException if an error occurs.
- */
- protected void savePersistables() throws RepositoryException {
- Object[] objects = getIdentityMap().getObjects();
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof Node) {
- Node node = (Node) objects[i];
- Persistable persistable = node.getPersistable();
- if (persistable != null && persistable.isModified()) {
- persistable.save();
- }
- }
- }
- }
-
- /**
- * Rolls the transaction back.
- * @throws RepositoryException if an error occurs.
- */
public void rollback() throws RepositoryException {
try {
- synchronized (TransactionLock.LOCK) {
- getUnitOfWork().rollback();
- }
- } catch (TransactionException e) {
+ getRepositorySession().rollback();
+ } catch (Exception e) {
throw new RepositoryException(e);
}
- this.events.clear();
- }
-
- protected SharedItemStore getSharedItemStore() {
- return this.sharedItemStore;
- }
-
- protected void setSharedItemStore(SharedItemStore sharedItemStore) {
- this.sharedItemStore = sharedItemStore;
- }
-
- /**
- * @see org.apache.lenya.cms.repository.Session#getRepositoryItem(org.apache.lenya.cms.repository.RepositoryItemFactory,
- * java.lang.String)
- */
- public RepositoryItem getRepositoryItem(RepositoryItemFactory factory, String key)
- throws RepositoryException {
- RepositoryItemFactoryWrapper wrapper = new RepositoryItemFactoryWrapper(factory, this);
- return (RepositoryItem) getIdentityMap().get(wrapper, key);
- }
-
- public void registerNew(Transactionable object) throws TransactionException {
- getUnitOfWork().registerNew(object);
- }
-
- public void registerDirty(Transactionable object) throws TransactionException {
- getUnitOfWork().registerDirty(object);
- }
-
- public void registerRemoved(Transactionable object) throws TransactionException {
- getUnitOfWork().registerRemoved(object);
}
/**
* @param identity The identity.
*/
public void setIdentity(Identity identity) {
- this.identity = identity;
- }
-
- public boolean isDirty(Transactionable transactionable) {
- return getUnitOfWork().isDirty(transactionable);
- }
-
- public Lock createLock(Lockable lockable, int version) throws TransactionException {
- return getUnitOfWork().createLock(lockable, version);
- }
-
- public void removeLock(Lockable lockable) throws TransactionException {
- getUnitOfWork().removeLock(lockable);
- }
-
- private Set listeners = new HashSet();
-
- public void addListener(RepositoryListener listener) throws RepositoryException {
- if (this.listeners.contains(listener)) {
- throw new RepositoryException("The listener [" + listener
- + "] is already registered for node [" + this + "]!");
- }
- this.listeners.add(listener);
+ getRepositorySession().setIdentity(new IdentityWrapper(identity));
}
- public boolean isListenerRegistered(RepositoryListener listener) {
- return this.listeners.contains(listener);
- }
-
- private List events = new ArrayList();
- private IdentityMap identityMap;
-
- public synchronized void enqueueEvent(RepositoryEvent event) {
- Validate.isTrue(event.getSession() == this, "event belongs to session");
- if (!isModifiable()) {
- throw new RuntimeException("Can't enqueue event in unmodifiable session!");
- }
- if (committing) {
- throw new RuntimeException(
- "No events can be queued while the session is being committed. Event: ["
- + event.getDescriptor() + "]");
- }
- this.events.add(event);
- }
-
- protected IdentityMap getIdentityMap() {
- return this.identityMap;
- }
-
- public boolean isModifiable() {
- return this.unitOfWork != null;
- }
-
- private String id;
-
- public String getId() {
- return this.id;
- }
-
- public String toString() {
- return "Session " + getId();
- }
-
private UriHandler uriHandler;
public UriHandler getUriHandler() {
@@ -328,4 +151,12 @@
return this.uriHandler;
}
+ public void enqueueEvent(Document document, Object descriptor) {
+ DocumentEvent event = RepositoryEventFactory.createEvent(document, descriptor);
+ }
+
+ public boolean isModifiable() {
+ return getRepositorySession().isModifiable();
+ }
+
}
Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/repository/SharedItemStoreImpl.java Tue Feb 10 01:34:58 2009
@@ -18,9 +18,9 @@
package org.apache.lenya.cms.repository;
import org.apache.cocoon.util.AbstractLogEnabled;
-import org.apache.lenya.ac.Identity;
import org.apache.lenya.cms.observation.RepositoryEvent;
import org.apache.lenya.cms.observation.RepositoryListener;
+import org.apache.lenya.transaction.Identity;
import org.apache.lenya.transaction.Lock;
import org.apache.lenya.transaction.Lockable;
import org.apache.lenya.transaction.TransactionException;
Modified: lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/metadata/MetaDataTest.java Tue Feb 10 01:34:58 2009
@@ -50,7 +50,7 @@
namespaceUri = DublinCore.DC_NAMESPACE;
MetaData dc = doc.getMetaData(namespaceUri);
- doc.getRepositoryNode().lock();
+ doc.lock();
checkSetTitle(dc);
checkRemoveAllValues(dc);
Modified: lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/publication/DublinCoreTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/publication/DublinCoreTest.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/publication/DublinCoreTest.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/publication/DublinCoreTest.java Tue Feb 10 01:34:58 2009
@@ -18,12 +18,9 @@
package org.apache.lenya.cms.publication;
-import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.impl.AbstractAccessControlTest;
import org.apache.lenya.cms.metadata.MetaData;
-import org.apache.lenya.cms.metadata.MetaDataException;
import org.apache.lenya.cms.metadata.dublincore.DublinCore;
-import org.apache.lenya.cms.repository.RepositoryException;
/**
* Dublin Core test.
@@ -38,14 +35,9 @@
/**
* Test the fetching, modification and refetching of a dc core object.
- * @throws PublicationException
- * @throws MetaDataException
- * @throws RepositoryException
- * @throws AccessControlException
- * @throws RepositoryException
+ * @throws Exception
*/
- final public void testModifySaveAndReload() throws PublicationException, MetaDataException,
- AccessControlException, RepositoryException {
+ final public void testModifySaveAndReload() throws Exception {
login("lenya");
@@ -53,7 +45,7 @@
Document doc = publication.getArea(AREA).getSite().getNode(PATH).getLink(LANGUAGE).getDocument();
- doc.getRepositoryNode().lock();
+ doc.lock();
MetaData dcCore = doc.getMetaData(DublinCore.DC_NAMESPACE);
String title = dcCore.getFirstValue(DublinCore.ELEMENT_TITLE);
@@ -75,7 +67,7 @@
assertFalse(creator.equals(dcCore2.getFirstValue(DublinCore.ELEMENT_CREATOR)));
assertEquals(newCreator, dcCore2.getFirstValue(DublinCore.ELEMENT_CREATOR));
- doc.getRepositoryNode().unlock();
+ doc.unlock();
}
}
Modified: lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/rc/RCMLTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/rc/RCMLTest.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/rc/RCMLTest.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/cms/rc/RCMLTest.java Tue Feb 10 01:34:58 2009
@@ -65,13 +65,13 @@
try {
org.apache.lenya.cms.publication.Document doc = null;
- doc.getRepositoryNode().checkout();
+ doc.checkout();
(new PrintWriter(System.out)).print(this.document);
System.out.println("\n");
- if (doc.getRepositoryNode().isCheckedOut()) {
+ if (doc.isCheckedOut()) {
System.out.println("Checked out");
} else {
System.out.println("Not checked out");
Modified: lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/MockTransactionable.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/MockTransactionable.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/MockTransactionable.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/MockTransactionable.java Tue Feb 10 01:34:58 2009
@@ -17,6 +17,7 @@
*/
package org.apache.lenya.transaction;
+import org.apache.lenya.cms.publication.IdentityWrapper;
import org.apache.lenya.cms.repository.RepositoryException;
public class MockTransactionable implements Transactionable {
@@ -80,7 +81,8 @@
}
private String getUserId() {
- return ((UnitOfWorkImpl) this.unit).getIdentity().getUser().getId();
+ IdentityWrapper wrapper = (IdentityWrapper) ((UnitOfWorkImpl) this.unit).getIdentity();
+ return wrapper.getIdentity().getUser().getId();
}
private Lock lock;
Modified: lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/TransactionTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/TransactionTest.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/TransactionTest.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/test/java/org/apache/lenya/transaction/TransactionTest.java Tue Feb 10 01:34:58 2009
@@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lenya.ac.Identity;
+import org.apache.lenya.cms.publication.IdentityWrapper;
public class TransactionTest extends ContainerTestCase {
@@ -34,12 +35,12 @@
Identity alice = new Identity(logger);
alice.addIdentifiable(new MockUser("alice"));
- IdentityMap lenyaMap = new IdentityMapImpl(logger);
- UnitOfWork lenyaUnit = new UnitOfWorkImpl(lenyaMap, lenya, logger);
+ IdentityMap lenyaMap = new IdentityMapImpl();
+ UnitOfWork lenyaUnit = new UnitOfWorkImpl(lenyaMap, new IdentityWrapper(lenya));
IdentifiableFactory lenyaFactory = new MockFactory(lenyaUnit);
- IdentityMap aliceMap = new IdentityMapImpl(logger);
- UnitOfWork aliceUnit = new UnitOfWorkImpl(aliceMap, alice, logger);
+ IdentityMap aliceMap = new IdentityMapImpl();
+ UnitOfWork aliceUnit = new UnitOfWorkImpl(aliceMap, new IdentityWrapper(alice));
IdentifiableFactory aliceFactory = new MockFactory(aliceUnit);
MockTransactionable lenyaT1 = (MockTransactionable) lenyaMap.get(lenyaFactory, "t1");
Modified: lenya/trunk/org.apache.lenya.core.repository/pom.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/pom.xml?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/pom.xml (original)
+++ lenya/trunk/org.apache.lenya.core.repository/pom.xml Tue Feb 10 01:34:58 2009
@@ -15,5 +15,13 @@
<packaging>jar</packaging>
<name>Apache Lenya Core Repository API</name>
<dependencies>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/AbstractRepositoryListener.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/AbstractRepositoryListener.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/AbstractRepositoryListener.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/AbstractRepositoryListener.java Tue Feb 10 01:34:58 2009
@@ -17,39 +17,14 @@
*/
package org.apache.lenya.cms.observation;
-import org.apache.avalon.framework.activity.Startable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.util.AbstractLogEnabled;
-
/**
- * Abstract repository listener implementation which registeres with the observation
+ * Abstract repository listener implementation which registers with the observation
* registry at startup.
*/
-public abstract class AbstractRepositoryListener extends AbstractLogEnabled implements Serviceable,
- Startable, ThreadSafe, RepositoryListener {
+public abstract class AbstractRepositoryListener implements RepositoryListener {
- public void start() throws Exception {
- ObservationRegistry registry = null;
- try {
- registry = (ObservationRegistry) this.manager.lookup(ObservationRegistry.ROLE);
- registry.registerListener(this);
- } finally {
- if (registry != null) {
- this.manager.release(registry);
- }
- }
- }
-
- public void stop() throws Exception {
- }
-
- protected ServiceManager manager;
-
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
+ public void setRegistry(ObservationRegistry registry) throws ObservationException {
+ registry.registerListener(this);
}
}
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/ObservationRegistry.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/ObservationRegistry.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/ObservationRegistry.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/ObservationRegistry.java Tue Feb 10 01:34:58 2009
@@ -17,8 +17,6 @@
*/
package org.apache.lenya.cms.observation;
-import org.apache.lenya.cms.publication.Document;
-
/**
* Observation registry.
*/
@@ -31,10 +29,10 @@
/**
* @param listener The listener.
- * @param document The document to listen to.
- * @throws ObservationException if the listener is already registered for this document.
+ * @param observeable The observeable to listen to.
+ * @throws ObservationException if the listener is already registered for this observeable.
*/
- void registerListener(RepositoryListener listener, Document document) throws ObservationException;
+ void registerListener(RepositoryListener listener, Observeable observeable) throws ObservationException;
/**
* Registers a listener which is notified for all events.
Added: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/Observeable.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/Observeable.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/Observeable.java (added)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/Observeable.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.observation;
+
+public interface Observeable {
+
+}
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/RepositoryEvent.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/RepositoryEvent.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/RepositoryEvent.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/observation/RepositoryEvent.java Tue Feb 10 01:34:58 2009
@@ -56,7 +56,7 @@
}
public String toString() {
- return "user:" + getSession().getIdentity().getUser() + " " + getNodeUri() + " " + getDescriptor();
+ return "identity:" + getSession().getIdentity().toString() + " " + getNodeUri() + " " + getDescriptor();
}
private String nodeUri;
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCEnvironment.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCEnvironment.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCEnvironment.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCEnvironment.java Tue Feb 10 01:34:58 2009
@@ -21,28 +21,24 @@
package org.apache.lenya.cms.rc;
import java.io.File;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.commons.logging.Log;
-import org.xml.sax.SAXException;
+import org.apache.commons.logging.LogFactory;
/**
* Helper class that holds the revision controller configuration
*/
-public class RCEnvironment extends AbstractLogEnabled implements Configurable {
-
+public class RCEnvironment {
+
+ private static final Log logger = LogFactory.getLog(RCEnvironment.class);
+
/**
* <code>CONFIGURATION_FILE</code> The configuration file
*/
- public static final String CONFIGURATION_FILE = "lenya" + File.separator + "config" +
- File.separator + "rc" + File.separator + "revision-controller.xconf";
+ public static final String CONFIGURATION_FILE = "lenya" + File.separator + "config"
+ + File.separator + "rc" + File.separator + "revision-controller.xconf";
/**
* <code>RCML_DIRECTORY</code> The RCML directory
*/
@@ -53,9 +49,9 @@
public static final String BACKUP_DIRECTORY = "backup-directory";
private String rcmlDirectory;
private String backupDirectory;
-
+
private static Map instances = new HashMap();
-
+
/**
* Returns the singleton RC environment for this context path.
* @param contextPath The context path (the Lenya webapp directory).
@@ -63,7 +59,7 @@
* @return An RC environment.
*/
public static RCEnvironment getInstance(String contextPath, Log logger) {
- RCEnvironment instance = (RCEnvironment) instances.get(contextPath);
+ RCEnvironment instance = (RCEnvironment) instances.get(contextPath);
if (instance == null) {
instance = new RCEnvironment(contextPath, logger);
instances.put(contextPath, instance);
@@ -77,37 +73,10 @@
* @param logger The logger.
*/
public RCEnvironment(String contextPath, Log logger) {
- getLogger().debug("context path:" + contextPath);
+ logger.debug("context path:" + contextPath);
String configurationFilePath = contextPath + "/" + CONFIGURATION_FILE;
- getLogger().debug("configuration file path:" + configurationFilePath);
-
- File configurationFile = new File(configurationFilePath);
-
- try {
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- Configuration configuration = builder.buildFromFile(configurationFile);
- configure(configuration);
- } catch (final ConfigurationException e) {
- getLogger().error("Cannot load revision controller configuration! ", e);
- } catch (final SAXException e) {
- getLogger().error("Cannot load revision controller configuration! ", e);
- } catch (final IOException e) {
- getLogger().error("Cannot load revision controller configuration! ", e);
- }
- }
-
- /**
- @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
- */
- public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
- throws ConfigurationException {
- // revision controller
- setRCMLDirectory(configuration.getChild("rcmlDirectory").getAttribute("href"));
- setBackupDirectory(configuration.getChild("backupDirectory").getAttribute("href"));
-
- getLogger().debug("CONFIGURATION:\nRCML Directory: href=" + getRCMLDirectory());
- getLogger().debug("CONFIGURATION:\nBackup Directory: href=" + getBackupDirectory());
+ logger.debug("configuration file path:" + configurationFilePath);
}
/**
@@ -118,11 +87,12 @@
return this.rcmlDirectory;
}
- /**
- * Set the rcml directory
- * @param rcmlDir the path to the rcml directory
- */
- protected void setRCMLDirectory(String rcmlDir) {
+ /**
+ * Set the rcml directory
+ * @param rcmlDir the path to the rcml directory
+ * TODO: Bean wiring
+ */
+ public void setRcmlDirectory(String rcmlDir) {
this.rcmlDirectory = rcmlDir;
}
@@ -134,11 +104,12 @@
return this.backupDirectory;
}
- /**
- * Set the backup directory
- * @param backupDir path to the backup directory
- */
- protected void setBackupDirectory(String backupDir) {
+ /**
+ * Set the backup directory
+ * @param backupDir path to the backup directory
+ * TODO: Bean wiring
+ */
+ public void setBackupDirectory(String backupDir) {
this.backupDirectory = backupDir;
}
}
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCML.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCML.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCML.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/rc/RCML.java Tue Feb 10 01:34:58 2009
@@ -23,7 +23,6 @@
import java.util.Vector;
import org.apache.lenya.cms.repository.Node;
-import org.apache.lenya.cms.repository.Session;
/**
* An object of this class handles the revisions of a node. The node is passed as a parameter so an
@@ -161,10 +160,11 @@
boolean isCheckedOut() throws RevisionControlException;
/**
- * @param session The session.
+ * @param sessionId The session ID.
+ * @param userId The user ID.
* @return if the RCML is checked out by this session.
* @throws RevisionControlException if an error occurs.
*/
- boolean isCheckedOutBySession(Session session) throws RevisionControlException;
+ boolean isCheckedOutBySession(String sessionId, String userId) throws RevisionControlException;
}
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/ContentHolder.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/ContentHolder.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/ContentHolder.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/ContentHolder.java Tue Feb 10 01:34:58 2009
@@ -2,7 +2,7 @@
import java.io.InputStream;
-import org.apache.lenya.cms.metadata.MetaDataOwner;
+import org.apache.lenya.cms.repository.metadata.MetaDataOwner;
/**
* Super interface for nodes and revisions.
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Node.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Node.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Node.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Node.java Tue Feb 10 01:34:58 2009
@@ -127,11 +127,12 @@
/**
* Checks if the node is checked out by a certain session. We pass the session
* as a parameter to allow the check for nodes from the shared item store.
- * @param session The session.
+ * @param sessionId The ID of the session.
+ * @param userId The user ID.
* @return if the node is checked out by a specific session.
* @throws RepositoryException if an error occurs.
*/
- boolean isCheckedOutBySession(Session session) throws RepositoryException;
+ boolean isCheckedOutBySession(String sessionId, String userId) throws RepositoryException;
/**
* @param source The node to copy the revisions from.
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryException.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryException.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryException.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryException.java Tue Feb 10 01:34:58 2009
@@ -25,6 +25,8 @@
*/
public class RepositoryException extends TransactionException {
+ private static final long serialVersionUID = 1L;
+
/**
* Ctor.
*/
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManager.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManager.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManager.java Tue Feb 10 01:34:58 2009
@@ -17,7 +17,7 @@
*/
package org.apache.lenya.cms.repository;
-import org.apache.lenya.ac.Identity;
+import org.apache.lenya.transaction.Identity;
/**
* Repository manager.
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/RepositoryManagerImpl.java Tue Feb 10 01:34:58 2009
@@ -17,18 +17,21 @@
*/
package org.apache.lenya.cms.repository;
-import org.apache.cocoon.util.AbstractLogEnabled;
-import org.apache.lenya.ac.Identity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.lenya.cms.observation.ObservationRegistry;
+import org.apache.lenya.transaction.Identity;
/**
* Repository manager implementation.
* @version $Id:$
*/
-public class RepositoryManagerImpl extends AbstractLogEnabled implements RepositoryManager {
-
+public class RepositoryManagerImpl implements RepositoryManager {
+
+ private static final Log logger = LogFactory.getLog(RepositoryManagerImpl.class);
+
public Session createSession(Identity identity, boolean modifiable) throws RepositoryException {
- SessionImpl session = new SessionImpl(identity, modifiable, getLogger());
+ SessionImpl session = new SessionImpl(identity, modifiable);
session.setObservationRegistry(getObservationRegistry());
session.setUuidGenerator(getUuidGenerator());
session.setSharedItemStore(getSharedItemStore());
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Session.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Session.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Session.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/Session.java Tue Feb 10 01:34:58 2009
@@ -17,10 +17,10 @@
*/
package org.apache.lenya.cms.repository;
-import org.apache.lenya.ac.Identity;
import org.apache.lenya.cms.observation.RepositoryEvent;
import org.apache.lenya.cms.observation.RepositoryListener;
import org.apache.lenya.transaction.ConcurrentModificationException;
+import org.apache.lenya.transaction.Identity;
import org.apache.lenya.transaction.UnitOfWork;
/**
@@ -88,4 +88,5 @@
* @return The ID of this session.
*/
String getId();
+
}
Modified: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/SessionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/SessionImpl.java?rev=742811&r1=742810&r2=742811&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/SessionImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/SessionImpl.java Tue Feb 10 01:34:58 2009
@@ -23,14 +23,14 @@
import java.util.List;
import java.util.Set;
-import org.apache.cocoon.util.AbstractLogEnabled;
import org.apache.commons.lang.Validate;
import org.apache.commons.logging.Log;
-import org.apache.lenya.ac.Identity;
+import org.apache.commons.logging.LogFactory;
import org.apache.lenya.cms.observation.ObservationRegistry;
import org.apache.lenya.cms.observation.RepositoryEvent;
import org.apache.lenya.cms.observation.RepositoryListener;
import org.apache.lenya.transaction.ConcurrentModificationException;
+import org.apache.lenya.transaction.Identity;
import org.apache.lenya.transaction.IdentityMap;
import org.apache.lenya.transaction.IdentityMapImpl;
import org.apache.lenya.transaction.Lock;
@@ -44,12 +44,16 @@
/**
* Repository session.
*/
-public class SessionImpl extends AbstractLogEnabled implements Session {
+public class SessionImpl implements Session {
+
+ private static final Log logger = LogFactory.getLog(SessionImpl.class);
protected static final String UNMODIFIABLE_SESSION_ID = "unmodifiable";
private Identity identity;
private ObservationRegistry observationRegistry;
private UUIDGenerator uuidGenerator;
+ private String id;
+ private String userId;
protected ObservationRegistry getObservationRegistry() {
return observationRegistry;
@@ -76,17 +80,15 @@
* Ctor.
* @param identity The identity.
* @param modifiable Determines if the repository items in this session can be modified.
- * @param manager The service manager.
- * @param logger The logger.
*/
- protected SessionImpl(Identity identity, boolean modifiable, Log logger) {
+ protected SessionImpl(Identity identity, boolean modifiable) {
- this.identityMap = new IdentityMapImpl(logger);
+ this.identityMap = new IdentityMapImpl();
this.identity = identity;
this.id = modifiable ? createUuid() : UNMODIFIABLE_SESSION_ID;
if (modifiable) {
- this.unitOfWork = new UnitOfWorkImpl(this.identityMap, this.identity, getLogger());
+ this.unitOfWork = new UnitOfWorkImpl(this.identityMap, this.identity);
}
}
@@ -267,8 +269,6 @@
return this.unitOfWork != null;
}
- private String id;
-
public String getId() {
return this.id;
}
Added: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java (added)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/Element.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository.metadata;
+
+/**
+ * A meta data element.
+ */
+public interface Element {
+
+ /**
+ * @return the name of the element.
+ */
+ String getName();
+
+ /**
+ * @return if the element can have multiple values.
+ */
+ boolean isMultiple();
+
+ /**
+ * @return the description of the element.
+ */
+ String getDescription();
+
+ /**
+ * @return if the element value can be edited.
+ */
+ boolean isEditable();
+
+ /**
+ * Copy all values if the meta data are copied.
+ */
+ int ONCOPY_COPY = 0;
+
+ /**
+ * Don't copy the values of this element if the meta data are copied.
+ */
+ int ONCOPY_IGNORE = 1;
+
+ /**
+ * Delete all values of this element if the meta data are copied.
+ */
+ int ONCOPY_DELETE = 2;
+
+ /**
+ * @return The action to be taken when meta data are copied from one owner to another.
+ */
+ int getActionOnCopy();
+
+ /**
+ * @return If this element shall be included in search queries.
+ */
+ boolean isSearchable();
+
+}
Added: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java (added)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/ElementSet.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository.metadata;
+
+/**
+ * Definition of a set of meta data elements.
+ */
+public interface ElementSet {
+
+ /**
+ * @return The supported elements.
+ */
+ Element[] getElements();
+
+ /**
+ * @param name The name.
+ * @return The element.
+ * @throws MetaDataException if the element with this name does not exist.
+ */
+ Element getElement(String name) throws MetaDataException;
+
+ /**
+ * @return The namespace URI of this element set.
+ */
+ String getNamespaceUri();
+
+ /**
+ * Checks if an element with a certain name is contained.
+ * @param name The name.
+ * @return A boolean value.
+ */
+ boolean containsElement(String name);
+
+}
Added: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java (added)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaData.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository.metadata;
+
+/**
+ * Generic meta data interface.
+ *
+ * @version $Id: MetaData.java 473861 2006-11-12 03:51:14Z gregor $
+ */
+public interface MetaData {
+
+ /**
+ * Returns the values for a certain key.
+ * @param key The key.
+ * @return An array of strings.
+ * @throws MetaDataException when something went wrong.
+ */
+ String[] getValues(String key) throws MetaDataException;
+
+ /**
+ * Returns the first value for a certain key.
+ * @param key The key.
+ * @return A string or <code>null</code> if no value is set for this key.
+ * @throws MetaDataException if an error occurs.
+ */
+ String getFirstValue(String key) throws MetaDataException;
+
+ /**
+ * Get all available keys.
+ * @return The keys available in this MetaData object.
+ */
+ String[] getAvailableKeys();
+
+ /**
+ * Sets the value for a certain key. All existing values will be removed.
+ * @param key The key.
+ * @param value The value to set.
+ * @throws MetaDataException when something went wrong.
+ */
+ void setValue(String key, String value) throws MetaDataException;
+
+ /**
+ * Addds a value for a certain key. The existing values will not be removed.
+ * @param key The key.
+ * @param value The value to add.
+ * @throws MetaDataException if there's already a value set and the element doesn't support multiple values.
+ */
+ void addValue(String key, String value) throws MetaDataException;
+
+ /**
+ * Replace the contents of the current meta data by the contents of other.
+ * @param other The other meta data manager.
+ * @throws MetaDataException if an error occurs.
+ */
+ void replaceBy(MetaData other) throws MetaDataException;
+
+ /**
+ * Replace the contents of the current meta data by the contents of other.
+ * All meta data is replaced, disregarding the rules given by element.getActionOnCopy().
+ * @param other The other meta data manager.
+ * @throws MetaDataException if an error occurs.
+ */
+ void forcedReplaceBy(MetaData other) throws MetaDataException;
+
+ /**
+ * @return All keys that can be used.
+ */
+ String[] getPossibleKeys();
+
+ /**
+ * Checks if a key represents a valid metadata attribute.
+ * @param key The key.
+ * @return A boolean value.
+ */
+ boolean isValidAttribute(String key);
+
+ /**
+ * Get last modification date.
+ * @return last modification date
+ * @throws MetaDataException if an error occurs.
+ */
+ long getLastModified() throws MetaDataException;
+
+ /**
+ * @return The element set this meta data object belongs to.
+ */
+ ElementSet getElementSet();
+
+ /**
+ * Removes all values for a certain key.
+ * @param key The key.
+ * @throws MetaDataException if the key is not supported.
+ */
+ void removeAllValues(String key) throws MetaDataException;
+
+}
Added: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java (added)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataException.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository.metadata;
+
+/**
+ * Meta data exception.
+ */
+public class MetaDataException extends Exception {
+
+ /**
+ *
+ */
+ public MetaDataException() {
+ super();
+ }
+
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public MetaDataException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ /**
+ * @param arg0
+ */
+ public MetaDataException(String arg0) {
+ super(arg0);
+ }
+
+ /**
+ * @param arg0
+ */
+ public MetaDataException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
Added: lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java?rev=742811&view=auto
==============================================================================
--- lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java (added)
+++ lenya/trunk/org.apache.lenya.core.repository/src/main/java/org/apache/lenya/cms/repository/metadata/MetaDataOwner.java Tue Feb 10 01:34:58 2009
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.repository.metadata;
+
+/**
+ * Owner of meta-data.
+ *
+ * @version $Id: MetaDataOwner.java 473861 2006-11-12 03:51:14Z gregor $
+ */
+public interface MetaDataOwner {
+
+ /**
+ * Returns a meta data object.
+ * @param namespaceUri The namespace URI.
+ * @return A meta data object.
+ * @throws MetaDataException if an error occurs.
+ */
+ MetaData getMetaData(String namespaceUri) throws MetaDataException;
+
+ /**
+ * Returns the URIs of the meta data currently supported by the owner.
+ * @return An array of strings.
+ * @throws MetaDataException if an error occurs.
+ */
+ String[] getMetaDataNamespaceUris() throws MetaDataException;
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.