| 1 |
/* |
|---|
| 2 |
* (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors. |
|---|
| 3 |
* |
|---|
| 4 |
* All rights reserved. This program and the accompanying materials |
|---|
| 5 |
* are made available under the terms of the GNU Lesser General Public License |
|---|
| 6 |
* (LGPL) version 2.1 which accompanies this distribution, and is available at |
|---|
| 7 |
* http://www.gnu.org/licenses/lgpl.html |
|---|
| 8 |
* |
|---|
| 9 |
* This library is distributed in the hope that it will be useful, |
|---|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 12 |
* Lesser General Public License for more details. |
|---|
| 13 |
* |
|---|
| 14 |
* Contributors: |
|---|
| 15 |
* Nuxeo - initial API and implementation |
|---|
| 16 |
* |
|---|
| 17 |
* $Id$ |
|---|
| 18 |
*/ |
|---|
| 19 |
|
|---|
| 20 |
package org.nuxeo.ecm.platform.ui.web.binding; |
|---|
| 21 |
|
|---|
| 22 |
import java.io.Serializable; |
|---|
| 23 |
|
|---|
| 24 |
import javax.faces.context.FacesContext; |
|---|
| 25 |
import javax.faces.el.MethodBinding; |
|---|
| 26 |
|
|---|
| 27 |
import org.apache.commons.logging.Log; |
|---|
| 28 |
import org.apache.commons.logging.LogFactory; |
|---|
| 29 |
import org.nuxeo.ecm.core.api.Blob; |
|---|
| 30 |
import org.nuxeo.ecm.platform.ui.web.util.ComponentUtils; |
|---|
| 31 |
|
|---|
| 32 |
/** |
|---|
| 33 |
* Download method binding for blobs. |
|---|
| 34 |
* |
|---|
| 35 |
* @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> |
|---|
| 36 |
* @deprecated use now {@link DownloadMethodExpression}. Will be removed in |
|---|
| 37 |
* 5.2. |
|---|
| 38 |
*/ |
|---|
| 39 |
@Deprecated |
|---|
| 40 |
public class DownloadMethodBinding extends MethodBinding implements |
|---|
| 41 |
Serializable { |
|---|
| 42 |
|
|---|
| 43 |
private static final Log log = LogFactory.getLog(DownloadMethodBinding.class); |
|---|
| 44 |
|
|---|
| 45 |
private static final long serialVersionUID = 1L; |
|---|
| 46 |
|
|---|
| 47 |
@SuppressWarnings({ "NonSerializableFieldInSerializableClass" }) |
|---|
| 48 |
// This class is deprecated anyway so ignore the issue. |
|---|
| 49 |
private final Blob blob; |
|---|
| 50 |
|
|---|
| 51 |
private final String filename; |
|---|
| 52 |
|
|---|
| 53 |
public DownloadMethodBinding(Blob blob, String filename) { |
|---|
| 54 |
this.blob = blob; |
|---|
| 55 |
this.filename = filename; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
@Override |
|---|
| 59 |
public Class getType(FacesContext facescontext) { |
|---|
| 60 |
return Void.class; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
@Override |
|---|
| 64 |
public Object invoke(FacesContext context, Object[] aobj) { |
|---|
| 65 |
return ComponentUtils.download(context, blob, filename); |
|---|
| 66 |
} |
|---|
| 67 |
|
|---|
| 68 |
} |
|---|