org.eclipse.equinox.app,
org.eclipse.equinox.p2.repository.metadata,
org.osgi.framework,
- org.osgi.service.packageadmin
+ org.osgi.service.packageadmin,
+ org.springframework.remoting
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
eu.etaxonomy.taxeditor.store,
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
import org.eclipse.ui.statushandlers.AbstractStatusHandler;
import org.eclipse.ui.statushandlers.StatusAdapter;
+import org.springframework.remoting.RemoteAccessException;
+import org.springframework.remoting.RemoteConnectFailureException;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {
private CdmStatusHandler cdmStatusHandler;
+
/*
* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer)
*/
class CdmStatusHandler extends AbstractStatusHandler {
+ private Throwable previousT;
/* (non-Javadoc)
* @see org.eclipse.ui.statushandlers.AbstractStatusHandler#handle(org.eclipse.ui.statushandlers.StatusAdapter, int)
*/
@Override
public void handle(StatusAdapter statusAdapter, int style)
{
+
if(statusAdapter.getStatus().matches(IStatus.ERROR)) {
IStatus status = statusAdapter.getStatus();
Throwable t = statusAdapter.getStatus().getException();
+ // NOTE : the global status handling mechanism in the case of
+ // runtime exceptions is called twice, once by the application
+ // throwing the exception and then by the rcp logging mechanism
+ // The check below is to make sure that the same exception is
+ // not shown twice in succession.
+ if(t != null && previousT == t) {
+ return;
+ }
+ previousT = t;
// NOTE : Currently we only allow RuntimeExceptions since
// allowing all kinds of exceptions would also include
// those in generated status objects coming from from logging triggers
// leading to a recursive infinite loop of :
// initial exception thrown -> status handling -> dialog opening + logging of status ->
// status handling -> dialog opening + logging of status ... and so on
- if(t != null && t instanceof RuntimeException && ! "Widget is disposed".equals(t.getMessage())){
- MessagingUtils.errorDialog("Unexpected error",
- null,
- MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
- statusAdapter.getStatus().getPlugin(),
- t,
- true);
- }
+ if(t != null &&
+ t instanceof RuntimeException &&
+ ! "Widget is disposed".equals(t.getMessage()) &&
+ ! handleKnownRuntimeException(t,statusAdapter.getStatus().getPlugin())) {
+
+ MessagingUtils.errorDialog("Unexpected error",
+ null,
+ MessagingUtils.UNEXPECTED_ERROR_MESSAGE,
+ statusAdapter.getStatus().getPlugin(),
+ t,
+ true);
+
+ }
+ }
+ }
+
+ private boolean handleKnownRuntimeException(Throwable t, String pluginId) {
+ if(t instanceof RemoteConnectFailureException ||
+ t.getCause() instanceof RemoteConnectFailureException) {
+ MessagingUtils.errorDialog("Connection Failure",
+ null,
+ MessagingUtils.CONNECTION_FAILURE_MESSAGE + System.getProperty("line.separator"),
+ pluginId,
+ t,
+ true,
+ false);
+ return true;
+ }
+ if(t instanceof RemoteAccessException ||
+ t.getCause() instanceof RemoteAccessException) {
+ MessagingUtils.errorDialog("Remote Access Error",
+ null,
+ MessagingUtils.REMOTE_ACCESS_FAILURE_MESSAGE + System.getProperty("line.separator"),
+ pluginId,
+ t,
+ true,
+ false);
+ return true;
}
+ return false;
}
}
-/**
-* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
package eu.etaxonomy.taxeditor.update;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.equinox.internal.p2.ui.ProvUI;
-import org.eclipse.equinox.p2.core.IProvisioningAgent;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.operations.ProvisioningJob;
-import org.eclipse.equinox.p2.operations.ProvisioningSession;
+import org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard;
+import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.operations.UpdateOperation;
-import org.eclipse.equinox.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
-import org.eclipse.equinox.p2.ui.ProvisioningUI;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-import eu.etaxonomy.taxeditor.TaxonomicEditorPlugin;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
+import org.eclipse.jface.wizard.WizardDialog;
/**
* UpdateHandler invokes the check for updates UI
*
+ * @since 3.4
*/
-public class UpdateHandler extends AbstractHandler {
-
- private static final String ERROR_PERFORMING_UPDATES = "Error performing updates";
- /**
- * {@inheritDoc}
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- // update using a progress monitor
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- doExecute(monitor);
- }
- };
-
- try {
- new ProgressMonitorDialog(null).run(true, true, runnable);
- } catch (InvocationTargetException | InterruptedException e) {
- showError(e);
- }
- return null;
- }
-
- private void doExecute(IProgressMonitor monitor) {
-
- //UpdateOperation operation = new UpdateOperation(ProvisioningUI.getDefaultUI().getSession());
-
- BundleContext bundleContext = TaxonomicEditorPlugin.getContext();
- ServiceReference reference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME);
- if (reference == null) {
- showMessage(MessageDialog.ERROR, ERROR_PERFORMING_UPDATES, "No provisioning agent found. This application is not set up for updates.");
- return;
- }
-
- final IProvisioningAgent agent = (IProvisioningAgent) bundleContext.getService(reference);
- final IWorkbench workbench = PlatformUI.getWorkbench();
-
- ProvisioningSession session = new ProvisioningSession(agent);
- // update all user-visible installable units
- UpdateOperation operation = new UpdateOperation(session);
+public class UpdateHandler extends PreloadingRepositoryHandler {
- // force refresh all the repository caches before update
- IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ProvisioningUI.getDefaultUI().getSession());
- URI[] repos = metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
+ boolean hasNoRepos = false;
- for(URI repo : repos) {
- try {
- metaManager.refreshRepository(repo, null);
- } catch (ProvisionException | OperationCanceledException e) {
- showError(e);
- }
- }
-
- // set location of artifact and metadata repo
- operation.getProvisioningContext().setArtifactRepositories(repos);
- operation.getProvisioningContext().setMetadataRepositories(repos);
-
- IStatus status = operation.resolveModal(monitor);
-
-// if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
-// if (UpdateSingleIUWizard.validFor(operation)) {
-// // Special case for only updating a single root
-// UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
-// WizardDialog dialog = new WizardDialog(getShell(), wizard);
-// dialog.create();
-// dialog.open();
-// } else {
-// // Open the normal version of the update wizard
-// getProvisioningUI().openUpdateWizard(false, operation, job);
-// }
-// }
-
- if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
- showMessage(MessageDialog.INFORMATION, "Checking for updates", "No updates were found");
+ @Override
+ protected void doExecute(LoadMetadataRepositoryJob job) {
+ if (hasNoRepos) {
return;
}
-
- final ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
- if (provisioningJob != null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- boolean performUpdate = MessageDialog.openQuestion(
- null,
- "Updates available",
- "There are updates available. Do you want to install them now?");
- if (performUpdate) {
- provisioningJob.addJobChangeListener(new JobChangeAdapter() {
- @Override
- public void done(IJobChangeEvent event) {
- if (event.getResult().isOK()) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- boolean restart = MessageDialog.openQuestion(null,
- "Updates installed, restart?",
- "Updates have been installed successfully, do you want to restart?");
- if (restart) {
- workbench.restart();
- }
- }
- });
- } else {
- MessageDialog.openInformation(
- null,
- ERROR_PERFORMING_UPDATES,
- event.getResult().getMessage());
- }
- }
- });
- provisioningJob.schedule();
- }
- }
- });
- } else {
- if (operation.hasResolved()) {
- showMessage(MessageDialog.ERROR, ERROR_PERFORMING_UPDATES, "Couldn't get provisioning job: " + operation.getResolutionResult());
+ UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
+
+
+ // check for updates
+ operation.resolveModal(null);
+ if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
+ if (UpdateSingleIUWizard.validFor(operation)) {
+ // Special case for only updating a single root
+ UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.create();
+ dialog.open();
} else {
- showMessage(MessageDialog.ERROR, ERROR_PERFORMING_UPDATES, "Couldn't resolve provisioning job");
+ // Open the normal version of the update wizard
+ getProvisioningUI().openUpdateWizard(false, operation, job);
}
}
}
- private void showMessage(final int kind, final String title, final String info) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.open(kind, null, title, info, SWT.NONE);
- }
- });
- }
-
- private void showError(final Throwable t) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MessagingUtils.errorDialog(ERROR_PERFORMING_UPDATES,
- this,
- t.getMessage(),
- TaxonomicEditorPlugin.PLUGIN_ID,
- t,
- true);
- }
- });
+ @Override
+ protected boolean preloadRepositories() {
+ hasNoRepos = false;
+ RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
+ if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
+ hasNoRepos = true;
+ return false;
+ }
+ return super.preloadRepositories();
}
-
-
}
return (IUserService) getService(IUserService.class, "/remoting-public/user.service", new CdmServiceRequestExecutor());\r
}\r
\r
+\r
+ public static IUserService getUserService(ICdmRemoteSource remoteSource) {\r
+ return (IUserService) getService(IUserService.class, "/remoting-public/user.service", remoteSource, new CommonsHttpInvokerRequestExecutor());\r
+ }\r
+\r
@Override\r
public IMetadataService getMetadataService() {\r
return (IMetadataService) getService(IMetadataService.class, "/remoting-public/metadata.service", new CommonsHttpInvokerRequestExecutor());\r
if(authenticationManager != null) {\r
return authenticationManager;\r
}\r
+\r
+ authenticationManager = getAuthenticationManager(getUserService());\r
+ return authenticationManager;\r
+ }\r
+\r
+ public static ProviderManager getAuthenticationManager(IUserService userService) {\r
Md5PasswordEncoder passwordEncoder = new Md5PasswordEncoder();\r
ReflectionSaltSource saltSource = new ReflectionSaltSource();\r
saltSource.setUserPropertyToUse("getUsername");\r
\r
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();\r
- daoAuthenticationProvider.setUserDetailsService(getUserService());\r
+ daoAuthenticationProvider.setUserDetailsService(userService);\r
daoAuthenticationProvider.setSaltSource(saltSource);\r
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);\r
\r
- authenticationManager = new ProviderManager(Arrays.asList((AuthenticationProvider)daoAuthenticationProvider));\r
- return authenticationManager;\r
+ return new ProviderManager(Arrays.asList((AuthenticationProvider)daoAuthenticationProvider));\r
}\r
\r
\r
public Person convertTeam2Person(UUID arg0) throws MergeException {
return defaultService.convertTeam2Person(arg0);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<AgentBase> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
}
@Override
public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
UUID classificationUuid, List<UUID> excludeTaxa) {
-
+
return defaultService.getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(classificationUuid, excludeTaxa);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Classification> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
return defaultService.loadWithUpdate(arg0);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Collection> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
return defaultService.moveTaxonDescriptions(arg0, arg1);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<DescriptionBase> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
return defaultService.loadWithUpdate(arg0);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<TaxonNameBase> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
return defaultService.listDeterminationEvents(arg0, arg1, arg2, arg3, arg4);
}
+<<<<<<< HEAD
@Override
public Collection<TaxonBase<?>> listDeterminedTaxa(SpecimenOrObservationBase<?> arg0, Integer arg1, Integer arg2,
List<OrderHint> arg3, List<String> arg4) {
public Collection<TaxonBase<?>> listTypeDesignationTaxa(SpecimenOrObservationBase<?> arg0, Integer arg1,
Integer arg2, List<OrderHint> arg3, List<String> arg4) {
return defaultService.listTypeDesignationTaxa(arg0, arg1, arg2, arg3, arg4);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<SpecimenOrObservationBase> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
}
}
return defaultService.loadWithUpdate(arg0);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Reference> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
return defaultService.loadWithUpdate(arg0);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<TaxonBase> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
return defaultService.getLanguageByLabel(arg0);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<DefinedTermBase> load(List<UUID> arg0, List<String> arg1) {
+ return defaultService.load(arg0, arg1);
+ }
+
}
}
public void updateRootEntities() {
- updateRootEntities(null);
+ updateRootEntities((Collection)null);
}
public void updateRootEntities(Collection<UUID> derivativeUuids) {
if(derivativeUuids!=null){
this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
- for (UUID uuid : derivativeUuids) {
- SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY);
+ List<SpecimenOrObservationBase> derivates =
+ CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
+ updateRootEntities(derivates);
+ }
+ refreshTree(false);
+ previousCdmEntitySession.bind();
+ }
+ }
+
+
+ public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
+
+ if(derivates!=null){
+ this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
+ this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
+ for (SpecimenOrObservationBase derivate : derivates) {
+
if(derivate instanceof FieldUnit){
derivateToRootEntityMap.put(derivate, derivate);
}
}
}
viewer.setInput(rootElements);
- refreshTree(false);
- previousCdmEntitySession.bind();
- }
+
}
@Override
for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
derivateUuids.add(specimenOrObservationBase.getUuid());
}
- derivativeEditor.updateRootEntities(derivateUuids);
+ derivativeEditor.updateRootEntities(occurrences);
}
@Override
String dialogTitle,
String message,
IStatus status,
- String stackTrace) {
+ String stackTrace,
+ boolean showStatusMessage) {
super(parentShell,
dialogTitle,
message, status,
IStatus.OK| IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
this.stackTrace = stackTrace;
-
-
+ String statusMessage = "";
+ if(showStatusMessage) {
+ statusMessage = status.getMessage();
+ }
+ this.message = message == null ? statusMessage : message + "\n " + statusMessage;
}
- /**
- * @param parentShell
- * @param dialogTitle
- * @param message
- * @param status
- * @param stackTrace
- */
- public CdmErrorDialog(Shell parentShell,
- String dialogTitle,
- String message,
- IStatus status,
- String stackTrace,
- Object[] updatedObjects) {
- this(parentShell, dialogTitle, message, status, stackTrace);
- this.message = message == null ? status.getMessage()
- : message + "\n " + status.getMessage(); //$NON-NLS-1$
- }
/**
* @param parentShell
String dialogTitle,
String message,
IStatus status) {
- this(parentShell, dialogTitle, message, status, "");
+ this(parentShell, dialogTitle, message, status, "", true);
}
/* (non-Javadoc)
public final static String UNEXPECTED_ERROR_MESSAGE = "This is an unexpected error.";
public final static String CONTACT_MESSAGE = System.getProperty("line.separator") + "Please contact EDIT Support (EditSupport@bgbm.org) with the error trace below (click on the 'Details' button).";
public final static String DEFAULT_MESSAGE = "Error thrown but no associated message";
+ public final static String CONNECTION_FAILURE_MESSAGE = "The connection to the remote server has been broken";
+ public final static String REMOTE_ACCESS_FAILURE_MESSAGE = "Problem accessing remote server";
/**
* Gets the Log4J logger for a given class
final Throwable t,
final List<String> contextInfo,
final String message,
- final MultiStatus status) {
+ final MultiStatus status,
+ final boolean showReason) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
String stackTraceWithContext = getStackTraceAndContextInfo(t, contextInfo);
- CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext);
+ CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, status, stackTraceWithContext, showReason);
ced.open();
Class<? extends Object> clazz = source != null ? source.getClass() : this.getClass();
});
}
+ public static void errorDialog(final String title,
+ final Object source,
+ final String message,
+ final String pluginId,
+ final Throwable t,
+ boolean addContactMesg) {
+ errorDialog(title, source, message, pluginId, t, addContactMesg, true);
+
+ }
/**
* Displays a {@link eu.etaxonomy.taxeditor.model.CdmErrorDialog}.
*
final String message,
final String pluginId,
final Throwable t,
- boolean addContactMesg) {
+ boolean addContactMesg,
+ boolean showReason) {
Throwable throwable = t;
StringBuffer sbStackTrace = new StringBuffer();
throwable.toString(),
throwable);
- errorDialog(title, source, throwable, contextInfo, finalMessage, ms);
+ errorDialog(title, source, throwable, contextInfo, finalMessage, ms, showReason);
}
/**
generatedTaxonNodeUuid = taxonNode.getUuid();
Set<CdmBase> affectedObjects = new HashSet<CdmBase>();
- //FIXME:Remoting Hack for now - need to generalise this
- // by making the affected objects a set of ICdmBase
- // Also, this needs to be moved to the new operations
- // architecture.
TaxonNode parentNode = taxonNode.getParent();
if(parentNode.getParent() == null) {
private ConversationHolder conversation;
+ public static final String INCORRECT_CREDENTIALS_MESSAGE = "Login and/or Password incorrect";
+ public static final String ACCOUNT_LOCKED_MESSAGE = "Account is locked";
+ public static final String EMPTY_CREDENTIALS_MESSAGE = "Login and/or Password empty";
+
public LoginManager(){
- CdmStore.getContextManager().addContextListener(this);
+ CdmStore.getContextManager().addContextListener(this);
}
/**
this.notifyObservers();
}
} catch(BadCredentialsException e){
- throw new CdmAuthenticationException("Login and/or Password incorrect", e);
+ throw new CdmAuthenticationException(INCORRECT_CREDENTIALS_MESSAGE, e);
} catch(LockedException e){
- throw new CdmAuthenticationException("Account is locked", e);
+ throw new CdmAuthenticationException(ACCOUNT_LOCKED_MESSAGE, e);
} catch(IllegalArgumentException e){
- throw new CdmAuthenticationException("Login and/or Password empty", e);
+ throw new CdmAuthenticationException(EMPTY_CREDENTIALS_MESSAGE, e);
}
}
+
private void _logGrantedAuthotities(StringBuilder gaText, String indent,
Set<GrantedAuthority> gaSet) {
for(GrantedAuthority ga : gaSet){
import eu.etaxonomy.cdm.model.common.User;
import eu.etaxonomy.cdm.model.name.NameRelationship;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.cdm.model.reference.Reference;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
*/
public List<SpecimenOrObservationBase> findOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> configurator, boolean showFieldUnits){
List<SpecimenOrObservationBase> records = new ArrayList<SpecimenOrObservationBase>();
- final List<String> OCCURRENCE_INIT_STRATEGY = Arrays.asList(new String[] {
+ final List<String> BASE_OCCURRENCE_INIT_STRATEGY = Arrays.asList(new String[] {
"collection",
"descriptions",
"identifiers",
"derivationEvents.originals",
- "derivedFrom.originals"
+ "derivedFrom.originals",
+ "gatheringEvent.country.representations",
+ "gatheringEvent.collector",
+ "gatheringEvent.locality",
+ "descriptions.descriptionElements",
+ "kindOfUnit",
+ "amplificationResults",
+ "sequences.singleReadAlignments",
+ "mediaSpecimen"
});
- configurator.setPropertyPaths(OCCURRENCE_INIT_STRATEGY);
+
+ List<String> occurrencePropertyPaths = new ArrayList<String>();
+ occurrencePropertyPaths.addAll(BASE_OCCURRENCE_INIT_STRATEGY);
+ for(String propertyPath:BASE_OCCURRENCE_INIT_STRATEGY) {
+ occurrencePropertyPaths.add("derivationEvents.derivatives." + propertyPath);
+ }
+ configurator.setPropertyPaths(occurrencePropertyPaths);
if(checkLargeResult(CdmStore.getService(IOccurrenceService.class).countOccurrences(configurator))){
records = CdmStore.getService(IOccurrenceService.class).findByTitle(configurator).getRecords();
import org.eclipse.wb.swt.SWTResourceManager;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.LockedException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration;
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.api.service.IUserService;
import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfo.CdmInstanceInfo;
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.LoginManager;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
import eu.etaxonomy.taxeditor.webapp.CDMEmbeddedServerException;
import eu.etaxonomy.taxeditor.webapp.CDMServer;
@Override
public void widgetSelected(SelectionEvent e) {
refreshCdmServer();
- updatePort();
+
}
});
GridData gd_comboCdmServer = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
CdmRemoteSource devRemoteSource = CdmServerInfo.getDevServerRemoteSource();
if(devRemoteSource != null) {
isDevRemoteSource = true;
- }
- refreshCdmServer();
- updatePort();
-
- if(devRemoteSource != null) {
String username = System.getProperty("cdm.server.dev.username");
String password = System.getProperty("cdm.server.dev.password");
if(username != null && !username.isEmpty() && password != null && !password.isEmpty()) {
txtPassword.setText(password);
CdmStore.connect(devRemoteSource, RemotingLoginDialog.this);
}
+ } else {
+ refreshCdmServer();
}
}
});
private void refreshCdmServer() {
txtCdmServerStatus.setText(STATUS_CHECKING_AVAILABILITY);
+ clearOnServerChange();
+ emptyCredentials();
updateSelectedCdmServer();
- checkSelectedCdmServer();
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ checkSelectedCdmServer();
+ }
+ });
+
}
private void updateSelectedCdmServer() {
}
private void checkSelectedCdmServer() {
-
- clearOnServerChange();
- emptyCredentials();
-
if(selectedCsii != null) {
if(selectedCsii.isLocalhost()) {
txtPort.setEditable(true);
} else {
txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
comboCdmInstance.removeAll();
+ disableCdmInstanceControls("", "");
}
}
+ updatePort();
}
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
- txtCdmInstanceStatus.setText(STATUS_NOT_AVAILABLE);
- txtCdmInstanceStatus.setToolTipText(e.getMessage());
- comboCdmInstance.setEnabled(false);
- btnConnect.setEnabled(false);
+ disableCdmInstanceControls(STATUS_NOT_AVAILABLE, e.getMessage());
}
});
}
// Start the Job
serverJob.schedule();
}
+ }
+ private void disableCdmInstanceControls(String cdmInstanceStatus, String tooltip) {
+ txtCdmInstanceStatus.setText(cdmInstanceStatus);
+ txtCdmInstanceStatus.setToolTipText(tooltip);
+ comboCdmInstance.setEnabled(false);
+ btnConnect.setEnabled(false);
}
-
private void refreshCdmInstance() {
txtCdmInstanceStatus.setText(STATUS_CHECKING_AVAILABILITY);
clearOnInstanceChange();
CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName());
}
- private boolean isActiveCdmInstanceRunningInManagedServer() {
- return CdmStore.getManagedServer() != null &&
- CdmStore.getManagedServer().isAlive() &&
- CdmStore.isActive() &&
- CdmServerInfo.NAME_LOCALHOST_MGD.equals(CdmStore.getActiveCdmSource().getName());
- }
-
-
private void startManagedServer() {
if(isManagedServerRunning()) {
if(CdmStore.getManagedServer().getDataSourceName().equals(selectedCdmInstance.getName())) {
ICdmRemoteSource source = selectedCsii.getCdmRemoteSource(selectedCdmInstance, getPort());
- if(!validateLogin()) {
+ if(!validateLogin(source)) {
return;
}
return selectedCsii.toString(selectedCdmInstance.getName(), getPort()) + PASSWORD_SUFFIX;
}
- private boolean validateLogin() {
+ private boolean validateLogin(ICdmRemoteSource remoteSource) {
if(getUsername() == null || getUsername().isEmpty()) {
setMessage("User login cannot be empty");
return false;
setMessage("Password cannot be empty");
return false;
}
+
+
+ try {
+ IUserService userService = CdmApplicationRemoteConfiguration.getUserService(remoteSource);
+ UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(getUsername(), getPassword());
+ CdmApplicationRemoteConfiguration.getAuthenticationManager(userService).authenticate(token);
+ } catch(BadCredentialsException e){
+ setMessage(LoginManager.INCORRECT_CREDENTIALS_MESSAGE);
+ return false;
+ } catch(LockedException e){
+ setMessage(LoginManager.ACCOUNT_LOCKED_MESSAGE);
+ return false;
+ } catch(IllegalArgumentException e){
+ setMessage(LoginManager.INCORRECT_CREDENTIALS_MESSAGE);
+ return false;
+ }
return true;
}
+
public String getUsername() {
return txtLogin.getText();
}
txtServerVersion.setText("");
txtServerVersion.setToolTipText("");
txtServerCDMVersion.setText("");
+ comboCdmInstance.removeAll();
+ txtCdmInstanceStatus.setText("");
txtPort.setEditable(false);
txtPort.setEnabled(false);
}
/**
* Prefix to declare the version as beta
*/
- private static final String BETA_PREFIX = "[REMOTING]";
+ private static final String BETA_PREFIX = "[BETA]";
public static String getTitle() {
return "EDIT Taxonomic Editor " + ApplicationUtil.getVersion();
<?xml version="1.0" encoding="UTF-8"?>
-<?pde version="3.5"?><product application="eu.etaxonomy.taxeditor.application.application" id="eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product" includeLaunchers="true" name="EDIT Taxonomic Editor" uid="eu.etaxonomy.taxeditor.product" useFeatures="true" version="3.12.0.SNAPSHOT">
- <aboutInfo>
- <image path="/eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif"/>
- <text>
+<?pde version="3.5"?>
+
+<product name="EDIT Taxonomic Editor" uid="eu.etaxonomy.taxeditor.product" id="eu.etaxonomy.taxeditor.application.eu_etaxonomy_taxeditor_product" application="eu.etaxonomy.taxeditor.application.application" version="3.12.0.qualifier" useFeatures="true" includeLaunchers="true">
+
+ <aboutInfo>
+ <image path="/eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif"/>
+ <text>
%productBlurb
</text>
- </aboutInfo>
- <configIni use="default"></configIni>
- <launcherArgs>
- <programArgs>-data @user.home/.cdmLibrary -Dserver_port=58080</programArgs>
- <vmArgs>-Xmx512M -XX:MaxPermSize=256M -Dorg.eclipse.update.reconcile=false -Declipse.p2.unsignedPolicy=allow</vmArgs>
- <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
- </launcherArgs>
- <windowImages i16="/eu.etaxonomy.taxeditor.application/icons/256color_16x16.gif" i32="/eu.etaxonomy.taxeditor.application/icons/256color_32x32.gif" i48="/eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif"/>
- <splash location="eu.etaxonomy.taxeditor.application" startupForegroundColor="000000" startupMessageRect="7,432,360,20" startupProgressRect="5,447,366,15"/>
- <launcher name="TaxonomicEditor">
- <solaris/>
- <win useIco="false">
- <bmp/>
- </win>
- </launcher>
- <vm></vm>
- <plugins></plugins>
- <features>
- <feature id="eu.etaxonomy.taxeditor.feature"/>
- </features>
- <configurations>
- <plugin autoStart="true" id="eu.etaxonomy.taxeditor.application" startLevel="5"/>
- <plugin autoStart="true" id="org.eclipse.core.runtime" startLevel="4"/>
- <plugin autoStart="true" id="org.eclipse.equinox.common" startLevel="2"/>
- <plugin autoStart="true" id="org.eclipse.equinox.ds" startLevel="2"/>
- <plugin autoStart="true" id="org.eclipse.equinox.p2.transport.ecf" startLevel="4"/>
- <plugin autoStart="true" id="org.eclipse.equinox.simpleconfigurator" startLevel="1"/>
- </configurations>
+ </aboutInfo>
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <programArgs>-data @user.home/.cdmLibrary -Dserver_port=58080
+ </programArgs>
+ <vmArgs>-Xmx512M -XX:MaxPermSize=256M -Dorg.eclipse.update.reconcile=false -Declipse.p2.unsignedPolicy=allow
+ </vmArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts
+ </vmArgsMac>
+ </launcherArgs>
+
+ <windowImages i16="/eu.etaxonomy.taxeditor.application/icons/256color_16x16.gif" i32="/eu.etaxonomy.taxeditor.application/icons/256color_32x32.gif" i48="/eu.etaxonomy.taxeditor.application/icons/256color_48x48.gif"/>
+
+ <splash
+ location="eu.etaxonomy.taxeditor.application"
+ startupProgressRect="5,447,366,15"
+ startupMessageRect="7,432,360,20"
+ startupForegroundColor="000000" />
+ <launcher name="TaxonomicEditor">
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+ <vm>
+ </vm>
+
+ <plugins>
+ </plugins>
+
+ <features>
+ <feature id="eu.etaxonomy.taxeditor.feature"/>
+ </features>
+
+ <configurations>
+ <plugin id="eu.etaxonomy.taxeditor.application" autoStart="true" startLevel="5" />
+ <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" />
+ <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
+ <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
+ <plugin id="org.eclipse.equinox.p2.transport.ecf" autoStart="true" startLevel="4" />
+ <plugin id="org.eclipse.equinox.simpleconfigurator" autoStart="true" startLevel="1" />
+ </configurations>
+
</product>