Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r427143 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/p: msg#00285

cms.lenya.cvs

Subject: svn commit: r427143 - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/publication/ pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/

Author: andreas
Date: Mon Jul 31 08:36:28 2006
New Revision: 427143

URL: http://svn.apache.org/viewvc?rev=427143&view=rev
Log:
Added methods to Document to retrieve a version in a different area+language

Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java

lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java

lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java

Modified:
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java?rev=427143&r1=427142&r2=427143&view=diff
==============================================================================
---
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
(original)
+++
lenya/trunk/src/impl/java/org/apache/lenya/cms/publication/DocumentImpl.java
Mon Jul 31 08:36:28 2006
@@ -652,4 +652,21 @@
return pub.getSourceURI() + "/content/" + area + "/" + path;
}

+ public boolean existsVersion(String area, String language) {
+ String sourceUri = getSourceURI(getPublication(), area, getUUID(),
language);
+ try {
+ return SourceUtil.exists(sourceUri, this.manager);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Document getVersion(String area, String language) throws
DocumentException {
+ try {
+ return getFactory().get(getPublication(), area, getUUID(),
language);
+ } catch (DocumentBuildException e) {
+ throw new DocumentException(e);
+ }
+ }
+
}

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?rev=427143&r1=427142&r2=427143&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Mon Jul
31 08:36:28 2006
@@ -285,4 +285,21 @@
*/
Document getAreaVersion(String area) throws DocumentException;

+ /**
+ * Checks if a translation of this document exists in a certain area.
+ * @param area The area.
+ * @param language The language.
+ * @return A boolean value.
+ */
+ boolean existsVersion(String area, String language);
+
+ /**
+ * Returns a translation of this document in a certain area.
+ * @param area The area.
+ * @param language The language.
+ * @return A document.
+ * @throws DocumentException if the area version doesn't exist.
+ */
+ Document getVersion(String area, String language) throws DocumentException;
+
}

Modified:
lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?rev=427143&r1=427142&r2=427143&view=diff
==============================================================================
---
lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
(original)
+++
lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
Mon Jul 31 08:36:28 2006
@@ -64,26 +64,30 @@
String event = getEvent();
boolean allowSingle = true;

