You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/06/07 17:19:52 UTC
svn commit: r412423 - in /lenya/trunk/src:
java/org/apache/lenya/cms/editors/InsertAsset.java
java/org/apache/lenya/cms/site/usecases/Assets.java
modules/bxe/usecases/insertAsset.jx
Author: andreas
Date: Wed Jun 7 08:19:52 2006
New Revision: 412423
URL: http://svn.apache.org/viewvc?rev=412423&view=rev
Log:
Asset upload: Completed validation, use name/id of logged-in user as default creator value, don't rely on file parameter when delegating the asset upload from the editor upload screen. This fixes bug 39510.
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/editors/InsertAsset.java
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Assets.java
lenya/trunk/src/modules/bxe/usecases/insertAsset.jx
Modified: lenya/trunk/src/java/org/apache/lenya/cms/editors/InsertAsset.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/editors/InsertAsset.java?rev=412423&r1=412422&r2=412423&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/editors/InsertAsset.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/editors/InsertAsset.java Wed Jun 7 08:19:52 2006
@@ -79,7 +79,7 @@
*/
public void advance() throws UsecaseException {
super.advance();
- if (getParameter("file") != null) {
+ if (getParameterAsBoolean("upload", false)) {
UsecaseInvoker invoker = null;
try {
invoker = (UsecaseInvoker) this.manager.lookup(UsecaseInvoker.ROLE);
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Assets.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Assets.java?rev=412423&r1=412422&r2=412423&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Assets.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Assets.java Wed Jun 7 08:19:52 2006
@@ -23,6 +23,7 @@
import java.util.Map;
import org.apache.cocoon.servlet.multipart.Part;
+import org.apache.lenya.ac.User;
import org.apache.lenya.cms.publication.Resource;
import org.apache.lenya.cms.publication.ResourcesManager;
import org.apache.lenya.cms.repository.Node;
@@ -40,11 +41,22 @@
* @throws UsecaseException if an error occurs.
*/
void validate() throws UsecaseException {
- String title = getParameterAsString("title");
- if (title.length() == 0) {
+ if (getParameterAsString("title").length() == 0) {
addErrorMessage("Please enter a title.");
}
+ if (getParameterAsString("creator").length() == 0) {
+ addErrorMessage("Please enter a creator.");
+ }
+ if (getParameterAsString("rights").length() == 0) {
+ addErrorMessage("Please enter the rights.");
+ }
+
+ Part file = getPart("file");
+ if (file == null) {
+ addErrorMessage("Please choose a file to upload.");
+ }
+
}
/**
@@ -68,6 +80,19 @@
resourcesManager = (ResourcesManager) this.manager.lookup(ResourcesManager.ROLE);
Resource[] resources = resourcesManager.getResources(getSourceDocument());
setParameter("assets", Arrays.asList(resources));
+
+ User user = getSession().getIdentity().getUser();
+ if (user != null) {
+ String creator;
+ String name = user.getName();
+ if (name != null && !name.trim().equals("")) {
+ creator = name;
+ } else {
+ creator = user.getId();
+ }
+ setParameter("creator", creator);
+ }
+
} catch (final Exception e) {
throw new RuntimeException(e);
} finally {
Modified: lenya/trunk/src/modules/bxe/usecases/insertAsset.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/bxe/usecases/insertAsset.jx?rev=412423&r1=412422&r2=412423&view=diff
==============================================================================
--- lenya/trunk/src/modules/bxe/usecases/insertAsset.jx (original)
+++ lenya/trunk/src/modules/bxe/usecases/insertAsset.jx Wed Jun 7 08:19:52 2006
@@ -98,6 +98,7 @@
<form method="POST" enctype="multipart/form-data" id="form-new_asset">
<input type="hidden" name="lenya.usecase" value="${usecase.getName()}"/>
<input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
+ <input type="hidden" name="upload" value="true"/>
<table class="lenya-table-noborder">
<tr>
<td colspan="2">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org