+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.eclipse.ui.specific;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.argeo.ArgeoException;
-import org.argeo.eclipse.ui.FileProvider;
-import org.eclipse.rap.rwt.service.ServiceHandler;
-
-@Deprecated
-public class DownloadServiceHandler implements ServiceHandler {
-
- private FileProvider provider;
-
- public DownloadServiceHandler(FileProvider provider) {
- this.provider = provider;
- }
-
- public void service(HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException {
- // Which file to download?
- String fileName = request.getParameter("filename");
- String fileId = request.getParameter("fileid");
-
- // Get the file content
- byte[] download = provider.getByteArrayFileFromId(fileId);
-
- // Send the file in the response
- response.setContentType("application/octet-stream");
- response.setContentLength(download.length);
- String contentDisposition = "attachment; filename=\"" + fileName + "\"";
- response.setHeader("Content-Disposition", contentDisposition);
-
- // Various header fields that can be set to solve some issues with some
- // old browsers.
- // Unused.
- // String contentType = "application/force-download; name=\"" + fileName
- // + "\"";
- // response.setContentType(contentType);
- // response.setHeader("Content-Transfer-Encoding", "binary");
- // response.setHeader("Pragma", "no-cache");
- // response.setHeader("Cache-Control", "no-cache, must-revalidate");
- // response.setHeader("Expires", "0");
- // response.setHeader("Connection", "Keep-Alive");
- // response.setHeader("Keep-Alive", "timeout=5, max=86");
- // response.setHeader("transfer-Encoding", "chunked");
-
- try {
- response.getOutputStream().write(download);
- } catch (IOException ioe) {
- throw new ArgeoException("Error while writing the file " + fileName
- + " to the servlet response", ioe);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.eclipse.ui.specific;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.argeo.eclipse.ui.FileProvider;
-import org.eclipse.rap.rwt.RWT;
-import org.eclipse.rap.rwt.client.service.UrlLauncher;
-import org.eclipse.rap.rwt.service.ServiceHandler;
-
-/**
- * RAP SPECIFIC handler to enable the opening of a download dialog box triggered
- * by whatever action in the UI
- *
- * Manages the registration of the effective DownloadServiceHandler at
- * instantiation time.
- *
- * Manages the process of forwarding the request to the handler at runtime to
- * open the dialog box encodedURL
- */
-@Deprecated
-public class FileHandler {
- public final static String DOWNLOAD_SERVICE_NAME = "argeo.rap.download.service";
- private final static Log log = LogFactory.getLog(FileHandler.class);
-
- public FileHandler(FileProvider provider) {
- ServiceHandler handler = new DownloadServiceHandler(provider);
- try {
- RWT.getServiceManager().registerServiceHandler(
- DOWNLOAD_SERVICE_NAME, handler);
- } catch (IllegalArgumentException iae) {
- log.warn("Handler is already registered, clean this registering process");
- }
- }
-
- public void openFile(String fileName, String fileId) {
- try {
- String downloadUrl = RWT.getServiceManager().getServiceHandlerUrl(
- DOWNLOAD_SERVICE_NAME)
- + createParamUrl(fileName, fileId);
- if (log.isTraceEnabled())
- log.debug("URL : " + downloadUrl);
- UrlLauncher launcher = RWT.getClient()
- .getService(UrlLauncher.class);
- launcher.openURL(downloadUrl);
- } catch (Exception e) {
- throw new ArgeoException("Unable to open file " + fileName, e);
- }
- // These lines are useless in the current use case but might be
- // necessary with new browsers. Stored here for memo
- // response.setContentType("application/force-download");
- // response.setHeader("Content-Disposition", contentDisposition);
- // response.setHeader("Content-Transfer-Encoding", "binary");
- // response.setHeader("Pragma", "no-cache");
- // response.setHeader("Cache-Control", "no-cache, must-revalidate");
- }
-
- private String createParamUrl(String filename, String fileId) {
- StringBuilder url = new StringBuilder();
- url.append("&filename=");
- url.append(filename);
- url.append("&fileid=");
- url.append(fileId);
- return url.toString();
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.eclipse.ui.specific;
-
-import java.io.InputStream;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-//import org.eclipse.rap.rwt.widgets.Upload;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-public class GenericUploadControl extends Composite {
- private final static Log log = LogFactory
- .getLog(GenericUploadControl.class);
-
- //private Upload upload;
-
- public GenericUploadControl(Composite parent, int style, String browseLabel) {
- super(parent, style);
- createControl(this, browseLabel);
-
- }
-
- private void createControl(Composite parent, String browseLabel) {
- parent.setLayout(new GridLayout(1, false));
- parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
-// upload = new Upload(parent, SWT.BORDER);
-// upload.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-// upload.setBrowseButtonText(browseLabel);
- // upload.addModifyListener(new UploadListener());
- parent.pack();
- }
-
- /**
- * Wrap upload.getLastFileUploaded(). Gets the name of the last uploaded
- * file. This method can be called even if the upload has not finished yet.
- */
- public String getLastFileUploadedName() {
- return "";
- }
-
- public boolean isControlEmpty() {
- String path = "";
- if (log.isTraceEnabled())
- log.trace("UploadControl chosen path : " + path);
- if (path == null || "".equals(path.trim()))
- return true;
- else
- return false;
- }
-
- public byte[] performUpload() {
-// boolean success = upload.performUpload();
-// if (success) {
-// if (upload.getUploadItem().getFileSize() == -1)
-// throw new ArgeoException("File "
-// + upload.getUploadItem().getFileName()
-// + " has not been uploaded, its size is -1");
-//
-// InputStream inStream = null;
-// byte[] fileBA = null;
-// try {
-// inStream = upload.getUploadItem().getFileInputStream();
-// fileBA = IOUtils.toByteArray(inStream);
-// } catch (Exception e) {
-// throw new ArgeoException("Cannot read uploaded data", e);
-// } finally {
-// IOUtils.closeQuietly(inStream);
-// }
-// return fileBA;
-// }
- return null;
- }
-
- public void addModifyListener(ModifyListener listener) {
-// upload.addModifyListener(listener);
- }
-
- // private class UploadManager extends UploadAdapter {
- // private Upload upload;
- //
- // public UploadManager(Upload upload) {
- // super();
- // this.upload = upload;
- // }
- //
- // public void uploadFinished(UploadEvent uploadEvent) {
- // handleUploadFinished(upload);
- // }
- //
- // public void uploadInProgress(UploadEvent uploadEvent) {
- // }
- //
- // public void uploadException(UploadEvent uploadEvent) {
- // Exception exc = uploadEvent.getUploadException();
- // if (exc != null) {
- // MessageDialog.openError(Display.getCurrent().getActiveShell(),
- // "Error", exc.getMessage());
- // }
- // }
- //
- // }
- //
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed 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.argeo.eclipse.ui.specific;
-
-import java.io.InputStream;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.eclipse.jface.wizard.WizardPage;
-//import org.eclipse.rap.rwt.widgets.Upload;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-public class ImportToServerWizardPage extends WizardPage {
- private final static Log log = LogFactory
- .getLog(ImportToServerWizardPage.class);
-
- public final static String FILE_ITEM_TYPE = "FILE";
- public final static String FOLDER_ITEM_TYPE = "FOLDER";
-
- //private Upload uploadFile;
-
- public ImportToServerWizardPage() {
- super("Import from file system");
- setDescription("Import files from the local file system to the server");
- }
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- new Label(composite, SWT.NONE).setText("Pick up a file");
-// uploadFile = new Upload(composite, SWT.BORDER);
-// uploadFile.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-// uploadFile.setBrowseButtonText("Open...");
- setControl(composite);
- }
-
- public String getObjectPath() {
- // NOTE Returns the full file name of the last uploaded file including
- // the file path as selected by the user on his local machine.
- // The full path including the directory and file drive are only
- // returned, if the browser supports reading this properties. In Firefox
- // 3, only the filename is returned.
- return null;
- }
-
- public String getObjectName() {
- return null;
- }
-
- public String getObjectType() {
- return FILE_ITEM_TYPE;
- }
-
- public void performFinish() {
-// boolean success = uploadFile.performUpload();
-// if (!success)
-// throw new ArgeoException("Cannot upload file named "
-// + uploadFile.getPath());
- }
-
-// protected void handleUploadFinished(final Upload upload) {
-// }
-
- public InputStream getFileInputStream() {
- return null;
- }
-
- public boolean getNeedsProgressMonitor() {
- return false;
- }
-
-}
import org.eclipse.rap.rwt.client.service.UrlLauncher;
/**
- * Rap specific command handler to open a file retrieved from the server. It
+ * RWT specific command handler to open a file retrieved from the server. It
* forwards the request to the correct service after encoding file name and path
* in the request URI.
*
+ * <p>
* The parameter "URI" is used to determine the correct file service, the path
* and the file name. An optional file name can be precized to present a
* different file name as the one used to retrieve it to the end user.
+ * </p>
*
+ * <p>
* Various instances of this handler with different command ID might coexist in
* order to provide context specific download service.
+ * </p>
*
+ * <p>
* The instance specific service is called by its ID and must have been
* externally created
+ * </p>
*/
public class OpenFile extends AbstractHandler {
private final static Log log = LogFactory.getLog(OpenFile.class);
String fileName = event.getParameter(PARAM_FILE_NAME);
String fileUri = event.getParameter(PARAM_FILE_URI);
- // sanity check
+ // Sanity check
if (fileUri == null || "".equals(fileUri.trim())
|| openFileServiceId == null
|| "".equals(openFileServiceId.trim()))
import org.eclipse.rap.rwt.service.ServiceHandler;
/**
- * Basic Default service handler that retrieves a file on the server file system
- * using its absolute path and forwards it to the end user browser. Rap
- * specific.
+ * RWT specific Basic Default service handler that retrieves a file on the
+ * server file system using its absolute path and forwards it to the end user
+ * browser.
*
- * Clients might extend to provide context specific services (to open files from
- * a JCR repository for instance)
+ * Clients might extend to provide context specific services
*/
public class OpenFileService implements ServiceHandler {
public final static String PARAM_FILE_NAME = "param.fileName";
String contentDisposition = "attachment; filename=\"" + fileName + "\"";
response.setHeader("Content-Disposition", contentDisposition);
+ // Useless for current use
+ // response.setContentType("application/force-download");
+ // response.setHeader("Content-Transfer-Encoding", "binary");
+ // response.setHeader("Pragma", "no-cache");
+ // response.setHeader("Cache-Control", "no-cache, must-revalidate");
+
+ // TODO use buffered array to directly write the stream?
response.getOutputStream().write(getFileAsByteArray(uri));
- // FileUtils.readFileToByteArray(new File(path))
}
+ /**
+ * Retrieves the data as Byte Array given an uri.
+ *
+ * <p>
+ * Overwrite to provide application specific abilities, among other to open
+ * from a JCR repository
+ * </p>
+ */
protected byte[] getFileAsByteArray(String uri) {
if (uri.startsWith(FILE_SCHEME)) {
try {
return FileUtils.readFileToByteArray(new File(
getFilePathFromUri(uri)));
} catch (IOException ioe) {
- throw new ArgeoException("Error while getting the file at "
- + uri, ioe);
+ throw new ArgeoException("Error getting the file at " + uri,
+ ioe);
}
}
return null;
private String getFilePathFromUri(String uri) {
return uri.substring((FILE_SCHEME + SCHEME_HOST_SEPARATOR).length());
}
-
}
\ No newline at end of file
this(DEFAULT_BUNDLE_LOCATION, type, false);
}
- @SuppressWarnings("unchecked")
@Override
protected T initialValue() {
if (utf8)
*/
package org.argeo.eclipse.ui.specific;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.rap.addons.fileupload.FileDetails;
+import org.eclipse.rap.addons.fileupload.FileUploadEvent;
+import org.eclipse.rap.addons.fileupload.FileUploadHandler;
+import org.eclipse.rap.addons.fileupload.FileUploadListener;
+import org.eclipse.rap.addons.fileupload.FileUploadReceiver;
+import org.eclipse.rap.rwt.service.ServerPushSession;
import org.eclipse.rap.rwt.widgets.FileUpload;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+/**
+ * RWT Specific convenience page that provides a simple interface to upload one
+ * file in a wizard context
+ *
+ * TODO Finalize clean and refactoring using the latest rap version and upload
+ * dialog addons
+ *
+ */
public class UploadFileWizardPage extends WizardPage {
// private final static Log log = LogFactory
// .getLog(UploadFileWizardPage.class);
public final static String FILE_ITEM_TYPE = "FILE";
public final static String FOLDER_ITEM_TYPE = "FOLDER";
+ private File file;
+
private FileUpload fileUpload;
+ private ServerPushSession pushSession;
+ private Label fileNameLabel;
public UploadFileWizardPage() {
super("Import from file system");
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
+ composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
new Label(composite, SWT.NONE).setText("Pick up a file");
- fileUpload = new FileUpload(composite, SWT.BORDER);
- fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- fileUpload.setText("Browse");
+
+ fileNameLabel = new Label(composite, SWT.NONE | SWT.BEGINNING);
+ fileNameLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
+ false));
+
+ fileUpload = new FileUpload(composite, SWT.NONE);
+ fileUpload.setText("Browse...");
+ fileUpload.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false,
+ false));
+
+ final String url = startUploadReceiver();
+ pushSession = new ServerPushSession();
+
+ fileUpload.addSelectionListener(new SelectionAdapter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String fileName = fileUpload.getFileName();
+ fileNameLabel.setText(fileName == null ? "" : fileName);
+ pushSession.start();
+ fileUpload.submit(url);
+ }
+ });
+
setControl(composite);
}
+ public void performFinish() {
+ // boolean success = uploadFile.performUpload();
+ // if (!success)
+ // throw new ArgeoException("Cannot upload file named "
+ // + uploadFile.getPath());
+ }
+
+ private String startUploadReceiver() {
+ MyFileUploadReceiver receiver = new MyFileUploadReceiver();
+ FileUploadHandler uploadHandler = new FileUploadHandler(receiver);
+ uploadHandler.addUploadListener(new FileUploadListener() {
+
+ public void uploadProgress(FileUploadEvent event) {
+ // handle upload progress
+ }
+
+ public void uploadFailed(FileUploadEvent event) {
+ UploadFileWizardPage.this.setErrorMessage("upload failed: "
+ + event.getException());
+ }
+
+ public void uploadFinished(FileUploadEvent event) {
+
+ fileNameLabel.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ // UploadFileWizardPage.this.getContainer()
+ // .updateButtons();
+ pushSession.stop();
+ }
+ });
+
+ // for (FileDetails file : event.getFileDetails()) {
+ // // addToLog("received: " + file.getFileName());
+ // }
+ }
+ });
+ return uploadHandler.getUploadUrl();
+ }
+
+ private class MyFileUploadReceiver extends FileUploadReceiver {
+
+ private static final String TEMP_FILE_PREFIX = "fileupload_";
+
+ @Override
+ public void receive(InputStream dataStream, FileDetails details)
+ throws IOException {
+ File result = File.createTempFile(TEMP_FILE_PREFIX, "");
+ FileOutputStream outputStream = new FileOutputStream(result);
+ try {
+ copy(dataStream, outputStream);
+ } finally {
+ dataStream.close();
+ outputStream.close();
+ }
+ file = result;
+ }
+ }
+
+ private static void copy(InputStream inputStream, OutputStream outputStream)
+ throws IOException {
+ byte[] buffer = new byte[8192];
+ boolean finished = false;
+ while (!finished) {
+ int bytesRead = inputStream.read(buffer);
+ if (bytesRead != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ } else {
+ finished = true;
+ }
+ }
+ }
+
+ /**
+ * The full path including the directory and file drive are only returned,
+ * if the browser supports reading this properties
+ *
+ * @return The full file name of the last uploaded file including the file
+ * path as selected by the user on his local machine.
+ */
public String getObjectPath() {
- // NOTE Returns the full file name of the last uploaded file including
- // the file path as selected by the user on his local machine.
- // The full path including the directory and file drive are only
- // returned, if the browser supports reading this properties. In Firefox
- // 3, only the filename is returned.
return null;
}
return FILE_ITEM_TYPE;
}
- public void performFinish() {
- // boolean success = uploadFile.performUpload();
- // if (!success)
- // throw new ArgeoException("Cannot upload file named "
- // + uploadFile.getPath());
- }
-
// protected void handleUploadFinished(final Upload upload) {
// }
- public InputStream getFileInputStream() {
- return null;
+ /** it is caller responsability to close the stream afterwards. */
+ public InputStream getFileInputStream() throws IOException {
+ return new FileInputStream(file);
+ // InputStream fis = null;
+ //
+ // try {
+ // fis = new FileInputStream(file);
+ // return fis;
+ // } catch (Exception e) {
+ // throw new ArgeoException("Unable to retrieve file " + file, e);
+ // } finally {
+ // IOUtils.closeQuietly(fis);
+ // }
}
public boolean getNeedsProgressMonitor() {
return false;
}
-
-}
+}
\ No newline at end of file
import javax.jcr.nodetype.NodeType;
import org.argeo.ArgeoException;
-import org.argeo.eclipse.ui.jcr.utils.JcrFileProvider;
-import org.argeo.eclipse.ui.specific.FileHandler;
import org.argeo.eclipse.ui.workbench.WorkbenchUiPlugin;
import org.argeo.eclipse.ui.workbench.jcr.DefaultNodeEditor;
import org.argeo.eclipse.ui.workbench.jcr.internal.model.RepositoryElem;
// .getLog(GenericNodeDoubleClickListener.class);
private TreeViewer nodeViewer;
- private JcrFileProvider jfp;
- private FileHandler fileHandler;
+
+ // private JcrFileProvider jfp;
+ // private FileHandler fileHandler;
public GenericNodeDoubleClickListener(TreeViewer nodeViewer) {
this.nodeViewer = nodeViewer;
- jfp = new JcrFileProvider();
+ // jfp = new JcrFileProvider();
// Commented out. see https://www.argeo.org/bugzilla/show_bug.cgi?id=188
- fileHandler = null;
+ // fileHandler = null;
// fileHandler = new FileHandler(jfp);
}
String name = node.getName();
String id = node.getIdentifier();
+ // TODO add integration of direct retrieval of the binary in
+ // a JCR repo.
+ // Map<String, String> params = new HashMap<String,
+ // String>();
+ // params.put(OpenFile.PARAM_FILE_NAME, name);
+ // params.put(OpenFile.PARAM_FILE_URI, "jcr://" + id);
+ // CommandUtils
+ // .callCommand("org.argeo.security.ui.specific.openFile",
+ // params);
+
// For the file provider to be able to browse the
// various
// repository.
// ITreeContentProvider itcp = (ITreeContentProvider)
// nodeViewer
// .getContentProvider();
- jfp.setReferenceNode(node);
- if (fileHandler != null)
- fileHandler.openFile(name, id);
+ // jfp.setReferenceNode(node);
+ // if (fileHandler != null)
+ // fileHandler.openFile(name, id);
}
GenericNodeEditorInput gnei = new GenericNodeEditorInput(node);
WorkbenchUiPlugin.getDefault().getWorkbench()
import java.io.File;
import java.io.FileInputStream;
+import java.io.InputStream;
import javax.jcr.Binary;
import javax.jcr.Node;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.argeo.ArgeoException;
-import org.argeo.eclipse.ui.specific.ImportToServerWizardPage;
import org.argeo.eclipse.ui.specific.UploadFileWizardPage;
import org.argeo.eclipse.ui.workbench.ErrorFeedback;
import org.eclipse.core.runtime.IProgressMonitor;
final String objectPath = importPage.getObjectPath();
// We do not display a progress bar for one file only
- if (ImportToServerWizardPage.FILE_ITEM_TYPE.equals(objectType)) {
+ if (UploadFileWizardPage.FILE_ITEM_TYPE.equals(objectType)) {
// In Rap we must force the "real" upload of the file
- importPage.performFinish();
+ // importPage.performFinish();
try {
Node fileNode = folder.addNode(importPage.getObjectName(),
NodeType.NT_FILE);
Node resNode = fileNode.addNode(Property.JCR_CONTENT,
NodeType.NT_RESOURCE);
Binary binary = null;
+ InputStream is = null;
try {
+ is = importPage.getFileInputStream();
binary = folder.getSession().getValueFactory()
- .createBinary(importPage.getFileInputStream());
+ .createBinary(is);
resNode.setProperty(Property.JCR_DATA, binary);
} finally {
if (binary != null)
binary.dispose();
- IOUtils.closeQuietly(importPage.getFileInputStream());
+ IOUtils.closeQuietly(is);
}
folder.getSession().save();
} catch (Exception e) {
return false;
}
return true;
- } else if (ImportToServerWizardPage.FOLDER_ITEM_TYPE.equals(objectType)) {
+ } else if (UploadFileWizardPage.FOLDER_ITEM_TYPE.equals(objectType)) {
if (objectPath == null || !new File(objectPath).exists()) {
ErrorFeedback.show("Directory " + objectPath
+ " does not exist");