- if (!WorkflowUtil.canInvoke(this.manager,
- getSession(),
- getLogger(),
- getSourceDocument(),
- event)) {
- allowSingle = false;
- addInfoMessage("The single document cannot be deactivated
because the workflow event cannot be invoked.");
- }
-
- DocumentFactory map = getSourceDocument().getFactory();
- Document liveDoc = map.getAreaVersion(getSourceDocument(),
Publication.LIVE_AREA);
- DocumentSet subSite = SiteUtil.getSubSite(this.manager, liveDoc);
- SiteNode node = NodeFactory.getNode(liveDoc);
- subSite.removeAll(SiteUtil.getExistingDocuments(map, node));
-
- if (!subSite.isEmpty()) {
- allowSingle = false;
- addInfoMessage("You have to deactivate the whole subtree
because descendants are live.");
+ if (!getSourceDocument().existsAreaVersion(Publication.LIVE_AREA))
{
+ addErrorMessage("This usecase can only be invoked when the
live version exists.");
+ } else {
+ if (!WorkflowUtil.canInvoke(this.manager,
+ getSession(),
+ getLogger(),
+ getSourceDocument(),
+ event)) {
+ allowSingle = false;
+ addInfoMessage("The single document cannot be deactivated
because the workflow event cannot be invoked.");
+ }
+
+ DocumentFactory map = getSourceDocument().getFactory();
+ Document liveDoc =
getSourceDocument().getAreaVersion(Publication.LIVE_AREA);
+ DocumentSet subSite = SiteUtil.getSubSite(this.manager,
liveDoc);
+ SiteNode node = NodeFactory.getNode(liveDoc);
+ subSite.removeAll(SiteUtil.getExistingDocuments(map, node));
+
+ if (!subSite.isEmpty()) {
+ allowSingle = false;
+ addInfoMessage("You have to deactivate the whole subtree
because descendants are live.");
+ }
+ setParameter(Publish.ALLOW_SINGLE_DOCUMENT,
Boolean.toString(allowSingle));
}
- setParameter(Publish.ALLOW_SINGLE_DOCUMENT,
Boolean.toString(allowSingle));
}
}

@@ -98,13 +102,13 @@
Document doc = getSourceDocument();
set.addAll(SiteUtil.getSubSite(this.manager, doc));

- Document liveDoc = doc.getFactory().getAreaVersion(doc,
Publication.LIVE_AREA);
+ Document liveDoc = doc.getAreaVersion(Publication.LIVE_AREA);
set.addAll(SiteUtil.getSubSite(this.manager, liveDoc));

Document[] documents = set.getDocuments();
for (int i = 0; i < documents.length; i++) {
nodes.add(documents[i].getRepositoryNode());
- nodes.addAll(AssetUtil.getAssetNodes(documents[i],
this.manager, getLogger()));
+ nodes.addAll(AssetUtil.getAssetNodes(documents[i],
this.manager, getLogger()));
}

nodes.add(SiteUtil.getSiteStructure(this.manager,
liveDoc).getRepositoryNode());
@@ -137,11 +141,10 @@
boolean success = false;

DocumentManager documentManager = null;
- SourceResolver resolver = null;
- Source source = null;
+ SourceResolver resolver = null;
+ Source source = null;
try {
- Document liveDocument = authoringDocument.getFactory()
- .getAreaVersion(authoringDocument, Publication.LIVE_AREA);
+ Document liveDocument =
authoringDocument.getAreaVersion(Publication.LIVE_AREA);

documentManager = (DocumentManager)
this.manager.lookup(DocumentManager.ROLE);
documentManager.delete(liveDocument);
@@ -156,12 +159,12 @@
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
- if (resolver != null) {
- if (source != null) {
- resolver.release(source);
- }
- this.manager.release(resolver);
- }
+ if (resolver != null) {
+ if (source != null) {
+ resolver.release(source);
+ }
+ this.manager.release(resolver);
+ }
if (getLogger().isDebugEnabled()) {
getLogger().debug("Deactivate document [" + authoringDocument
+ "]. Success: ["
+ success + "]");
@@ -243,16 +246,16 @@
WorkflowException {
String[] languages = document.getPublication().getLanguages();
for (int i = 0; i < languages.length; i++) {
- Document version =
document.getFactory().getLanguageVersion(document, languages[i]);
- if (version.exists()
- && WorkflowUtil.canInvoke(this.manager,
- getSession(),
- getLogger(),
- version,
- getEvent())) {
- deactivate(version);
+ if (document.existsVersion(Publication.LIVE_AREA, languages[i])) {
+ Document version = document.getVersion(Publication.LIVE_AREA,
languages[i]);
+ if (WorkflowUtil.canInvoke(this.manager,
+ getSession(),
+ getLogger(),
+ version,
+ getEvent())) {
+ deactivate(version);
+ }
}
}
}
-
}

Modified:
lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?rev=427143&r1=427142&r2=427143&view=diff
==============================================================================
---
lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
(original)
+++
lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
Mon Jul 31 08:36:28 2006
@@ -31,7 +31,7 @@
import org.apache.lenya.ac.Identifiable;
import org.apache.lenya.ac.User;
import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentLocator;
import org.apache.lenya.cms.publication.DocumentManager;
@@ -40,9 +40,9 @@
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.util.DocumentSet;
import org.apache.lenya.cms.publication.util.DocumentVisitor;
-import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.NodeFactory;
import org.apache.lenya.cms.site.SiteManager;
+import org.apache.lenya.cms.site.SiteNode;
import org.apache.lenya.cms.site.SiteUtil;
import org.apache.lenya.cms.site.usecases.AssetUtil;
import org.apache.lenya.cms.usecase.DocumentUsecase;
@@ -151,8 +151,6 @@
Publication publication = document.getPublication();
DocumentFactory map = document.getFactory();

- Document liveDocument = map.getAreaVersion(document,
Publication.LIVE_AREA);
-
List missingDocuments = new ArrayList();

ServiceSelector selector = null;
@@ -161,7 +159,10 @@
selector = (ServiceSelector)
this.manager.lookup(SiteManager.ROLE + "Selector");
siteManager = (SiteManager)
selector.select(publication.getSiteManagerHint());

- SiteNode liveNode = NodeFactory.getNode(liveDocument);
+ String path = SiteUtil.getPath(this.manager, document);
+ SiteNode liveNode =
NodeFactory.getNode(document.getPublication(),
+ Publication.LIVE_AREA,
+ path);
SiteNode[] requiredNodes =
siteManager.getRequiredResources(map, liveNode);

for (int i = 0; i < requiredNodes.length; i++) {
@@ -174,8 +175,8 @@
if (authoringDoc.exists()) {
missingDocuments.add(authoringDoc);
} else {
-
missingDocuments.add(map.getLanguageVersion(authoringDoc,
-
authoringDoc.getPublication().getDefaultLanguage()));
+
missingDocuments.add(authoringDoc.getTranslation(authoringDoc.getPublication()
+ .getDefaultLanguage()));
}
}

@@ -268,12 +269,11 @@
}
}

- protected void sendNotification(Document authoringDocument) throws
DocumentBuildException,
- NotificationException {
+ protected void sendNotification(Document authoringDocument) throws
NotificationException,
+ DocumentException {
User sender = getSession().getIdentity().getUser();
Identifiable[] recipients = { sender };
- Document liveVersion =
getDocumentFactory().getAreaVersion(authoringDocument,
- Publication.LIVE_AREA);
+ Document liveVersion =
authoringDocument.getAreaVersion(Publication.LIVE_AREA);

String url;

@@ -353,8 +353,7 @@
Document parent = document.getFactory().get(parentLocator);
boolean publish = true;
if (parent != null) {
- Document liveParent =
parent.getFactory().getAreaVersion(parent,
- Publication.LIVE_AREA);
+ Document liveParent =
parent.getAreaVersion(Publication.LIVE_AREA);
if (!liveParent.exists()) {
publish = false;
}
@@ -380,9 +379,8 @@

try {
for (int i = 0; i < languages.length; i++) {
- Document version =
document.getFactory().getLanguageVersion(document,
- languages[i]);
- if (version.exists()) {
+ if (document.existsTranslation(languages[i])) {
+ Document version = document.getTranslation(languages[i]);
if (WorkflowUtil.canInvoke(this.manager,
getSession(),
getLogger(),


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
user-groups.jax...    php.zend.framew...    os.solaris.open...    web.quixote.use...    java.openjdk.ho...    ietf.secmech/20...    gnu.glpk/2004-0...    recreation.cars...    network.smokepi...    linux.drivers.i...    cms.opencms.dev...    fonts.gfontview...    text.xml.soap.u...    voip.nist-sip/2...    debian.ports.hp...    xfree86.interna...    science.biology...    qnx.openqnx.dev...    mail.sylpheed.c...    busybox/bios/20...    emulators.kvm.s...    hardware.openco...    apple.fink.begi...    kde.german/2006...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation