Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #134 from UNC-Libraries/release

updates in support of minor release
  • Loading branch information...
commit e6ffe953ae062eff3adbdd513d48dfa10535a565 2 parents 11960cd + 910cd7a
daines daines authored
Showing with 442 additions and 1,817 deletions.
  1. +35 −0 eclipse-repository/bundleJREs/win32.win32.x86-assembly.xml
  2. +1 −1  eclipse-repository/category.xml
  3. +2 −1  eclipse-repository/pom.xml
  4. +3 −3 eclipse-repository/workbench.product
  5. +0 −18 irods-efs.plugin/META-INF/MANIFEST.MF
  6. +0 −5 irods-efs.plugin/build.properties
  7. +0 −29 irods-efs.plugin/plugin.xml
  8. +0 −15 irods-efs.plugin/pom.xml
  9. +0 −245 irods-efs.plugin/src/irods/efs/plugin/Activator.java
  10. +0 −319 irods-efs.plugin/src/irods/efs/plugin/IrodsConnectionDialog.java
  11. +0 −55 irods-efs.plugin/src/irods/efs/plugin/IrodsEFSFileSystem.java
  12. +0 −533 irods-efs.plugin/src/irods/efs/plugin/IrodsFileStore.java
  13. +0 −254 irods-efs.plugin/src/irods/efs/plugin/LoginInputDialog.java
  14. +0 −141 irods-efs.plugin/src/irods/efs/plugin/properties/IrodsPropertyPage.java
  15. +4 −5 pom.xml
  16. +1 −2  staging/META-INF/MANIFEST.MF
  17. +1 −1  staging/pom.xml
  18. +15 −0 staging/src/main/java/staging/plugin/EFSResolver.java
  19. +15 −0 staging/src/main/java/staging/plugin/IRODSURLStreamHandler.java
  20. +15 −0 staging/src/main/java/staging/plugin/IRODSURLStreamHandlerFactory.java
  21. +15 −0 staging/src/main/java/staging/plugin/StagingAreaPreferenceInitializer.java
  22. +15 −0 staging/src/main/java/staging/plugin/StagingPlugin.java
  23. +46 −51 staging/src/main/java/staging/plugin/StagingUtils.java
  24. +15 −0 staging/src/main/java/staging/plugin/WorkbenchPreferencePage.java
  25. +111 −27 staging/src/main/java/staging/plugin/views/StagingAreasView.java
  26. +15 −0 staging/src/main/java/staging/plugin/views/StagingFolderDialog.java
  27. +1 −1  target-definition/pom.xml
  28. +2 −11 workbench_feature/feature.xml
  29. +1 −1  workbench_feature/pom.xml
  30. +1 −1  workbench_help/META-INF/MANIFEST.MF
  31. +1 −1  workbench_help/pom.xml
  32. +1 −2  workbench_plugin/META-INF/MANIFEST.MF
  33. +1 −1  workbench_plugin/plugin.xml
  34. +1 −1  workbench_plugin/pom.xml
  35. +1 −6 workbench_plugin/src/main/java/unc/lib/cdr/workbench/DivPropertyTester.java
  36. +0 −1  workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/CaptureJob.java
  37. +0 −30 workbench_plugin/src/main/java/unc/lib/cdr/workbench/capture/PickOriginalLocationsPage.java
  38. +3 −11 workbench_plugin/src/main/java/unc/lib/cdr/workbench/commands/DeleteDescriptionsCommand.java
  39. +15 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/commands/ExportProjectHandler.java
  40. +47 −1 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/CdrSipExportJob.java
  41. +12 −9 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/CdrSipExportWizard.java
  42. +14 −33 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/MetsProjectNature.java
  43. +15 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/ProjectBagItExportWizard.java
  44. +15 −0 workbench_plugin/src/main/java/unc/lib/cdr/workbench/project/StagingAreaContributionItem.java
  45. +2 −2 workbench_plugin/src/main/java/unc/lib/cdr/workbench/views/LabelImageFactory.java
35 eclipse-repository/bundleJREs/win32.win32.x86-assembly.xml
View
@@ -0,0 +1,35 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>win32.win32.x86-jre</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <baseDirectory>curators-workbench</baseDirectory>
+ <fileSets>
+ <fileSet>
+ <outputDirectory>/</outputDirectory>
+ <directory>${basedir}/target/products/curators-workbench/win32/win32/x86/curators-workbench</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileSet>
+
+ <fileSet>
+ <outputDirectory>/jre</outputDirectory>
+ <directory>${bundleJREs.dir}/windows-i586/jre${jre.version}</directory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+
+ <files>
+ <file>
+ <source>${bundleJREs.dir}/windows-i586/jre${jre.version}/bin/java.exe</source>
+ <outputDirectory>/jre/bin</outputDirectory>
+ <filtered>false</filtered>
+ <fileMode>755</fileMode>
+ </file>
+ </files>
+</assembly>
2  eclipse-repository/category.xml
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<site>
- <feature url="features/workbench_feature_4.1.4.qualifier.jar" id="workbench_feature" version="4.1.4.qualifier">
+ <feature url="features/workbench_feature_4.1.5.qualifier.jar" id="workbench_feature" version="4.1.5.qualifier">
<category name="workbench_category_id"/>
</feature>
<category-def name="workbench_category_id" label="Curator&apos;s Workbench Category">
3  eclipse-repository/pom.xml
View
@@ -6,7 +6,7 @@
<parent>
<groupId>curators.workbench</groupId>
<artifactId>parent</artifactId>
- <version>4.1.4-SNAPSHOT</version>
+ <version>4.1.5-SNAPSHOT</version>
</parent>
<artifactId>eclipse-repository</artifactId>
<packaging>eclipse-repository</packaging>
@@ -182,6 +182,7 @@
<configuration>
<descriptors>
<descriptor>bundleJREs/macosx.cocoa.x86_64-app-assembly.xml</descriptor>
+ <descriptor>bundleJREs/win32.win32.x86-assembly.xml</descriptor>
<descriptor>bundleJREs/win32.win32.x86_64-assembly.xml</descriptor>
<descriptor>bundleJREs/linux.gtk.x86_64-assembly.xml</descriptor>
</descriptors>
6 eclipse-repository/workbench.product
View
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
-<product name="Curator&apos;s Workbench" uid="curators-workbench" id="workbench_plugin.eclipse-repository" application="workbench_plugin.application" version="4.1.4.qualifier" useFeatures="true" includeLaunchers="true">
+<product name="Curator&apos;s Workbench" uid="curators-workbench" id="workbench_plugin.eclipse-repository" application="workbench_plugin.application" version="4.1.5.qualifier" useFeatures="true" includeLaunchers="true">
<aboutInfo>
<image path="/workbench_plugin/about.png"/>
<text>
- Curator&apos;s Workbench, version 4.1.4
+ Curator&apos;s Workbench, version 4.1.5
The Curator&apos;s Workbench is a project of the Carolina Digital Repository, created by the University Libraries of UNC Chapel Hill.
http://cdr.unc.edu
@@ -90,7 +90,7 @@ limitations under the License.
</plugins>
<features>
- <feature id="workbench_feature" version="4.1.4.qualifier"/>
+ <feature id="workbench_feature" version="4.1.5.qualifier"/>
</features>
<configurations>
18 irods-efs.plugin/META-INF/MANIFEST.MF
View
@@ -1,18 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: irods-efs.plugin
-Bundle-SymbolicName: irods-efs.plugin;singleton:=true
-Bundle-Version: 4.1.4.qualifier
-Bundle-Activator: irods.efs.plugin.Activator
-Bundle-Vendor: University Libraries, UNC Chapel Hill
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.resources,
- org.eclipse.core.filesystem,
- org.irods.jargon.core;bundle-version="[3.2.1.4,3.2.2)",
- org.ops4j.pax.logging.pax-logging-api;bundle-version="1.7.1"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Bundle-ActivationPolicy: lazy
-Import-Package: org.eclipse.core.filesystem
-Export-Package: irods.efs.plugin
-Bundle-ClassPath: .
5 irods-efs.plugin/build.properties
View
@@ -1,5 +0,0 @@
-source.. = src/
-bin.includes = plugin.xml,\
- META-INF/,\
- .
-jre.compilation.profile = JavaSE-1.7
29 irods-efs.plugin/plugin.xml
View
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
- <extension
- point="org.eclipse.ui.propertyPages">
- <page
- name="iRODS"
- nameFilter="*.*"
- class="irods.efs.plugin.properties.IrodsPropertyPage"
- id="irods.efs.plugin.properties.samplePropertyPage">
- <enabledWhen>
- <instanceof
- value="org.eclipse.core.resources.IFile">
- </instanceof>
- </enabledWhen>
- </page>
- </extension>
- <extension
- point="org.eclipse.core.filesystem.filesystems">
- <filesystem
- scheme="irods">
- <run
- class="irods.efs.plugin.IrodsEFSFileSystem">
- </run>
- </filesystem>
- </extension>
-
-</plugin>
15 irods-efs.plugin/pom.xml
View
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
->
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>curators.workbench</groupId>
- <artifactId>parent</artifactId>
- <version>4.1.4-SNAPSHOT</version>
- </parent>
- <artifactId>irods-efs.plugin</artifactId>
- <packaging>eclipse-plugin</packaging>
-</project>
245 irods-efs.plugin/src/irods/efs/plugin/Activator.java
View
@@ -1,245 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * 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 irods.efs.plugin;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.irods.jargon.core.connection.IRODSAccount;
-import org.irods.jargon.core.connection.IRODSAccount.AuthScheme;
-import org.irods.jargon.core.connection.auth.AuthResponse;
-import org.irods.jargon.core.exception.JargonException;
-import org.irods.jargon.core.pub.IRODSFileSystem;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
- private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
-
- private static Map<String, String> accountPasswords = new HashMap<String, String>();
- private static ThreadLocal<Boolean> authenticated = new ThreadLocal<Boolean>() {
- @Override
- protected Boolean initialValue() {
- return Boolean.FALSE;
- }
- };
- private static Object lock = new Object();
- private IRODSFileSystem ifs = null;
-
- // The plug-in ID
- public static final String PLUGIN_ID = "irods-efs.plugin"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- public IRODSFileSystem getIRODSFileSystem() {
- return this.ifs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- ifs = IRODSFileSystem.instance();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given plug-in
- * relative path
- *
- * @param path
- * the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- /**
- * For this base server URI, save zone, password, username, etc in
- * application preferences.
- *
- * @param a
- * @return the server base URI for which connection details are stored
- */
- public void storeConnectionDetails(IRODSAccount a, String password) {
- String key = makeKey(a);
- LOG.debug("storing password by key: {}", key);
- accountPasswords.put(key, password);
- }
-
- private String makeKey(IRODSAccount account) {
- return account.getHost() + ":" + account.getPort() + "/"
- + account.getZone();
- }
-
- public String getZone(URI irodsURI) {
- String zone = null;
- String[] pathParts = irodsURI.getPath().split("/");
- if (pathParts.length > 0) {
- zone = pathParts[1];
- }
- return zone;
- }
-
- public static URI removePassword(URI uri) {
- try {
- String userName = uri.getUserInfo();
- if (userName != null && userName.contains(":")) {
- userName = userName.substring(0, userName.indexOf(":"));
- }
- return new URI(uri.getScheme(), userName, uri.getHost(),
- uri.getPort(), uri.getPath(), null, null);
- } catch (URISyntaxException e) {
- throw new Error("Problem removing password from an iRODS URI.", e);
- }
- }
-
- private IRODSAccount makeAccount(URI uri) {
- LOG.debug("Making account for irods uri: {}", uri);
- IRODSAccount result = null;
- String userName = uri.getUserInfo();
- if (userName != null && userName.contains(":")) {
- userName = userName.substring(0, userName.indexOf(":"));
- }
- if (userName == null)
- userName = System.getProperty("user.name");
- String zone = getZone(uri);
- result = new IRODSAccount(uri.getHost(), uri.getPort(), userName, null,
- "", zone, "fake");
- result.setAuthenticationScheme(AuthScheme.PAM);
- LOG.debug("Account serializes to URI as: {}", result.toString());
- return result;
- }
-
- private URI makeURI(IRODSAccount a) {
- StringBuilder sb = new StringBuilder();
- sb.append("irods://").append(a.getUserName()).append("@")
- .append(a.getHost()).append(":").append(a.getPort());
- return URI.create(sb.toString());
- }
-
- /**
- * For this server URI, load zone, password, username, etc in application
- * preferences. Will prompt user if preferences have not been stored.
- *
- * @param uri
- */
- protected IRODSAccount getAccount(final URI uri) throws CoreException {
- IRODSAccount result = makeAccount(uri);
- authenticate(result);
- return result;
- }
-
- private void authenticate(final IRODSAccount account) throws CoreException {
- final String baseKey = makeKey(account);
- final URI gridURI = makeURI(account);
- final String zone = account.getZone();
- // do we have credentials stored?
- String result = accountPasswords.get(baseKey);
-
- if (result == null) { // prompt
- synchronized (lock) {
- LOG.debug("getting password by key: {}", baseKey);
- result = accountPasswords.get(baseKey);
- LOG.info(Thread.currentThread().getId()
- + " in sync and got initial account: " + result);
- if (result == null) {
- PlatformUI.getWorkbench().getDisplay()
- .syncExec(new Runnable() {
- public void run() {
- Shell s = Activator.getDefault()
- .getWorkbench().getDisplay()
- .getActiveShell();
- String message = "Need a username and password to connect to iRODS.";
- String promptName = account.getUserName();
- LoginInputDialog d = new LoginInputDialog(
- s, message, gridURI, promptName,
- zone, AuthScheme.PAM);
- if (Dialog.OK == d.open()) {
- storeConnectionDetails(
- d.getAuthenticatedIRODSAccount(),
- d.getPassword());
- account.setPassword(d.getPassword());
- LOG.info(Thread.currentThread().getId()
- + " set new password on account");
- }
- }
- });
- }
- }
- } else {
- account.setPassword(result);
- }
-
- // now authenticate for this thread
- if (!authenticated.get()) {
- LOG.debug("Authenticating");
- try {
- AuthResponse ar = ifs.getIRODSAccessObjectFactory()
- .authenticateIRODSAccount(account);
- if (ar.isSuccessful()) authenticated.set(Boolean.TRUE);
- } catch (JargonException e) {
- LOG.debug("I had trouble authenticating to irods", e);
- }
- }
- }
-}
319 irods-efs.plugin/src/irods/efs/plugin/IrodsConnectionDialog.java
View
@@ -1,319 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * 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 irods.efs.plugin;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-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.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.irods.jargon.core.connection.IRODSAccount;
-import org.irods.jargon.core.exception.JargonException;
-import org.irods.jargon.core.pub.IRODSFileSystem;
-import org.irods.jargon.core.pub.io.IRODSFile;
-import org.irods.jargon.core.pub.io.IRODSFileFactory;
-
-/**
- * @author Gregory Jansen
- *
- */
-public class IrodsConnectionDialog extends TitleAreaDialog {
-
- private Text usernameText;
- private Text passwordText;
- private Text serverText;
- private Text portText;
- private Text zoneText;
- private Text defResourceText;
- private Text homeDirectoryText;
- private Button okButton;
- private IRODSAccount account;
- private IRODSAccount input;
- private URI location;
-
- /**
- * @param parentShell
- */
- public IrodsConnectionDialog(Shell parentShell) {
- super(parentShell);
- }
-
- /**
- * @param parentShell
- */
- public IrodsConnectionDialog(Shell parentShell, IRODSAccount input) {
- super(parentShell);
- this.input = input;
- }
-
- /**
- * @param parentShell
- */
- public IrodsConnectionDialog(Shell parentShell, String uri) {
- super(parentShell);
- // get account for input or make one
- URI i;
- try {
- i = new URI(uri);
- this.input = new IRODSAccount(i.getHost(), i.getPort(), null, null,
- i.getPath(), i.getPath().split("/")[0], null);
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(
- "failed to setup account from URI: " + uri, e);
- }
- }
-
- @Override
- public void create() {
- super.create();
- setTitle("Set up an iRODS Connection");
- setMessage("Provide and test iRODS connection settings.",
- IMessageProvider.INFORMATION);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- // layout.horizontalAlignment = GridData.FILL;
- parent.setLayout(layout);
-
- // The text fields will grow with the size of the dialog
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = true;
- gridData.horizontalAlignment = GridData.FILL;
-
- Label label3 = new Label(parent, SWT.NONE);
- label3.setText("Server Host");
- serverText = new Text(parent, SWT.BORDER);
- serverText.setLayoutData(gridData);
-
- Label label4 = new Label(parent, SWT.NONE);
- label4.setText("Server Port");
- portText = new Text(parent, SWT.BORDER);
- portText.setLayoutData(gridData);
-
- Label label5 = new Label(parent, SWT.NONE);
- label5.setText("Zone Name");
- zoneText = new Text(parent, SWT.BORDER);
- zoneText.setLayoutData(gridData);
-
- Label label1 = new Label(parent, SWT.NONE);
- label1.setText("Username");
- usernameText = new Text(parent, SWT.BORDER);
- usernameText.setLayoutData(gridData);
-
- Label label2 = new Label(parent, SWT.NONE);
- label2.setText("Password");
- passwordText = new Text(parent, SWT.BORDER);
- passwordText.setLayoutData(gridData);
-
- Label label6 = new Label(parent, SWT.NONE);
- label6.setText("Default Resource");
- defResourceText = new Text(parent, SWT.BORDER);
- defResourceText.setLayoutData(gridData);
-
- Label label7 = new Label(parent, SWT.NONE);
- label7.setText("Directory");
- homeDirectoryText = new Text(parent, SWT.BORDER);
- homeDirectoryText.setLayoutData(gridData);
-
- // set some defaults
- portText.setText("1247");
- homeDirectoryText.setText("/");
-
- // setup fields from input account
- if (input != null) {
- // usernameText.setText(input.getUserName());
- // passwordText.setText(input.getPassword());
- serverText.setText(input.getHost());
- portText.setText(Integer.toString(input.getPort()));
- zoneText.setText(input.getZone());
- // defResourceText.setText(input.getDefaultStorageResource());
- if (input.getHomeDirectory() != null
- && !"".equals(input.getHomeDirectory().trim())) {
- homeDirectoryText.setText(input.getHomeDirectory());
- }
- }
- return parent;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalSpan = 3;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.CENTER;
-
- parent.setLayoutData(gridData);
- // Create Add button
- // Own method as we need to overview the SelectionAdapter
- createOkButton(parent, OK, "Okay", true);
-
- // Create Cancel button
- Button cancelButton = createButton(parent, CANCEL, "Cancel", false);
-
- // Add a SelectionListener
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setReturnCode(CANCEL);
- close();
- }
- });
-
- // Create Test button
- Button testButton = createButton(parent, IDialogConstants.PROCEED_ID,
- "Test", false);
-
- // Add a SelectionListener
- testButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (validFormInputs()) {
- makeAccount();
- testConnection();
- }
- }
- });
- }
-
- private boolean validFormInputs() {
- boolean result = false;
- try {
- Integer.parseInt(this.portText.getText());
- result = true;
- } catch (NumberFormatException e) {
- setMessage("Server Port must be a number, e.g. \"1247\"");
- result = false;
- }
- return result;
- }
-
- private boolean testConnection() {
- boolean result = false;
- try {
- IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance();
- IRODSFileFactory ff = irodsFileSystem
- .getIRODSFileFactory(this.account);
- IRODSFile file = ff.instanceIRODSFile(account.getHomeDirectory());
- result = file.exists();
- if (!file.exists()) {
- setMessage("Connection succeeded but directory doesn't exist: "
- + account.getHomeDirectory(), IMessageProvider.ERROR);
- }
- } catch (JargonException e) {
- String msg = null;
- if (e.getCause() != null) {
- msg = e.getCause().getLocalizedMessage();
- } else {
- msg = e.getLocalizedMessage();
- }
- setMessage("Connection failed: " + msg, IMessageProvider.ERROR);
- }
- if (result) {
- setMessage("Connection succeeded", IMessageProvider.INFORMATION);
- this.okButton.setEnabled(true);
- } else {
- this.okButton.setEnabled(false);
- }
- return result;
- }
-
- /**
- * @param parent
- * @param ok
- * @param string
- * @param b
- */
- private Button createOkButton(Composite parent, int ok, String string,
- boolean defaultButton) {
- // increment the number of columns in the button bar
- ((GridLayout) parent.getLayout()).numColumns++;
- okButton = new Button(parent, SWT.PUSH);
- okButton.setEnabled(false);
- okButton.setText(string);
- // button.setFont(JFaceResources.getDialogFont());
- // button.setData(new Integer(id));
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- okPressed();
- }
- });
- if (defaultButton) {
- Shell shell = parent.getShell();
- if (shell != null) {
- shell.setDefaultButton(okButton);
- }
- }
- setButtonLayoutData(okButton);
- return okButton;
- }
-
- @Override
- protected boolean isResizable() {
- return true;
- }
-
- @Override
- protected void okPressed() {
- if (validFormInputs()) {
- makeAccount();
- if (testConnection()) {
- super.okPressed();
- Activator.getDefault().storeConnectionDetails(this.account, this.passwordText.getText());
- try {
- this.location = Activator.removePassword(this.account
- .toURI(false));
- } catch (JargonException e) {
- throw new Error(e);
- }
- }
- }
- }
-
- /**
- *
- */
- private void makeAccount() {
- int port = Integer.parseInt(this.portText.getText());
- IRODSAccount result = new IRODSAccount(this.serverText.getText(), port,
- this.usernameText.getText(), this.passwordText.getText(),
- this.homeDirectoryText.getText(), this.zoneText.getText(),
- this.defResourceText.getText());
- account = result;
- }
-
- public URI getLocation() {
- return this.location;
- }
-
-}
55 irods-efs.plugin/src/irods/efs/plugin/IrodsEFSFileSystem.java
View
@@ -1,55 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * 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 irods.efs.plugin;
-
-import java.net.URI;
-
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileSystem;
-import org.eclipse.core.runtime.CoreException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IrodsEFSFileSystem extends FileSystem {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(IrodsEFSFileSystem.class);
-
- public IrodsEFSFileSystem() {
- super();
- }
-
- /*
- * This method retrieves FileStore objects based on the irods scheme. iRODS URIs look like this;
- *
- * irods://myUser:myPassword@myirodshost.org:1247/myDirectory/myFile
- *
- * If username and/or password are omitted, then store creation will result in a prompt for these. The prompt will
- * save username and password as a preference under the URI.
- *
- * @see org.eclipse.core.filesystem.provider.FileSystem#getStore(java.net.URI)
- */
- @Override
- public IFileStore getStore(URI uri) {
- // get IRODS file store (handle only) for URI
- try {
- return new IrodsFileStore(uri);
- } catch (CoreException e) {
- throw new Error(e);
- }
- }
-
-}
533 irods-efs.plugin/src/irods/efs/plugin/IrodsFileStore.java
View
@@ -1,533 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * 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 irods.efs.plugin;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileInfo;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.provider.FileInfo;
-import org.eclipse.core.filesystem.provider.FileStore;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.irods.jargon.core.connection.IRODSAccount;
-import org.irods.jargon.core.exception.JargonException;
-import org.irods.jargon.core.pub.CollectionAO;
-import org.irods.jargon.core.pub.DataObjectAO;
-import org.irods.jargon.core.pub.IRODSAccessObjectFactory;
-import org.irods.jargon.core.pub.IRODSFileSystem;
-import org.irods.jargon.core.pub.domain.Collection;
-import org.irods.jargon.core.pub.domain.DataObject;
-import org.irods.jargon.core.pub.io.IRODSFile;
-import org.irods.jargon.core.pub.io.IRODSFileFactory;
-import org.irods.jargon.core.pub.io.IRODSFileOutputStream;
-
-/**
- * @author Gregory Jansen
- *
- */
-public class IrodsFileStore extends FileStore {
- URI uri = null;
- IRODSAccount __account = null;
- IRODSFileSystem ifs = null;
-
- // private static final int BUFFER_SIZE = 4194304;
- // private static final int BUFFER_SIZE = 1048576;
- private static final int BUFFER_SIZE = 262144;
-
- // private static final int BUFFER_SIZE = 32768;
-
- public IrodsFileStore(URI uri) throws CoreException {
- this.uri = uri;
- this.ifs = Activator.getDefault().getIRODSFileSystem();
- }
-
- private IrodsFileStore(URI uri, IRODSAccount __account2) {
- this.uri = uri;
- this.__account = __account2;
- this.ifs = Activator.getDefault().getIRODSFileSystem();
- }
-
- private IRODSAccount getAccount() throws CoreException {
- if (__account == null) {
- __account = Activator.getDefault().getAccount(uri);
- }
- return __account;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.filesystem.provider.FileStore#childNames(int,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public String[] childNames(int options, IProgressMonitor monitor)
- throws CoreException {
- List<String> result = new ArrayList<String>();
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("fetching IRODS child names", 2);
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSFileFactory ff = irodsFileSystem
- .getIRODSFileFactory(getAccount());
- IRODSFile file = ff.instanceIRODSFile(getDecodedPath());
- monitor.worked(1);
- // remove path and just give names
- for (String c : file.list()) {
- if ("/".equals(c))
- continue;
- String[] split = c.split("/");
- if (split.length > 0) {
- result.add(split[split.length - 1]);
- }
- }
- monitor.worked(1);
- monitor.done();
- return result.toArray(new String[0]);
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem fetching child names", e));
- }
- }
-
- private String getDecodedPath() {
- String result = null;
- try {
- result = URLDecoder.decode(this.uri.getPath(), "utf-8");
- // /result = this.uri.getPath();
- if (result.endsWith("/"))
- result = result.substring(0, result.length() - 1);
- } catch (UnsupportedEncodingException e) {
- throw new Error(e);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.filesystem.provider.FileStore#fetchInfo(int,
- * org.eclipse.core.runtime.IProgressMonitor)inu
- */
- @Override
- public IFileInfo fetchInfo(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- FileInfo result = new FileInfo();
- monitor.beginTask("fetching IRODS file information", 4);
-
- // get connection and file
- IRODSFile f = null;
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSFileFactory iff = irodsFileSystem
- .getIRODSFileFactory(getAccount());
- f = iff.instanceIRODSFile(getDecodedPath());
- } catch (Exception e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem connecting to IRODS", e));
- }
-
- if (!f.exists()) {
- // log.debug("fetchInfo found a file that doesn't exist in iRODS");
- result.setExists(false);
- result.setName(this.getName());
- return result;
- }
-
- if (f.isDirectory()) {
- // log.debug("fetchInfo says a DIR {}", uri.toASCIIString());
- result.setDirectory(true);
- fetchCollInfo(result, monitor);
- } else {
- // log.debug("fetchInfo says a FILE {}", uri.toASCIIString());
- result.setDirectory(false);
- fetchDataInfo(result, monitor);
- }
- monitor.done();
- return result;
- }
-
- @Override
- public IFileInfo fetchInfo() {
- try {
- return fetchInfo(EFS.NONE, new NullProgressMonitor());
- } catch (CoreException e) {
- // there was an error contacting the file system, so treat it as
- // non-existent file
- // log.debug("fetchInfo threw a CORE exception on {}",
- // uri.toASCIIString(), e);
- e.printStackTrace();
- FileInfo result = new FileInfo(getName());
- result.setExists(false);
- return result;
- }
- }
-
- /**
- * @return
- */
- private void fetchDataInfo(FileInfo info, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSAccessObjectFactory aof = irodsFileSystem
- .getIRODSAccessObjectFactory();
- DataObjectAO doao = aof.getDataObjectAO(getAccount());
- DataObject dObject = doao.findByAbsolutePath(getDecodedPath());
- info.setExists(true);
- info.setLastModified(dObject.getUpdatedAt().getTime());
- info.setLength(dObject.getDataSize());
- info.setName(dObject.getDataName());
- info.setStringAttribute(EFS.ATTRIBUTE_LINK_TARGET,
- dObject.getChecksum());
- info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, false);
- info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, false);
- info.setAttribute(EFS.ATTRIBUTE_HIDDEN, false);
- info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
- info.setAttribute(EFS.ATTRIBUTE_SYMLINK, false);
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem executing IRODS data query",
- e));
- } catch (java.io.FileNotFoundException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem executing IRODS data query",
- e));
- }
- }
-
- /**
- * @return
- */
- private void fetchCollInfo(FileInfo info, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSAccessObjectFactory aof = irodsFileSystem
- .getIRODSAccessObjectFactory();
- CollectionAO cao = aof.getCollectionAO(getAccount());
- Collection cObject = cao.findByAbsolutePath(getDecodedPath());
- info.setExists(true);
- info.setLastModified(cObject.getModifiedAt().getTime());
- info.setName(cObject.getCollectionName());
- info.setAttribute(EFS.ATTRIBUTE_ARCHIVE, false);
- info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, false);
- info.setAttribute(EFS.ATTRIBUTE_HIDDEN, false);
- info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, false);
- info.setAttribute(EFS.ATTRIBUTE_SYMLINK, false);
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem executing IRODS data query",
- e));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.filesystem.provider.FileStore#getChild(java.lang.String)
- */
- @Override
- public IFileStore getChild(String name) {
- // try {
- // name = new URI("file", name, null).toString();
- // name = name.substring(name.indexOf(":")+1);
- // //name = URLEncoder.encode(name, "utf-8");
- // } catch(URISyntaxException e) {
- // throw new Error(e);
- // }
- StringBuilder newPath = new StringBuilder();
- if (this.uri.getPath().endsWith("/")) {
- newPath.append(this.uri.getPath()).append(name);
- } else {
- newPath.append(this.uri.getPath()).append("/").append(name);
- }
- URI child = null;
- try {
- child = new URI(this.uri.getScheme(), this.uri.getUserInfo(),
- this.uri.getHost(), this.uri.getPort(), newPath.toString(),
- null, null);
- } catch (URISyntaxException er) {
- throw new Error(er);
- }
- IrodsFileStore resultStore = null;
- try {
- if (__account == null) {
- resultStore = new IrodsFileStore(child);
- } else {
- resultStore = new IrodsFileStore(child, __account);
- }
- } catch (CoreException e) {
- throw new Error(e);
- }
- return resultStore;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.filesystem.provider.FileStore#getName()
- */
- @Override
- public String getName() {
- String result = this.uri.getRawPath();
- String[] parts = result.split("/");
- if (parts.length == 0) {
- return "";
- }
- result = parts[parts.length - 1];
- try {
- result = URLDecoder.decode(result, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new Error(e);
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.filesystem.provider.FileStore#getParent()
- */
- @Override
- public IFileStore getParent() {
- String[] path = this.uri.getRawPath().split("/");
- if (path.length < 1) {
- return null;
- }
- StringBuilder parentPathBuilder = new StringBuilder();
- // parentPath.append("/");
- for (int i = 0; i < path.length - 1; i++) {
- parentPathBuilder.append(path[i]).append("/");
- }
- String parentPath;
- try {
- parentPath = URLDecoder.decode(parentPathBuilder.toString(),
- "UTF-8");
- } catch (UnsupportedEncodingException e1) {
- throw new Error(e1);
- }
- URI result;
- try {
- result = new URI(this.uri.getScheme(), this.uri.getUserInfo(),
- this.uri.getHost(), this.uri.getPort(), parentPath, null,
- null);
- } catch (URISyntaxException e) {
- throw new Error(e);
- }
- // System.out.println("parent of "+this.uri+" is "+ result);
- IrodsFileStore resultStore = null;
- try {
- if (__account == null) {
- resultStore = new IrodsFileStore(result);
- } else {
- resultStore = new IrodsFileStore(result, __account);
- }
- } catch (CoreException e) {
- throw new Error(e);
- }
- return resultStore;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.filesystem.provider.FileStore#openInputStream(int,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public InputStream openInputStream(int options, IProgressMonitor monitor)
- throws CoreException {
- InputStream result = null;
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("fetching IRODS input stream", 2);
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSFileFactory ff = irodsFileSystem
- .getIRODSFileFactory(getAccount());
- IRODSFile file = ff.instanceIRODSFile(getDecodedPath());
- monitor.worked(1);
- result = ff.instanceIRODSFileInputStream(file);
- result = new BufferedInputStream(result, BUFFER_SIZE);
- monitor.worked(1);
- monitor.done();
- return result;
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem getting iRODS input stream",
- e));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.filesystem.provider.FileStore#toURI()
- */
- @Override
- public URI toURI() {
- return this.uri;
- }
-
- @Override
- public void delete(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("fetching IRODS input stream", 2);
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSFileFactory irodsFileFactory = irodsFileSystem
- .getIRODSFileFactory(getAccount());
- IRODSFile file = irodsFileFactory
- .instanceIRODSFile(getDecodedPath());
- file.deleteWithForceOption();
- irodsFileSystem.close();
- monitor.worked(1);
- monitor.done();
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem getting iRODS input stream",
- e));
- }
- }
-
- @Override
- public IFileStore mkdir(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("fetching IRODS input stream", 2);
- boolean makeParents = false;
- if ((options & EFS.SHALLOW) == 0) {
- makeParents = true;
- }
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSFileFactory irodsFileFactory = irodsFileSystem
- .getIRODSFileFactory(getAccount());
- IRODSFile file = irodsFileFactory
- .instanceIRODSFile(getDecodedPath());
- if (makeParents) {
- file.mkdirs();
- } else {
- file.mkdir();
- }
- irodsFileSystem.close();
- monitor.worked(1);
- monitor.done();
- return this;
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem getting iRODS input stream",
- e));
- }
- }
-
- @Override
- public OutputStream openOutputStream(int options, IProgressMonitor monitor)
- throws CoreException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.beginTask("fetching IRODS output stream", 2);
- try {
- IRODSFileSystem irodsFileSystem = ifs;
- IRODSFileFactory irodsFileFactory = irodsFileSystem
- .getIRODSAccessObjectFactory().getIRODSFileFactory(
- getAccount());
- IRODSFile irodsFile = irodsFileFactory
- .instanceIRODSFile(getDecodedPath());
- IRODSFile parent = irodsFileFactory.instanceIRODSFile(irodsFile
- .getParent());
- if (!parent.exists()) {
- parent.mkdirs();
- }
- if (irodsFile.exists()) {
- irodsFile.deleteWithForceOption();
- }
- parent.close();
- irodsFile.close();
- IRODSFileOutputStream irodsFileOutputStream = irodsFileFactory
- .instanceIRODSFileOutputStream(getDecodedPath());
- BufferedOutputStream bos = new BufferedOutputStream(
- irodsFileOutputStream, BUFFER_SIZE);
- monitor.worked(1);
- monitor.done();
- return bos;
- } catch (JargonException e) {
- throw new CoreException(new Status(Status.ERROR,
- Activator.PLUGIN_ID, "Problem getting iRODS output stream",
- e));
- }
- }
-
- @Override
- public void putInfo(IFileInfo info, int options, IProgressMonitor monitor)
- throws CoreException {
- super.putInfo(info, options, monitor);
- // if (monitor == null) {
- // monitor = new NullProgressMonitor();
- // }
- // monitor.beginTask("fetching IRODS output stream", 2);
- // try {
- // IRODSFileSystem irodsFileSystem = ifs;
- // IRODSFileFactory irodsFileFactory =
- // irodsFileSystem.getIRODSFileFactory(account);
- // IRODSFile file = irodsFileFactory.instanceIRODSFile(uri.getPath());
- // IRODSFileOutputStream irodsFileOutputStream =
- // irodsFileFactory.instanceIRODSFileOutputStream(file);
- // //irodsFileSystem.close();
- // monitor.worked(1);
- // monitor.done();
- // return irodsFileOutputStream;
- // } catch (JargonException e) {
- // throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID,
- // "Problem getting iRODS input stream",
- // e));
- // }
- }
-
-}
254 irods-efs.plugin/src/irods/efs/plugin/LoginInputDialog.java
View
@@ -1,254 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * 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 irods.efs.plugin;
-
-import java.net.URI;
-
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-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.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.irods.jargon.core.connection.IRODSAccount;
-import org.irods.jargon.core.connection.IRODSAccount.AuthScheme;
-import org.irods.jargon.core.connection.auth.AuthResponse;
-import org.irods.jargon.core.exception.JargonException;
-import org.irods.jargon.core.pub.IRODSFileSystem;
-
-/**
- * @author Gregory Jansen
- *
- */
-public class LoginInputDialog extends TitleAreaDialog {
- String message;
- URI irodsURI;
- String zone;
- String defaultUsername;
- Text textUsername;
- Text textPassword;
- Shell shell = null;
-
- Button okButton;
-
- String username = null;
- String password = null;
- AuthScheme authScheme = null;
- IRODSAccount authenticatedIrodsAccount = null;
-
- /**
- * @param parentShell
- * @param pam
- */
- protected LoginInputDialog(Shell parentShell, String message, URI irodsURI, String defaultUsername, String zone, AuthScheme scheme) {
- super(parentShell);
- this.message = message;
- this.irodsURI = irodsURI;
- this.defaultUsername = defaultUsername;
- this.textPassword = null;
- this.textUsername = null;
- this.zone = zone;
- this.authScheme = scheme;
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- createControls(composite);
- // add controls to composite as necessary
- return composite;
- }
-
- /**
- * @param composite
- */
- private void createControls(Composite composite) {
- shell = composite.getShell();
- shell.setText("iRODS Authentication");
-
- this.setMessage(message);
- Group group = new Group(composite, SWT.None);
- group.setText("");
-
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.setLayout(new GridLayout(2, true));
- Label grid = new Label(group, SWT.None);
- grid.setText("Location");
- Text gridText = new Text(group, SWT.BORDER);
- gridText.setText(irodsURI.toString());
- gridText.setEnabled(false);
-
- Label userId = new Label(group, SWT.None);
- userId.setText("Username");
-
- textUsername = new Text(group, SWT.BORDER);
- if (this.defaultUsername != null && !this.defaultUsername.isEmpty()) {
- textUsername.setText(this.defaultUsername);
- textUsername.setEditable(false);
- }
- textUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label userPsw = new Label(group, SWT.None);
- userPsw.setText("Password");
-
- textPassword = new Text(group, SWT.PASSWORD | SWT.BORDER);
- textPassword.setText("");
- textPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- if(textUsername.getText() == null || textUsername.getText().trim().length() == 0) {
- textUsername.setFocus();
- } else {
- textPassword.setFocus();
- }
-
- group.pack();
- composite.pack();
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalSpan = 3;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- gridData.horizontalAlignment = SWT.CENTER;
-
- parent.setLayoutData(gridData);
- // Create Add button
- // Own method as we need to overview the SelectionAdapter
- createOkButton(parent, OK, "Okay", true);
-
- // Create Cancel button
- Button cancelButton = createButton(parent, CANCEL, "Cancel", false);
-
- // Add a SelectionListener
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setReturnCode(CANCEL);
- close();
- }
- });
- }
-
- /**
- * @return
- */
- protected IRODSAccount makeAccount() {
- IRODSAccount result = new IRODSAccount(this.irodsURI.getHost(), this.irodsURI.getPort(), textUsername.getText(),
- textPassword.getText(), "", zone, "fake");
- result.setAuthenticationScheme(authScheme);
- return result;
- }
-
- /**
- * @return
- */
- protected boolean validFormInputs() {
- return textPassword.getText() != null && !textPassword.getText().isEmpty() && textUsername.getText() != null
- && !textUsername.getText().isEmpty();
- }
-
- /**
- * @param parent
- * @param ok
- * @param string
- * @param b
- */
- private Button createOkButton(Composite parent, int ok, String string, boolean defaultButton) {
- // increment the number of columns in the button bar
- ((GridLayout) parent.getLayout()).numColumns++;
- okButton = new Button(parent, SWT.PUSH);
- okButton.setEnabled(true);
- okButton.setText(string);
- // button.setFont(JFaceResources.getDialogFont());
- // button.setData(new Integer(id));
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- okPressed();
- }
- });
- if (defaultButton) {
- Shell shell = parent.getShell();
- if (shell != null) {
- shell.setDefaultButton(okButton);
- }
- }
- setButtonLayoutData(okButton);
- return okButton;
- }
-
- @Override
- protected void okPressed() {
- if (validFormInputs()) {
- IRODSAccount account = makeAccount();
- if(testConnection(account)) {
- this.username = this.textUsername.getText();
- this.password = this.textPassword.getText();
- super.okPressed();
- }
- }
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-
- private boolean testConnection(IRODSAccount account) {
- try {
- this.authenticatedIrodsAccount = null;
- IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance();
- AuthResponse ar = irodsFileSystem.getIRODSAccessObjectFactory().authenticateIRODSAccount(account);
- if(ar.isSuccessful()) {
- this.authenticatedIrodsAccount = ar.getAuthenticatedIRODSAccount();
- return true;
- }
- } catch (JargonException e) {
- String msg = null;
- if (e.getCause() != null) {
- msg = e.getCause().getLocalizedMessage();
- } else {
- msg = e.getLocalizedMessage();
- }
- if (msg.contains("826000")) {
- setMessage("Connection failed: Bad username or password.", IMessageProvider.ERROR);
- textPassword.setFocus();
- } else {
- setMessage("Connection failed due to an error: " + msg, IMessageProvider.ERROR);
- }
- }
- return false;
- }
-
- public IRODSAccount getAuthenticatedIRODSAccount() {
- return this.authenticatedIrodsAccount;
- }
-
-}
141 irods-efs.plugin/src/irods/efs/plugin/properties/IrodsPropertyPage.java
View
@@ -1,141 +0,0 @@
-/**
- * Copyright 2010 The University of North Carolina at Chapel Hill
- *
- * 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 irods.efs.plugin.properties;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.QualifiedName;
-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.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.PropertyPage;
-
-public class IrodsPropertyPage extends PropertyPage {
-
- private static final String PATH_TITLE = "Path:";
- private static final String OWNER_TITLE = "&Owner:";
- private static final String OWNER_PROPERTY = "OWNER";
- private static final String DEFAULT_OWNER = "John Doe";
-
- private static final int TEXT_FIELD_WIDTH = 50;
-
- private Text ownerText;
-
- /**
- * Constructor for SamplePropertyPage.
- */
- public IrodsPropertyPage() {
- super();
- }
-
- private void addFirstSection(Composite parent) {
- Composite composite = createDefaultComposite(parent);
-
- //Label for path field
- Label pathLabel = new Label(composite, SWT.NONE);
- pathLabel.setText(PATH_TITLE);
-
- // Path text field
- Text pathValueText = new Text(composite, SWT.WRAP | SWT.READ_ONLY);
- pathValueText.setText(((IResource) getElement()).getFullPath().toString());
- }
-
- private void addSeparator(Composite parent) {
- Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- separator.setLayoutData(gridData);
- }
-
- private void addSecondSection(Composite parent) {
- Composite composite = createDefaultComposite(parent);
-
- // Label for owner field
- Label ownerLabel = new Label(composite, SWT.NONE);
- ownerLabel.setText(OWNER_TITLE);
-
- // Owner text field
- ownerText = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridData gd = new GridData();
- gd.widthHint = convertWidthInCharsToPixels(TEXT_FIELD_WIDTH);
- ownerText.setLayoutData(gd);
-
- // Populate owner text field
- try {
- String owner =
- ((IResource) getElement()).getPersistentProperty(
- new QualifiedName("", OWNER_PROPERTY));
- ownerText.setText((owner != null) ? owner : DEFAULT_OWNER);
- } catch (CoreException e) {
- ownerText.setText(DEFAULT_OWNER);
- }
- }
-
- /**
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
- GridData data = new GridData(GridData.FILL);
- data.grabExcessHorizontalSpace = true;
- composite.setLayoutData(data);
-
- addFirstSection(composite);
- addSeparator(composite);
- addSecondSection(composite);
- return composite;
- }
-
- private Composite createDefaultComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- composite.setLayout(layout);
-
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
-
- return composite;
- }
-
- protected void performDefaults() {
- super.performDefaults();
- // Populate the owner text field with the default value
- ownerText.setText(DEFAULT_OWNER);
- }
-
- public boolean performOk() {
- // store the value in the owner text field
- try {
- ((IResource) getElement()).setPersistentProperty(
- new QualifiedName("", OWNER_PROPERTY),
- ownerText.getText());
- } catch (CoreException e) {
- return false;
- }
- return true;
- }
-
-}
9 pom.xml
View
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>curators.workbench</groupId>
<artifactId>parent</artifactId>
- <version>4.1.4-SNAPSHOT</version>
+ <version>4.1.5-SNAPSHOT</version>
<packaging>pom</packaging>
<inceptionYear>2010</inceptionYear>
<properties>
@@ -14,7 +14,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.0.6.RELEASE</spring.version>
- <jre.version>1.7.0_40</jre.version>
+ <jre.version>1.7.0_60</jre.version>
</properties>
<developers>
<developer>
@@ -56,7 +56,7 @@
<layout>p2</layout>
<url>http://download.eclipse.org/eclipse/updates/3.8</url>
</repository>
- <repository>
+ <!--repository>
<id>eclipse-gmp</id>
<layout>p2</layout>
<url>http://download.eclipse.org/modeling/gmp/gmf-tooling/updates/releases/</url>
@@ -65,7 +65,7 @@
<id>epsilon-updates</id>
<layout>p2</layout>
<url>http://download.eclipse.org/epsilon/updates/</url>
- </repository>
+ </repository-->
<repository>
<!-- see UNC-Libraries/maven-osgi-bundles to modify this repository -->
<id>maven-dependencies</id>
@@ -84,7 +84,6 @@
<module>workbench_feature</module>
<module>workbench_plugin</module>
<module>eclipse-repository</module>
- <module>irods-efs.plugin</module>
<module>target-definition</module>
<module>staging</module>
</modules>
3  staging/META-INF/MANIFEST.MF
View
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: staging.plugin
Bundle-SymbolicName: staging.plugin;singleton:=true
-Bundle-Version: 4.1.4.qualifier
+Bundle-Version: 4.1.5.qualifier
Bundle-Activator: staging.plugin.StagingPlugin
Bundle-Vendor: University Libraries, UNC Chapel Hill
Require-Bundle: org.eclipse.ui,
@@ -10,7 +10,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.core.filesystem,
org.apache.commons.codec;bundle-version="1.3.0",
- irods-efs.plugin;bundle-version="4.1.4";visibility:=reexport,
org.junit,
edu.unc.lib.cdr.staging-areas;bundle-version="0.0.1";visibility:=reexport,
org.ops4j.pax.logging.pax-logging-api;bundle-version="1.7.1"
2  staging/pom.xml
View
@@ -8,7 +8,7 @@
<parent>
<groupId>curators.workbench</groupId>
<artifactId>parent</artifactId>
- <version>4.1.4-SNAPSHOT</version>
+ <version>4.1.5-SNAPSHOT</version>
</parent>
<artifactId>staging.plugin</artifactId>
<packaging>eclipse-plugin</packaging>
15 staging/src/main/java/staging/plugin/EFSResolver.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin;
import java.net.URI;
15 staging/src/main/java/staging/plugin/IRODSURLStreamHandler.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin;
import java.io.IOException;
15 staging/src/main/java/staging/plugin/IRODSURLStreamHandlerFactory.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin;
import java.io.IOException;
15 staging/src/main/java/staging/plugin/StagingAreaPreferenceInitializer.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin;
import java.io.BufferedReader;
15 staging/src/main/java/staging/plugin/StagingPlugin.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin;
import java.beans.PropertyChangeEvent;
97 staging/src/main/java/staging/plugin/StagingUtils.java
View
@@ -15,8 +15,6 @@
*/
package staging.plugin;
-import irods.efs.plugin.IrodsFileStore;
-
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
@@ -110,9 +108,9 @@ public String toString() {
* when the staging cannot complete
*/
public static StagingResult stage(IFileStore original, IProject project,
- String originalPath, String md5sum, URI manifestStagingURI, SharedStagingArea stage,
- URL destinationConfig, IProgressMonitor monitor)
- throws CoreException {
+ String originalPath, String md5sum, URI manifestStagingURI,
+ SharedStagingArea stage, URL destinationConfig,
+ IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
@@ -175,7 +173,8 @@ public static StagingResult stage(IFileStore original, IProject project,
// stagedChecksumMonitor.subTask("Getting digest for staged file.. ");
String stagedMD5 = fetchMD5Digest(stageFileStore, stagedChecksumMonitor);
if (md5sum != null && !md5sum.equals(sourceMD5)) {
- log.error("old checksum does not match new one: {} | {}", md5sum, sourceMD5);
+ log.error("old checksum does not match new one: {} | {}", md5sum,
+ sourceMD5);
stageFileStore.delete(EFS.NONE, stagedChecksumMonitor);
throw new CoreException(
new Status(IStatus.ERROR, StagingPlugin.PLUGIN_ID,
@@ -244,10 +243,12 @@ public static StagingResult stageInPlace(IFileStore original,
prestage = StagingPlugin.getDefault().getStages()
.findMatchingArea(original.toURI());
}
-
+
if (prestage == null) {
throw new CoreException(new Status(IStatus.ERROR,
- StagingPlugin.PLUGIN_ID, "This file is not in a mapped staging area: "+original.toString()));
+ StagingPlugin.PLUGIN_ID,
+ "This file is not in a mapped staging area: "
+ + original.toString()));
}
try {
@@ -292,53 +293,47 @@ public static String fetchMD5Digest(IFileStore fileStore,
IProgressMonitor monitor) throws CoreException {
String result = null;
IFileInfo info = null;
- if (fileStore instanceof IrodsFileStore) {
- info = fileStore.fetchInfo();
- result = info.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET);
+ monitor.beginTask("Retreiving staged file and calculating checksum",
+ 100);
+ info = fileStore.fetchInfo();
+ if (info.getLength() == 0) {
+ return "d41d8cd98f00b204e9800998ecf8427e";
}
- if (result == null) {
- monitor.beginTask(
- "Retreiving staged file and calculating checksum", 100);
- info = fileStore.fetchInfo();
- if (info.getLength() == 0) {
- return "d41d8cd98f00b204e9800998ecf8427e";
- }
- MessageDigest messageDigest;
- try {
- messageDigest = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new CoreException(new Status(Status.ERROR,
- StagingPlugin.PLUGIN_ID,
- "Cannot create checksum without MD5 algorithm.", e));
- }
- messageDigest.reset();
- byte[] buffer = new byte[chunkSize];
- int bytesRead = 0;
- int totalBytesRead = 0;
- int progressTickBytes = (int) info.getLength() / 100;
- if (progressTickBytes == 0) {
- progressTickBytes = 1; // prevents divide by zero on files less
- // than 100 bytes
- }
- BufferedInputStream in = new BufferedInputStream(
- fileStore.openInputStream(EFS.NONE, null));
- try {
- while ((bytesRead = in.read(buffer, 0, chunkSize)) != -1) {
- messageDigest.update(buffer, 0, bytesRead);
- totalBytesRead = totalBytesRead + bytesRead;
- if ((totalBytesRead % progressTickBytes) < bytesRead) {
- monitor.worked(1);
- }
+ MessageDigest messageDigest;
+ try {
+ messageDigest = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ throw new CoreException(new Status(Status.ERROR,
+ StagingPlugin.PLUGIN_ID,
+ "Cannot create checksum without MD5 algorithm.", e));
+ }
+ messageDigest.reset();
+ byte[] buffer = new byte[chunkSize];
+ int bytesRead = 0;
+ int totalBytesRead = 0;
+ int progressTickBytes = (int) info.getLength() / 100;
+ if (progressTickBytes == 0) {
+ progressTickBytes = 1; // prevents divide by zero on files less
+ // than 100 bytes
+ }
+ BufferedInputStream in = new BufferedInputStream(
+ fileStore.openInputStream(EFS.NONE, null));
+ try {
+ while ((bytesRead = in.read(buffer, 0, chunkSize)) != -1) {
+ messageDigest.update(buffer, 0, bytesRead);
+ totalBytesRead = totalBytesRead + bytesRead;
+ if ((totalBytesRead % progressTickBytes) < bytesRead) {
+ monitor.worked(1);
}
- } catch (IOException e) {
- throw new CoreException(new Status(Status.ERROR,
- StagingPlugin.PLUGIN_ID,
- "Cannot read file store to calculate MD5 digest.", e));
}
- Hex hex = new Hex();
- result = new String(hex.encode(messageDigest.digest()));
- monitor.done();
+ } catch (IOException e) {
+ throw new CoreException(new Status(Status.ERROR,
+ StagingPlugin.PLUGIN_ID,
+ "Cannot read file store to calculate MD5 digest.", e));
}
+ Hex hex = new Hex();
+ result = new String(hex.encode(messageDigest.digest()));
+ monitor.done();
return result;
}
15 staging/src/main/java/staging/plugin/WorkbenchPreferencePage.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin;
import java.net.URI;
138 staging/src/main/java/staging/plugin/views/StagingAreasView.java
View
@@ -1,7 +1,26 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin.views;
import java.io.File;
+import java.io.IOException;
import java.net.URI;
+import java.nio.file.FileStore;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
@@ -14,25 +33,31 @@
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import staging.plugin.StagingPlugin;
import edu.unc.lib.staging.SharedStagingArea;
@@ -55,6 +80,7 @@
*/
public class StagingAreasView extends ViewPart {
+ private static final Logger log = LoggerFactory.getLogger(StagingAreasView.class);
/**
* The ID of the view as specified by the extension.
@@ -144,7 +170,7 @@ public StagingAreasView() {
* it.
*/
public void createPartControl(Composite parent) {
- viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
+ viewer = new TableViewer(parent, SWT.SINGLE | SWT.H_SCROLL
| SWT.V_SCROLL);
ViewLabelProvider labelProvider = new ViewLabelProvider();
createColumns(parent, labelProvider);
@@ -154,7 +180,6 @@ public void createPartControl(Composite parent) {
viewer.setInput(getViewSite());
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
-
ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE);
// Create the help context id for the viewer's control
@@ -164,24 +189,39 @@ public void createPartControl(Composite parent) {
hookContextMenu();
hookDoubleClickAction();
contributeToActionBars();
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ log.debug("Selection changed:"+viewer.getSelection().isEmpty());
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ actionConnect.setEnabled(sel.getFirstElement() != null);
+ }
+ });
}
private void createColumns(Composite parent, ViewLabelProvider labelProvider) {
- String[] titles = { "Stage Name", "Base URI", "Status", "Writable" };
- int[] bounds = { 250, 300, 200, 200 };
-
- TableViewerColumn col0 = createTableViewerColumn(titles[0], bounds[0], 0);
- col0.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn nameCol = createTableViewerColumn("Name", 200, 0);
+ nameCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((StagingArea)element).getName();
}
});
- TableViewerColumn col1 = createTableViewerColumn(titles[1], bounds[1], 1);
- col1.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn statusCol = createTableViewerColumn("Status", 100, 1);
+ statusCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
+ public Image getImage(Object element) {
+ boolean conn = ((StagingArea)element).isConnected();
+ if(conn) {
+ return imageConnected;
+ } else {
+ return imageDisconnected;
+ }
+ }
+
@Override
public String getText(Object element) {
- return ((StagingArea)element).getURI().toString();
+ return ((StagingArea)element).getStatus();
}
@Override
@@ -189,21 +229,53 @@ public String getToolTipText(Object element) {
return getAreaTooltip(element);
}
});
- TableViewerColumn col2 = createTableViewerColumn(titles[2], bounds[2], 2);
- col2.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn spaceCol = createTableViewerColumn("Space", 50, 2);
+ spaceCol.setLabelProvider(new ColumnLabelProvider() {
@Override
- public Image getImage(Object element) {
- boolean conn = ((StagingArea)element).isConnected();
- if(conn) {
- return imageConnected;
- } else {
- return imageDisconnected;
+ public String getText(Object element) {
+ StagingArea a = (StagingArea)element;
+ String result = "";
+ if(a.isConnected() && a.getScheme() != null) {
+ URI storage = a.getConnectedStorageURI();
+ try {
+ FileStore fs = Files.getFileStore(Paths.get(storage));
+ result = humanReadableByteCount(fs.getUnallocatedSpace(), true);
+ } catch (IOException e) {
+ }
}
+ return result;
}
@Override
+ public Color getForeground(Object element) {
+ Color result = super.getForeground(element);
+ StagingArea a = (StagingArea)element;
+ if(a.isConnected() && a.getScheme() != null) {
+ URI storage = a.getConnectedStorageURI();
+ try {
+ FileStore fs = Files.getFileStore(Paths.get(storage));
+ long bytes = fs.getUnallocatedSpace();
+ if(bytes < 10 * 1024 * 1024) { // 10 GB is red
+ return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
+ } else if(bytes < 100 * 1024 * 1024) { // 100GB is yellow
+ return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_YELLOW);
+ }
+ } catch (IOException e) {
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ return getAreaTooltip(element);
+ }
+ });
+ TableViewerColumn uriCol = createTableViewerColumn("URI", 300, 3);
+ uriCol.setLabelProvider(new ColumnLabelProvider() {
+ @Override
public String getText(Object element) {
- return ((StagingArea)element).getStatus();
+ return ((StagingArea)element).getURI().toString();
}
@Override
@@ -211,8 +283,8 @@ public String getToolTipText(Object element) {
return getAreaTooltip(element);
}
});
- TableViewerColumn col3 = createTableViewerColumn(titles[3], bounds[3], 3);
- col3.setLabelProvider(new ColumnLabelProvider() {
+ TableViewerColumn writableCol = createTableViewerColumn("Writable", 150, 4);
+ writableCol.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((StagingArea)element).isReadOnly() ? "no" : "yes";
@@ -280,15 +352,13 @@ private void fillLocalPullDown(IMenuManager manager) {
}
private void fillContextMenu(IMenuManager manager) {
- IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
- SharedStagingArea stage = (SharedStagingArea)sel.getFirstElement();
- manager.add(actionConnect);
// Other plug-ins can contribute there actions here
//manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
private void fillLocalToolBar(IToolBarManager manager) {
manager.add(actionReloadConfiguration);
+ //manager.add(actionConnect);
}
private void makeActions() {
@@ -333,11 +403,17 @@ public void run() {
}
}
}
+
+ @Override
+ public boolean isEnabled() {
+ IStructuredSelection sel = (IStructuredSelection)viewer.getSelection();
+ return sel.getFirstElement() != null;
+ }
+
};
actionConnect.setText("Connect");
- actionConnect.setToolTipText("Connect to this staging area.");
- actionConnect.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
- .getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
+ actionConnect.setToolTipText("Connect this staging area.");
+ actionConnect.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
}
private void hookDoubleClickAction() {
@@ -359,4 +435,12 @@ private void showMessage(String message) {
public void setFocus() {
viewer.getControl().setFocus();
}
+
+ public static String humanReadableByteCount(long bytes, boolean si) {
+ int unit = si ? 1000 : 1024;
+ if (bytes < unit) return bytes + " B";
+ int exp = (int) (Math.log(bytes) / Math.log(unit));
+ String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i");
+ return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
+ }
}
15 staging/src/main/java/staging/plugin/views/StagingFolderDialog.java
View
@@ -1,3 +1,18 @@
+/**
+ * Copyright 2010 The University of North Carolina at Chapel Hill
+ *
+ * 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 staging.plugin.views;
import java.net.URI;
2  target-definition/pom.xml
View
@@ -11,7 +11,7 @@
<parent>
<groupId>curators.workbench</groupId>
<artifactId>parent</artifactId>
- <version>4.1.4-SNAPSHOT</version>
+ <version>4.1.5-SNAPSHOT</version>
</parent>
<build>
13 workbench_feature/feature.xml
View
@@ -2,7 +2,7 @@
<feature
id="workbench_feature"
label="Curator&apos;s Workbench Feature"
- version="4.1.4.qualifier"
+ version="4.1.5.qualifier"
provider-name="UNC Libraries"
plugin="workbench_plugin">