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: r532656 - /lenya/trunk/src/modules-core/sitemanagement/java/src: msg#00193

cms.lenya.cvs

Subject: svn commit: r532656 - /lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java

Author: andreas
Date: Thu Apr 26 01:26:12 2007
New Revision: 532656

URL: http://svn.apache.org/viewvc?view=rev&rev=532656
Log:
Allow to paste documents at top level

Modified:

lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java

Modified:
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java?view=diff&rev=532656&r1=532655&r2=532656
==============================================================================
---
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java
(original)
+++
lenya/trunk/src/modules-core/sitemanagement/java/src/org/apache/lenya/cms/site/usecases/Paste.java
Thu Apr 26 01:26:12 2007
@@ -29,11 +29,13 @@
import org.apache.lenya.cms.publication.DocumentLocator;
import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationException;
+import org.apache.lenya.cms.publication.URLInformation;
import org.apache.lenya.cms.repository.Node;
import org.apache.lenya.cms.site.NodeSet;
import org.apache.lenya.cms.site.SiteException;
import org.apache.lenya.cms.site.SiteUtil;
-import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.usecase.AbstractUsecase;
import org.apache.lenya.cms.usecase.UsecaseException;

/**
@@ -41,7 +43,7 @@
*
* @version $Id$
*/
-public class Paste extends DocumentUsecase {
+public class Paste extends AbstractUsecase {

protected static final String CLIPBOARD_LABEL = "clipboardLabel";

@@ -61,6 +63,20 @@
}
}

+ protected Document getSourceDocument() {
+ Document doc = null;
+ try {
+ DocumentFactory factory = getDocumentFactory();
+ String sourceUrl = getParameterAsString(SOURCE_URL);
+ if (factory.isDocument(sourceUrl)) {
+ doc = factory.getFromURL(sourceUrl);
+ }
+ } catch (DocumentBuildException e) {
+ throw new RuntimeException(e);
+ }
+ return doc;
+ }
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
*/
@@ -69,13 +85,9 @@

Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
if (clipboard != null) {
- if(getSourceDocument() == null) {
- addErrorMessage("No source document");
- return;
- }
String label;
try {
- Publication pub = getSourceDocument().getPublication();
+ Publication pub = getPublication();
label = clipboard.getDocument(getDocumentFactory(),
pub).getLink().getLabel();
} catch (Exception e) {
throw new RuntimeException(e);
@@ -84,6 +96,16 @@
}
}

+ protected Publication getPublication() {
+ URLInformation info = new URLInformation(getSourceURL());
+ String pubId = info.getPublicationId();
+ try {
+ return getDocumentFactory().getPublication(pubId);
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
*/
@@ -91,15 +113,16 @@
List nodes = new ArrayList();

try {
- Node siteNode =
getSourceDocument().area().getSite().getRepositoryNode();
+ Node siteNode = getArea().getSite().getRepositoryNode();
nodes.add(siteNode);

Clipboard clipboard = new
ClipboardHelper().getClipboard(getContext());
DocumentFactory map = getDocumentFactory();
- Publication pub = getSourceDocument().getPublication();
+ Publication pub = getPublication();
Document clippedDocument = clipboard.getDocument(map, pub);

- NodeSet subsite = SiteUtil.getSubSite(this.manager,
clippedDocument.getLink().getNode());
+ NodeSet subsite = SiteUtil
+ .getSubSite(this.manager,
clippedDocument.getLink().getNode());
Document[] subsiteDocs = subsite.getDocuments();

for (int i = 0; i < subsiteDocs.length; i++) {
@@ -115,6 +138,16 @@
return (Node[]) nodes.toArray(new Node[nodes.size()]);
}

+ protected Area getArea() {
+ Publication pub = getPublication();
+ URLInformation info = new URLInformation(getSourceURL());
+ try {
+ return pub.getArea(info.getArea());
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
*/
@@ -123,9 +156,9 @@

DocumentFactory identityMap = getDocumentFactory();
ClipboardHelper helper = new ClipboardHelper();
-
+
Clipboard clipboard = helper.getClipboard(getContext());
- Publication pub = getSourceDocument().getPublication();
+ Publication pub = getPublication();
Document clippedDocument = clipboard.getDocument(identityMap, pub);

final String targetPath = getTargetPath();
@@ -146,7 +179,7 @@
this.manager.release(documentManager);
}
}
-
+
helper.removeClipboard(getContext());
}

@@ -154,19 +187,20 @@
ServiceException, DocumentException {
DocumentFactory identityMap = getDocumentFactory();
Clipboard clipboard = new ClipboardHelper().getClipboard(getContext());
- Publication pub = getSourceDocument().getPublication();
+ Publication pub = getPublication();
Document clippedDocument = clipboard.getDocument(identityMap, pub);

- String targetArea = getSourceDocument().getArea();
+ String targetArea = getArea().getName();
String language = clippedDocument.getLanguage();
String nodeId = clippedDocument.getName();
- String potentialPath = getSourceDocument().getPath() + "/" + nodeId;

- DocumentLocator potentialLoc =
DocumentLocator.getLocator(getSourceDocument().getPublication()
- .getId(),
- targetArea,
- potentialPath,
- language);
+ Document sourceDoc = getSourceDocument();
+ String basePath = sourceDoc != null ? sourceDoc.getPath() : "";
+
+ String potentialPath = basePath + "/" + nodeId;
+
+ DocumentLocator potentialLoc =
DocumentLocator.getLocator(getPublication().getId(),
+ targetArea, potentialPath, language);
return SiteUtil.getAvailableLocator(this.manager,
getDocumentFactory(), potentialLoc)
.getPath();
}


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

Recently Viewed:
solaris.opensol...    editors.vim/200...    web.turbogears....    jakarta.ant.dev...    mathematics.max...    text.unicode.ge...    lang.ruby.core/...    xfce.announce/2...    network.centeri...    php.cvs.pear/20...    user-groups.lin...    kde.devel.quant...    file-systems.ar...    redhat.fedora.t...    apple.fink.auto...    gnome.orbit.gen...    qplus.devel/200...    culture.transpo...    video.dri.user/...    operators.nanog...   
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