<bean id="openModuleEditor" class="org.argeo.slc.client.ui.dist.commands.OpenModuleEditor"
scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="localRepository" ref="nodeRepository" />
+ <property name="repoService" ref="repoService" />
</bean>
<!-- REPOSITORY MANAGEMENT -->
<bean id="displayRepoInformation"
class="org.argeo.slc.client.ui.dist.commands.DisplayRepoInformation"
scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
+ <property name="repoService" ref="repoService" />
+ <property name="nodeRepository" ref="nodeRepository" />
</bean>
<property name="nodeRepository" ref="nodeRepository" />
<property name="keyring" ref="keyring" />
</bean>
+ <bean id="openGenerateBinariesWizard"
+ class="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard">
+ <property name="repoService" ref="repoService" />
+ </bean>
<!-- WORKSPACE CRUD -->
<bean id="createWorkspace" class="org.argeo.slc.client.ui.dist.commands.CreateWorkspace">
<bean id="artifactVersionEditor"
class="org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor"
scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="localRepository" ref="nodeRepository" />
+ <property name="repoService" ref="repoService" />
</bean>
+
<bean id="modularDistVersionEditor"
class="org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor"
scope="prototype">
- <property name="repositoryFactory" ref="repositoryFactory" />
- <property name="keyring" ref="keyring" />
- <property name="localRepository" ref="nodeRepository" />
+ <property name="repoService" ref="repoService" />
</bean>
</beans>
<property name="workspace" value="org.argeo.tp-1.3.1" />
</bean>
+ <bean id="repoService" class="org.argeo.slc.client.ui.dist.RepoServiceImpl">
+ <property name="repositoryFactory" ref="repositoryFactory" />
+ <property name="keyring" ref="keyring" />
+ <property name="nodeRepository" ref="nodeRepository" />
+ </bean>
+
<!-- For the record <property name="session"> <bean factory-bean="repository"
factory-method="login" /> </property> -->
</beans>
</commandParameter>
</command>
- <command
+ <!-- <command
defaultHandler="org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory"
id="org.argeo.slc.client.ui.dist.markAsRelevantCategory"
name="Mark as relevant category">
- </command>
+ </command> -->
<command
- defaultHandler="org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard"
id="org.argeo.slc.client.ui.dist.openGenerateBinariesWizard"
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
name="Generate Binaries...">
+ <commandParameter
+ id="param.repoNodePath"
+ name="Repo node path">
+ </commandParameter>
+ <commandParameter
+ id="param.workspaceName"
+ name="Workspace name">
+ </commandParameter>
+ <commandParameter
+ id="param.modulePath"
+ name="Module path name">
+ </commandParameter>
</command>
<command
public final static String SLC_BUNDLE_VENDOR = SlcNames.SLC_
+ Constants.BUNDLE_VENDOR;
+ public final static String SLC_BUNDLE_DESCRIPTION = SlcNames.SLC_
+ + Constants.BUNDLE_DESCRIPTION;
+
public final String DEFAULT_PUBLIC_REPOSITORY_URI = "vm:///java";
}
--- /dev/null
+package org.argeo.slc.client.ui.dist;
+
+import javax.jcr.Session;
+
+/** Start factorisation of the session management using a manager service */
+public interface RepoService {
+
+ /**
+ * Returns a corresponding session given the current context. Caller must
+ * close the session once it as been used
+ */
+ public Session getRemoteSession(String repoNodePath, String uri,
+ String workspaceName);
+}
--- /dev/null
+package org.argeo.slc.client.ui.dist;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.Session;
+
+import org.argeo.slc.repo.RepoUtils;
+import org.argeo.util.security.Keyring;
+
+public class RepoServiceImpl implements RepoService {
+
+ /* DEPENDENCY INJECTION */
+ private Repository nodeRepository;
+ private RepositoryFactory repositoryFactory;
+ private Keyring keyring;
+
+ public Session getRemoteSession(String repoNodePath, String uri,
+ String workspaceName) {
+ return RepoUtils.getRemoteSession(repositoryFactory, keyring,
+ nodeRepository, repoNodePath, uri, workspaceName);
+ }
+
+ /* DEPENDENCY INJECTION */
+ public void setNodeRepository(Repository nodeRepository) {
+ this.nodeRepository = nodeRepository;
+ }
+
+ public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
+ this.repositoryFactory = repositoryFactory;
+ }
+
+ public void setKeyring(Keyring keyring) {
+ this.keyring = keyring;
+ }
+
+}
*/
package org.argeo.slc.client.ui.dist.commands;
-import javax.jcr.RepositoryFactory;
+import javax.jcr.Repository;
import javax.jcr.Session;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
import org.argeo.slc.client.ui.dist.model.RepoElem;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
public final static String DEFAULT_LABEL = "Information";
public final static ImageDescriptor DEFAULT_ICON = DistPlugin
.getImageDescriptor("icons/help.gif");
-
+
/* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
-
+ private RepoService repoService;
+ private Repository nodeRepository;
+
public Object execute(ExecutionEvent event) throws ExecutionException {
IStructuredSelection iss = (IStructuredSelection) HandlerUtil
.getActiveSite(event).getSelectionProvider().getSelection();
if (iss.getFirstElement() instanceof RepoElem) {
RepoElem re = (RepoElem) iss.getFirstElement();
-
- Session defaultSession = null;
- try{
- defaultSession = RepoUtils.getCorrespondingSession(repositoryFactory, keyring, re.getRepoNode(), re.getUri(), null);
-
-
- InformationDialog inputDialog = new InformationDialog(HandlerUtil
- .getActiveSite(event).getShell());
- inputDialog.create();
- inputDialog.loginTxt.setText(defaultSession.getUserID());
- inputDialog.nameTxt.setText(re.getLabel());
- inputDialog.uriTxt.setText(re.getUri());
- inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
-
- inputDialog.open();
+
+ Session defaultSession = null;
+ try {
+ defaultSession = repoService.getRemoteSession(re.getRepoNodePath(),
+ re.getUri(), null);
+
+ InformationDialog inputDialog = new InformationDialog(
+ HandlerUtil.getActiveSite(event).getShell());
+ inputDialog.create();
+ // TODO add more information.
+ inputDialog.loginTxt.setText(defaultSession.getUserID());
+ inputDialog.nameTxt.setText(re.getLabel());
+ inputDialog.uriTxt.setText(re.getUri());
+ inputDialog.readOnlyBtn.setSelection(re.isReadOnly());
+
+ inputDialog.open();
// } catch (RepositoryException e) {
// throw new SlcException("Unexpected error while "
// + "getting repository information.", e);
shell.setText("Repository information");
}
}
-
+
/* DEPENDENCY INJECTION */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
+ public void setRepoService(RepoService repoService) {
+ this.repoService = repoService;
}
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
+ public void setNodeRepository(Repository nodeRepository) {
+ this.nodeRepository = nodeRepository;
}
-
+
}
\ No newline at end of file
*/
package org.argeo.slc.client.ui.dist.commands;
-import java.util.Iterator;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
-import org.argeo.ArgeoException;
import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.jcr.SlcTypes;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
/**
* Add the {@code SlcNames.SLC_RELEVANT_CATEGORY} mixin to the selected node
public final static String ID = DistPlugin.ID + ".markAsRelevantCategory";
public final static String DEFAULT_LABEL = "Mark as relevant category base";
- public final static String DEFAULT_REMOVE_LABEL = "Remove this category from relevant list";
public final static ImageDescriptor DEFAULT_ICON = DistPlugin
.getImageDescriptor("icons/addItem.gif");
- public final static ImageDescriptor DEFAULT_REMOVE_ICON = DistPlugin
- .getImageDescriptor("icons/removeMark.gif");
-
+
public Object execute(ExecutionEvent event) throws ExecutionException {
- try {
- IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActivePart();
-
- if (activePart instanceof IEditorPart) {
- ISelection selector = ((IEditorPart) activePart)
- .getEditorSite().getSelectionProvider().getSelection();
- if (selector != null
- && selector instanceof IStructuredSelection) {
- Iterator<?> it = ((IStructuredSelection) selector)
- .iterator();
-
- Node node = (Node) it.next();
- if (node.isNodeType(SlcTypes.SLC_CATEGORY)) {
- String msg = "Your are about to unlist this category from the relevant category list for current workspace"
- + ".\n" + "Are you sure you want to proceed?";
- if (MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm", msg)) {
- node.removeMixin(SlcTypes.SLC_CATEGORY);
- node.getSession().save();
- }
- } else {
- String msg = "Your are about to mark this group as category base in the current workspace"
- + ".\n" + "Are you sure you want to proceed?";
-
- if (MessageDialog.openConfirm(DistPlugin.getDefault()
- .getWorkbench().getDisplay().getActiveShell(),
- "Confirm", msg)) {
- node.addMixin(SlcTypes.SLC_CATEGORY);
- node.getSession().save();
- }
- }
- }
- }
- } catch (RepositoryException re) {
- throw new ArgeoException(
- "Unexpected error while deleting artifacts.", re);
- }
+ // try {
+ // IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
+ // .getActiveWorkbenchWindow().getActivePage().getActivePart();
+ //
+ // if (activePart instanceof IEditorPart) {
+ // ISelection selector = ((IEditorPart) activePart)
+ // .getEditorSite().getSelectionProvider().getSelection();
+ // if (selector != null
+ // && selector instanceof IStructuredSelection) {
+ // Iterator<?> it = ((IStructuredSelection) selector)
+ // .iterator();
+ //
+ // Node node = (Node) it.next();
+ // if (node.isNodeType(SlcTypes.SLC_CATEGORY)) {
+ // String msg =
+ // "Your are about to unlist this category from the relevant category list for current workspace"
+ // + ".\n" + "Are you sure you want to proceed?";
+ // if (MessageDialog.openConfirm(DistPlugin.getDefault()
+ // .getWorkbench().getDisplay().getActiveShell(),
+ // "Confirm", msg)) {
+ // node.removeMixin(SlcTypes.SLC_CATEGORY);
+ // node.getSession().save();
+ // }
+ // } else {
+ // String msg =
+ // "Your are about to mark this group as category base in the current workspace"
+ // + ".\n" + "Are you sure you want to proceed?";
+ //
+ // if (MessageDialog.openConfirm(DistPlugin.getDefault()
+ // .getWorkbench().getDisplay().getActiveShell(),
+ // "Confirm", msg)) {
+ // node.addMixin(SlcTypes.SLC_CATEGORY);
+ // node.getSession().save();
+ // }
+ // }
+ // }
+ // }
+ // } catch (RepositoryException re) {
+ // throw new ArgeoException(
+ // "Unexpected error while deleting artifacts.", re);
+ // }
return null;
}
}
\ No newline at end of file
*/
package org.argeo.slc.client.ui.dist.commands;
-import java.util.Iterator;
-
-import javax.jcr.Credentials;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-
-import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
-import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
+import org.argeo.slc.client.ui.dist.RepoService;
import org.argeo.slc.client.ui.dist.utils.CommandHelpers;
import org.argeo.slc.client.ui.dist.wizards.GenerateBinariesWizard;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
public final static String DEFAULT_LABEL = "Generate Aether Index";
public final static ImageDescriptor DEFAULT_ICON = null;
+ /* DEPENDENCY INJECTION */
+ private RepoService repoService;
+
+ // Absolute Coordinates of the current group node
+ public final static String PARAM_REPO_NODE_PATH = "param.repoNodePath";
+ public final static String PARAM_WORKSPACE_NAME = "param.workspaceName";
+ public final static String PARAM_MODULE_PATH = "param.modulePath";
+
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = DistPlugin.getDefault().getWorkbench()
.getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (activePart instanceof IViewPart) {
- ISelection selector = ((IViewPart) activePart).getViewSite()
- .getSelectionProvider().getSelection();
- if (selector != null && selector instanceof IStructuredSelection) {
- Iterator<?> it = ((IStructuredSelection) selector).iterator();
- Object element = it.next();
- if (element instanceof ModularDistBaseElem) {
- ModularDistBaseElem elem = (ModularDistBaseElem) element;
- // Session newSession = null;
- try {
- Node cBase = elem.getCategoryBase();
- String catBasePath = cBase.getPath();
- // newSession = ((WorkspaceElem) elem.getParent())
- // .getNewSession();
-
- String wkspName = ((WorkspaceElem) elem.getParent())
- .getWorkspaceName();
- Repository repository = ((WorkspaceElem) elem
- .getParent()).getRepoElem().getRepository();
- Credentials credentials = ((WorkspaceElem) elem
- .getParent()).getRepoElem().getCredentials();
+ String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
+ String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
+ String modulePath = event.getParameter(PARAM_MODULE_PATH);
- GenerateBinariesWizard wizard = new GenerateBinariesWizard(
- repository, credentials, wkspName, catBasePath);
+ GenerateBinariesWizard wizard = new GenerateBinariesWizard(repoService,
+ repoNodePath, workspaceName, modulePath);
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), wizard);
- int result = dialog.open();
+ WizardDialog dialog = new WizardDialog(
+ HandlerUtil.getActiveShell(event), wizard);
+ int result = dialog.open();
- if (result == Dialog.OK)
- CommandHelpers
- .callCommand(RefreshDistributionsView.ID);
- } catch (RepositoryException re) {
- throw new SlcException(
- "Unable to duplicate session for node " + elem,
- re);
- // } finally {
- // JcrUtils.logoutQuietly(newSession);
- }
- }
+ if (result == Dialog.OK
+ && (activePart instanceof RefreshDistributionsView))
+ CommandHelpers.callCommand(RefreshDistributionsView.ID);
- }
- }
return null;
}
+
+ /* DEPENDENCY INJECTION */
+ public void setRepoService(RepoService repoService) {
+ this.repoService = repoService;
+ }
}
\ No newline at end of file
package org.argeo.slc.client.ui.dist.commands;
import javax.jcr.Node;
-import javax.jcr.Repository;
import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
import javax.jcr.Session;
-import org.argeo.jcr.ArgeoNames;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
import org.argeo.slc.client.ui.dist.editors.ArtifactVersionEditor;
import org.argeo.slc.client.ui.dist.editors.ModularDistVersionEditor;
import org.argeo.slc.client.ui.dist.editors.ModuleEditorInput;
import org.argeo.slc.jcr.SlcTypes;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
public final static String PARAM_MODULE_PATH = "param.modulePath";
/* DEPENDENCY INJECTION */
- private Repository localRepository;
- // We must log in the corresponding repository to get the node and be able
- // to decide which editor to open depending on its mixin
- private RepositoryFactory repositoryFactory;
- private Keyring keyring;
+ private RepoService repoService;
public Object execute(ExecutionEvent event) throws ExecutionException {
String repoNodePath = event.getParameter(PARAM_REPO_NODE_PATH);
String workspaceName = event.getParameter(PARAM_WORKSPACE_NAME);
String modulePath = event.getParameter(PARAM_MODULE_PATH);
- Session localSession = null;
Session businessSession = null;
- Node repoNode = null;
-
try {
- try {
- localSession = localRepository.login();
- if (repoNodePath != null
- && localSession.nodeExists(repoNodePath))
- repoNode = localSession.getNode(repoNodePath);
-
- businessSession = RepoUtils.getCorrespondingSession(
- repositoryFactory, keyring, repoNode, repoUri,
- workspaceName);
- if (repoUri == null && repoNode != null)
- repoUri = repoNode.getProperty(ArgeoNames.ARGEO_URI)
- .getString();
+ businessSession = repoService.getRemoteSession(repoNodePath,
+ repoUri, workspaceName);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot log to workspace "
- + workspaceName + " for repo defined in "
- + repoNodePath, e);
- } finally {
- JcrUtils.logoutQuietly(localSession);
- }
-
- ModuleEditorInput wei = new ModuleEditorInput(repoNodePath,
+ Node module = businessSession.getNode(modulePath);
+ ModuleEditorInput mei = new ModuleEditorInput(repoNodePath,
repoUri, workspaceName, modulePath);
- Node artifact = businessSession.getNode(modulePath);
- // Choose correct editor based on the artifact mixin
- if (artifact.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
+ // Choose correct editor based on its mixin
+ if (module.isNodeType(SlcTypes.SLC_MODULAR_DISTRIBUTION))
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(wei, ModularDistVersionEditor.ID);
+ .openEditor(mei, ModularDistVersionEditor.ID);
else
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
- .openEditor(wei, ArtifactVersionEditor.ID);
+ .openEditor(mei, ArtifactVersionEditor.ID);
} catch (RepositoryException e) {
throw new SlcException("Unexpected error while "
+ "getting repoNode info for repoNode at path "
}
/* DEPENDENCY INJECTION */
- public void setLocalRepository(Repository localRepository) {
- this.localRepository = localRepository;
- }
-
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
+ public void setRepoService(RepoService repoService) {
+ this.repoService = repoService;
}
-
}
\ No newline at end of file
treeViewer.refresh(obj);
}
} else if (obj instanceof WorkspaceElem) {
- //WorkspaceElem wn = (WorkspaceElem) obj;
- // if (!wn.isConnected()) {
- // wn.login();
- // treeViewer.refresh(obj);
- // } else {
WorkspaceElem we = (WorkspaceElem) obj;
- Node repoNode = null;
- try {
- RepoElem repoElem = we.getRepoElem();
- Map<String, String> params = new HashMap<String, String>();
+ RepoElem repoElem = we.getRepoElem();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
+ repoElem.getRepoNodePath());
+ params.put(OpenWorkspaceEditor.PARAM_REPO_URI, repoElem.getUri());
+ params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
+ we.getWorkspaceName());
+ CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
- repoNode = repoElem.getRepoNode();
- if (repoNode != null)
- params.put(OpenWorkspaceEditor.PARAM_REPO_NODE_PATH,
- repoNode.getPath());
- params.put(OpenWorkspaceEditor.PARAM_REPO_URI,
- repoElem.getUri());
- params.put(OpenWorkspaceEditor.PARAM_WORKSPACE_NAME,
- we.getWorkspaceName());
- CommandUtils.callCommand(OpenWorkspaceEditor.ID, params);
- } catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + repoNode
- + " while " + "setting parameters of command "
- + "OpenWorkspaceEditor", re);
- }
- // }
} else if (obj instanceof ModularDistVersionElem) {
ModularDistVersionElem modDistElem = (ModularDistVersionElem) obj;
WorkspaceElem wkspElem = modDistElem.getWorkspaceElem();
- Node repoNode = null;
Node moduleNode = modDistElem.getModularDistVersionNode();
+ RepoElem repoElem = wkspElem.getRepoElem();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
+ repoElem.getRepoNodePath());
+ params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
+ params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
+ wkspElem.getWorkspaceName());
try {
- RepoElem repoElem = wkspElem.getRepoElem();
- Map<String, String> params = new HashMap<String, String>();
- repoNode = repoElem.getRepoNode();
- if (repoNode != null)
- params.put(OpenModuleEditor.PARAM_REPO_NODE_PATH,
- repoNode.getPath());
- params.put(OpenModuleEditor.PARAM_REPO_URI, repoElem.getUri());
- params.put(OpenModuleEditor.PARAM_WORKSPACE_NAME,
- wkspElem.getWorkspaceName());
params.put(OpenModuleEditor.PARAM_MODULE_PATH,
moduleNode.getPath());
- CommandUtils.callCommand(OpenModuleEditor.ID, params);
} catch (RepositoryException re) {
- throw new SlcException("Cannot get path for node " + repoNode
- + " or " + moduleNode
+ throw new SlcException("Cannot get path for node " + moduleNode
+ " while setting parameters for "
+ "command OpenModuleEditor", re);
}
+ CommandUtils.callCommand(OpenModuleEditor.ID, params);
}
}
}
\ No newline at end of file
import org.argeo.eclipse.ui.jcr.JcrImages;
import org.argeo.slc.client.ui.dist.DistImages;
import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
import org.argeo.slc.client.ui.dist.model.ModularDistVersionElem;
import org.argeo.slc.client.ui.dist.model.RepoElem;
import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
return DistImages.IMG_WKSP_GROUP;
// else if (element instanceof GroupBaseElem)
// return DistImages.IMG_GROUP_BASE;
- else if (element instanceof ModularDistBaseElem)
+ else if (element instanceof ModularDistVersionBaseElem)
return DistImages.IMG_MODULAR_DIST_BASE;
else if (element instanceof ModularDistVersionElem)
return DistImages.IMG_MODULAR_DIST_VERSION;
package org.argeo.slc.client.ui.dist.editors;
import javax.jcr.Node;
-import javax.jcr.Repository;
import javax.jcr.RepositoryException;
-import javax.jcr.RepositoryFactory;
import javax.jcr.Session;
import org.argeo.ArgeoException;
import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
+import org.argeo.slc.client.ui.dist.RepoService;
import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.repo.RepoUtils;
-import org.argeo.util.security.Keyring;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
// LogFactory.getLog(ArtifactEditor.class);
public final static String ID = DistPlugin.ID + ".artifactVersionEditor";
- private ModuleEditorInput editorInput;
-
/* DEPENDENCY INJECTION */
- private RepositoryFactory repositoryFactory;
- private Repository localRepository;
- private Keyring keyring;
-
- // Business objects
- private Node repoNode;
- // Session that provides the node in the home of the local repository
- private Session localSession = null;
- // The business Session on an optionally remote repository
+ private RepoService repoService;
+
+ // Business Objects
private Session businessSession;
private Node artifact;
+ private ModuleEditorInput editorInput;
+
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
editorInput = (ModuleEditorInput) input;
+ businessSession = repoService.getRemoteSession(
+ editorInput.getRepoNodePath(), editorInput.getUri(),
+ editorInput.getWorkspaceName());
try {
- localSession = localRepository.login();
- if (editorInput.getRepoNodePath() != null
- && localSession.nodeExists(editorInput.getRepoNodePath()))
- repoNode = localSession.getNode(editorInput.getRepoNodePath());
- businessSession = RepoUtils.getCorrespondingSession(
- repositoryFactory, keyring, repoNode, editorInput.getUri(),
- editorInput.getWorkspaceName());
artifact = businessSession.getNode(editorInput.getModulePath());
} catch (RepositoryException e) {
throw new PartInitException(
"Unable to initialise editor for artifact "
+ editorInput.getModulePath() + " in workspace "
- + editorInput.getWorkspaceName()
- + " of repository " + editorInput.getUri(), e);
+ + editorInput.getWorkspaceName(), e);
}
- setPartName(getFormattedName());
super.init(site, input);
}
/** Override to provide a specific part name */
protected String getFormattedName() {
try {
- String partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
+ String partName = null;
+ if (artifact.hasProperty(SLC_ARTIFACT_ID))
+ partName = artifact.getProperty(SLC_ARTIFACT_ID).getString();
+ else
+ partName = artifact.getName();
if (partName.length() > 10) {
partName = "..." + partName.substring(partName.length() - 10);
@Override
protected void addPages() {
+ setPartName(getFormattedName());
+
try {
addPage(new BundleDetailsPage(this, "Details ", artifact));
addPage(new BundleRawPage(this, "Raw Meta-Data ", artifact));
} catch (PartInitException e) {
throw new ArgeoException("Cannot add distribution editor pages", e);
}
+
}
@Override
@Override
public void dispose() {
JcrUtils.logoutQuietly(businessSession);
- JcrUtils.logoutQuietly(localSession);
super.dispose();
}
return false;
}
- protected Node getRepoNode() {
- return repoNode;
+ protected RepoService getRepoService() {
+ return repoService;
}
protected Node getArtifact() {
}
/* DEPENDENCY INJECTION */
- public void setRepositoryFactory(RepositoryFactory repositoryFactory) {
- this.repositoryFactory = repositoryFactory;
- }
-
- public void setKeyring(Keyring keyring) {
- this.keyring = keyring;
- }
-
- public void setLocalRepository(Repository localRepository) {
- this.localRepository = localRepository;
+ public void setRepoService(RepoService repoService) {
+ this.repoService = repoService;
}
}
\ No newline at end of file
&& localSession.nodeExists(editorInput.getRepoNodePath()))
repoNode = localSession.getNode(editorInput.getRepoNodePath());
- businessSession = RepoUtils.getCorrespondingSession(
+ businessSession = RepoUtils.getRemoteSession(
repositoryFactory, keyring, repoNode, editorInput.getUri(),
editorInput.getWorkspaceName());
} catch (RepositoryException e) {
*/
package org.argeo.slc.client.ui.dist.editors;
+import javax.jcr.RepositoryException;
+
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.eclipse.ui.IEditorInput;
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
super.init(site, input);
- // setPartName("Editing distrib");
}
@Override
protected void addPages() {
try {
- addPage(new ModularDistVersionOverviewPage(this, "Modules ", getArtifact()));
+ addPage(new ModularDistVersionOverviewPage(this, "Modules ",
+ getArtifact()));
addPage(new RunInOsgiPage(this, "Run as OSGi ", getArtifact()));
super.addPages();
} catch (PartInitException e) {
// throw new SlcException("Cannot get artifact session", e);
}
}
+
+ protected String getFormattedName() {
+ try {
+ String partName = null;
+ if (getArtifact().hasProperty(SLC_NAME))
+ partName = getArtifact().getProperty(SLC_NAME).getString();
+ else
+ partName = getArtifact().getName();
+
+ if (partName.length() > 10) {
+ partName = "..." + partName.substring(partName.length() - 10);
+ }
+ return partName;
+ } catch (RepositoryException re) {
+ throw new SlcException("unable to get slc:name property for node "
+ + getArtifact(), re);
+ }
+ }
+
}
\ No newline at end of file
.getProperty(SlcNames.SLC_NAME).getString() : "");
form.setMessage(
modularDistribution
- .hasProperty(SlcNames.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
- .getProperty(SlcNames.SLC_BUNDLE_DESCRIPTION)
+ .hasProperty(DistConstants.SLC_BUNDLE_DESCRIPTION) ? modularDistribution
+ .getProperty(DistConstants.SLC_BUNDLE_DESCRIPTION)
.getString() : "", IMessageProvider.NONE);
} catch (RepositoryException re) {
throw new SlcException("Unable to get bundle name for node "
String workspaceName, String artifactPath) {
if (workspaceName == null)
throw new SlcException("Workspace name cannot be null");
- if (uri == null)
- throw new SlcException("URI for repository cannot be null");
+ if (uri == null && repoNodePath == null)
+ throw new SlcException("Define at least one of the 2 "
+ + "parameters URI or Repo Node Path");
if (artifactPath == null)
throw new SlcException("Module path cannot be null");
this.repoNodePath = repoNodePath;
return false;
if (!workspaceName.equals(other.getWorkspaceName()))
return false;
- if (!uri.equals(other.getUri()))
+
+ if (uri == null && other.getUri() != null
+ || !uri.equals(other.getUri()))
+ return false;
+
+ if (repoNodePath == null && other.getRepoNodePath() != null
+ || !repoNodePath.equals(other.getRepoNodePath()))
return false;
- if (repoNodePath == null)
- return other.getRepoNodePath() == null;
- else
- return repoNodePath.equals(other.getRepoNodePath());
+ return true;
}
}
\ No newline at end of file
package org.argeo.slc.client.ui.dist.editors;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.observation.Event;
-import javax.jcr.observation.ObservationManager;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import javax.jcr.query.qom.Constraint;
import org.argeo.slc.client.ui.dist.DistConstants;
import org.argeo.slc.client.ui.dist.DistImages;
import org.argeo.slc.client.ui.dist.DistPlugin;
-import org.argeo.slc.client.ui.dist.commands.MarkAsRelevantCategory;
+import org.argeo.slc.client.ui.dist.commands.OpenGenerateBinariesWizard;
import org.argeo.slc.client.ui.dist.utils.NodeViewerComparator;
import org.argeo.slc.jcr.SlcNames;
import org.argeo.slc.jcr.SlcTypes;
+import org.argeo.slc.repo.RepoConstants;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
private final static String FILTER_HELP_MSG = "Enter filter criterion separated by a space";
// Observes changes
- private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE };
- private CategoryObserver categoriesObserver;
+ // private final static String[] observedTypes = { SlcTypes.SLC_GROUP_BASE
+ // };
+ // private CategoryObserver categoriesObserver;
public WkspCategoryBaseListPage(FormEditor formEditor, String title,
Session session) {
tableCmp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
createTableViewer(tableCmp);
- categoriesObserver = new CategoryObserver(viewer.getTable()
- .getDisplay());
- try {
- ObservationManager observationManager = session.getWorkspace()
- .getObservationManager();
- // FIXME Will not be notified if empty result is deleted
- observationManager.addEventListener(categoriesObserver,
- Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
- false);
- } catch (RepositoryException e) {
- throw new SlcException("Cannot register listeners", e);
- }
+ // categoriesObserver = new CategoryObserver(viewer.getTable()
+ // .getDisplay());
+ // try {
+ // ObservationManager observationManager = session.getWorkspace()
+ // .getObservationManager();
+ // // FIXME Will not be notified if empty result is deleted
+ // observationManager.addEventListener(categoriesObserver,
+ // Event.PROPERTY_CHANGED, "/", true, null, observedTypes,
+ // false);
+ // } catch (RepositoryException e) {
+ // throw new SlcException("Cannot register listeners", e);
+ // }
refresh();
}
// Version
col = new TableViewerColumn(viewer, SWT.NONE);
col.getColumn().setWidth(80);
- col.getColumn().setText("Relevant");
+ col.getColumn().setText("Has binaries");
col.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
try {
- return ((Node) element)
- .isNodeType(SlcTypes.SLC_CATEGORY) ? "Yes"
+ Node currNode = (Node) element;
+
+ return currNode.hasNode(RepoConstants.BINARIES_ARTIFACT_ID) ? "Yes"
: "No";
} catch (RepositoryException e) {
throw new SlcException("unable to check type of node "
.getFirstElement();
Node currSelected = (Node) firstElement;
- boolean isRelevant = false;
- try {
- isRelevant = currSelected
- .isNodeType(SlcTypes.SLC_CATEGORY);
- boolean canEdit = currSelected
- .canAddMixin(SlcTypes.SLC_CATEGORY);
+ DistWkspEditorInput input = (DistWkspEditorInput) getEditorInput();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+ input.getRepoNodePath());
+ try {
+ params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+ currSelected.getPath());
} catch (RepositoryException e) {
- throw new SlcException("unable to check type of node "
- + firstElement, e);
- }
- // Add
- if (isRelevant) {// Remove
- CommandUtils.refreshCommand(menuManager, window,
- MarkAsRelevantCategory.ID,
- MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
- MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
- } else {
- CommandUtils.refreshCommand(menuManager, window,
- MarkAsRelevantCategory.ID,
- MarkAsRelevantCategory.DEFAULT_LABEL,
- MarkAsRelevantCategory.DEFAULT_ICON, true);
+ throw new SlcException("Unable to get path for " + currSelected, e);
}
+ params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+ input.getWorkspaceName());
+
+ CommandUtils.refreshParametrizedCommand(menuManager, window,
+ OpenGenerateBinariesWizard.ID,
+ OpenGenerateBinariesWizard.DEFAULT_LABEL,
+ OpenGenerateBinariesWizard.DEFAULT_ICON, true, params);
+
+ // boolean isRelevant = false;
+ // try {
+ // isRelevant = currSelected.isNodeType(SlcTypes.SLC_CATEGORY);
+ // boolean canEdit = currSelected.canAddMixin(SlcTypes.SLC_CATEGORY);
+ //
+ // } catch (RepositoryException e) {
+ // throw new SlcException("unable to check type of node "
+ // + firstElement, e);
+ // }
+ // // Add
+ // if (isRelevant) {// Remove
+ // CommandUtils.refreshCommand(menuManager, window,
+ // MarkAsRelevantCategory.ID,
+ // MarkAsRelevantCategory.DEFAULT_REMOVE_LABEL,
+ // MarkAsRelevantCategory.DEFAULT_REMOVE_ICON, true);
+ // } else {
+ // CommandUtils.refreshCommand(menuManager, window,
+ // MarkAsRelevantCategory.ID,
+ // MarkAsRelevantCategory.DEFAULT_LABEL,
+ // MarkAsRelevantCategory.DEFAULT_ICON, true);
+ // }
}
private SelectionAdapter getSelectionAdapter(final int index) {
+++ /dev/null
-package org.argeo.slc.client.ui.dist.model;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.QueryManager;
-import javax.jcr.query.QueryResult;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.Selector;
-
-import org.argeo.ArgeoException;
-import org.argeo.slc.SlcException;
-import org.argeo.slc.jcr.SlcNames;
-import org.argeo.slc.jcr.SlcTypes;
-
-/**
- * Abstract the base of a given modular distribution set i.e. the parent of all
- * versions of a given modular distribution
- */
-public class ModularDistBaseElem extends DistParentElem {
-
- final static public String AETHER_CATEGORY_BASE = "categoryBase";
- final static public String AETHER_BINARIES_TYPE = "binaries";
- final static public String AETHER_DEP_TYPE = "dep";
- private String type;
- private Node modularDistBase;
-
- public ModularDistBaseElem(WorkspaceElem wkspElem, String name,
- Node modularDistBase, String type) {
- super(name, wkspElem.inHome(), wkspElem.isReadOnly());
- setParent(wkspElem);
- this.modularDistBase = modularDistBase;
- this.type = type;
- }
-
- public Node getCategoryBase() {
- // TODO clean this
- if (type.equals(AETHER_CATEGORY_BASE))
- return modularDistBase;
- else
- try {
- return modularDistBase.getParent();
- } catch (RepositoryException e) {
- throw new SlcException("unable tyo get parent node for "
- + modularDistBase, e);
- }
- }
-
- /**
- * Override normal behaviour to initialise children only when first
- * requested
- */
- @Override
- public synchronized boolean hasChildren() {
- if (isLoaded()) {
- return super.hasChildren();
- } else {
- return true;
- }
- };
-
- /**
- * Override normal behaviour to initialise children only when first
- * requested
- */
- @Override
- public synchronized Object[] getChildren() {
- if (isLoaded()) {
- return super.getChildren();
- } else {
- try {
- NodeIterator ni = getDistVersions();
- while (ni != null && ni.hasNext()) {
- Node curNode = ni.nextNode();
- if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
- addChild(new ModularDistVersionElem(this, curNode
- .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
- .getString(), curNode));
- }
- return super.getChildren();
- } catch (RepositoryException re) {
- throw new ArgeoException("Unable to retrieve children for "
- + modularDistBase, re);
- }
- }
- }
-
- private NodeIterator getDistVersions() {
- try {
- if (AETHER_CATEGORY_BASE.equals(type))
- return null;
-
- QueryManager queryManager = modularDistBase.getSession()
- .getWorkspace().getQueryManager();
- QueryObjectModelFactory factory = queryManager.getQOMFactory();
- Selector source = factory.selector(
- SlcTypes.SLC_MODULAR_DISTRIBUTION,
- SlcTypes.SLC_MODULAR_DISTRIBUTION);
- Constraint constraint = factory.descendantNode(
- source.getSelectorName(), modularDistBase.getPath());
- // Ordering order = factory.descending(factory.propertyValue(
- // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
- // Ordering[] orderings = { order };
- QueryObjectModel query = factory.createQuery(source, constraint,
- null, null);
- QueryResult queryResult = query.execute();
- return queryResult.getNodes();
- } catch (RepositoryException e) {
- throw new SlcException(
- "Unable to version for modular distribution: " + getName(),
- e);
- }
- }
-
- public String getType() {
- return type;
- }
-
-}
\ No newline at end of file
--- /dev/null
+package org.argeo.slc.client.ui.dist.model;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+import javax.jcr.query.qom.Constraint;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
+
+import org.argeo.ArgeoException;
+import org.argeo.slc.SlcException;
+import org.argeo.slc.jcr.SlcNames;
+import org.argeo.slc.jcr.SlcTypes;
+
+/**
+ * Abstract the base of a given modular distribution set i.e. the parent of all
+ * versions of a given modular distribution
+ */
+public class ModularDistVersionBaseElem extends DistParentElem {
+
+ // final static public String AETHER_CATEGORY_BASE = "categoryBase";
+ final static public String AETHER_BINARIES_TYPE = "binaries";
+ final static public String AETHER_DEP_TYPE = "dep";
+ private String type;
+ private Node modularDistVersionBase;
+
+ public ModularDistVersionBaseElem(WorkspaceElem wkspElem, String name,
+ Node modularDistVersionBase, String type) {
+ super(name, wkspElem.inHome(), wkspElem.isReadOnly());
+ setParent(wkspElem);
+ this.modularDistVersionBase = modularDistVersionBase;
+ this.type = type;
+ }
+
+ public Node getModularDistBase() {
+ // // TODO clean this
+ // if (type.equals(AETHER_CATEGORY_BASE))
+ // return modularDistVersionBase;
+ // else
+ try {
+ return modularDistVersionBase.getParent();
+ } catch (RepositoryException e) {
+ throw new SlcException("unable to get parent node for "
+ + modularDistVersionBase, e);
+ }
+ }
+
+ public WorkspaceElem getWkspElem() {
+ return (WorkspaceElem) getParent();
+ }
+
+ /**
+ * Override normal behaviour to initialise children only when first
+ * requested
+ */
+ @Override
+ public synchronized boolean hasChildren() {
+ if (isLoaded()) {
+ return super.hasChildren();
+ } else {
+ return true;
+ }
+ };
+
+ /**
+ * Override normal behaviour to initialise children only when first
+ * requested
+ */
+ @Override
+ public synchronized Object[] getChildren() {
+ if (isLoaded()) {
+ return super.getChildren();
+ } else {
+ try {
+ NodeIterator ni = getDistVersions();
+ while (ni != null && ni.hasNext()) {
+ Node curNode = ni.nextNode();
+ if (curNode.hasProperty(SlcNames.SLC_ARTIFACT_VERSION))
+ addChild(new ModularDistVersionElem(this, curNode
+ .getProperty(SlcNames.SLC_ARTIFACT_VERSION)
+ .getString(), curNode));
+ }
+ return super.getChildren();
+ } catch (RepositoryException re) {
+ throw new ArgeoException("Unable to retrieve children for "
+ + modularDistVersionBase, re);
+ }
+ }
+ }
+
+ private NodeIterator getDistVersions() {
+ try {
+ // if (AETHER_CATEGORY_BASE.equals(type))
+ // return null;
+
+ QueryManager queryManager = modularDistVersionBase.getSession()
+ .getWorkspace().getQueryManager();
+ QueryObjectModelFactory factory = queryManager.getQOMFactory();
+ Selector source = factory.selector(
+ SlcTypes.SLC_MODULAR_DISTRIBUTION,
+ SlcTypes.SLC_MODULAR_DISTRIBUTION);
+ Constraint constraint = factory.descendantNode(
+ source.getSelectorName(), modularDistVersionBase.getPath());
+ // Ordering order = factory.descending(factory.propertyValue(
+ // source.getSelectorName(), SlcNames.SLC_ARTIFACT_VERSION));
+ // Ordering[] orderings = { order };
+ QueryObjectModel query = factory.createQuery(source, constraint,
+ null, null);
+ QueryResult queryResult = query.execute();
+ return queryResult.getNodes();
+ } catch (RepositoryException e) {
+ throw new SlcException(
+ "Unable to version for modular distribution: " + getName(),
+ e);
+ }
+ }
+
+ public String getType() {
+ return type;
+ }
+}
\ No newline at end of file
public class ModularDistVersionElem extends DistParentElem {
private final Node modularDistVersionNode;
- public ModularDistVersionElem(ModularDistBaseElem modularDistGroupElem,
+ public ModularDistVersionElem(ModularDistVersionBaseElem modularDistGroupElem,
String version, Node modularDistVersionNode) {
super(version, modularDistGroupElem.inHome(), modularDistGroupElem
.isReadOnly());
return uri;
}
+ public String getRepoNodePath() {
+ if (repoNode == null)
+ return null;
+ else
+ try {
+ return repoNode.getPath();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get node path for repository "
+ + label, e);
+ }
+ }
+
/**
* Exposes the local repoNode that completely define a connection to a
* repository (including a set of credentials). Might return null in case of
* an anonymous user
*/
- public Node getRepoNode() {
+ protected Node getRepoNode() {
return repoNode;
}
- public Repository getRepository() {
+ protected Repository getRepository() {
return repository;
}
-
- public Credentials getCredentials() {
+
+ protected Credentials getCredentials() {
return credentials;
}
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.query.InvalidQueryException;
import javax.jcr.query.Query;
import org.argeo.ArgeoException;
"select * from ["
+ SlcTypes.SLC_MODULAR_DISTRIBUTION
+ "]", Query.JCR_SQL2);
- NodeIterator distributions = groupQuery.execute().getNodes();
- distribs: while (distributions.hasNext()) {
+ NodeIterator distributions = null;
+ try {
+ distributions = groupQuery.execute().getNodes();
+ } catch (InvalidQueryException iqe) {
+ // For legacy only does not throw an exception while
+ // browsing
+ // legacy repositories that does not know
+ // SLC_MODULAR_DISTRIBUTION type
+ }
+ distribs: while (distributions != null
+ && distributions.hasNext()) {
Node currDist = distributions.nextNode();
Node distBase = currDist.getParent().getParent();
if (!distBase.isNodeType(SlcTypes.SLC_ARTIFACT_BASE))
String name;
String type;
- if (ModularDistBaseElem.AETHER_BINARIES_TYPE
+ if (ModularDistVersionBaseElem.AETHER_BINARIES_TYPE
.equals(artifactId)) {
name = groupId;
- type = ModularDistBaseElem.AETHER_BINARIES_TYPE;
+ type = ModularDistVersionBaseElem.AETHER_BINARIES_TYPE;
} else {
name = artifactId;
- type = ModularDistBaseElem.AETHER_DEP_TYPE;
+ type = ModularDistVersionBaseElem.AETHER_DEP_TYPE;
}
if (getChildByName(name) == null)
- addChild(new ModularDistBaseElem(WorkspaceElem.this,
- name, distBase, type));
- }
- // Add empty group base that have been marked as relevant
- groupQuery = currSession
- .getWorkspace()
- .getQueryManager()
- .createQuery(
- "select * from ["
- + SlcTypes.SLC_CATEGORY + "]",
- Query.JCR_SQL2);
- distributions = groupQuery.execute().getNodes();
- while (distributions.hasNext()) {
- Node distBase = distributions.nextNode();
- String groupBaseId = distBase.getProperty(
- SlcNames.SLC_GROUP_BASE_ID).getString();
- if (getChildByName(groupBaseId) == null)
- addChild(new ModularDistBaseElem(WorkspaceElem.this,
- groupBaseId, distBase,
- ModularDistBaseElem.AETHER_CATEGORY_BASE));
+ addChild(new ModularDistVersionBaseElem(
+ WorkspaceElem.this, name, distBase, type));
}
return super.getChildren();
} catch (RepositoryException e) {
import org.argeo.slc.client.ui.dist.controllers.DistTreeDoubleClickListener;
import org.argeo.slc.client.ui.dist.controllers.DistTreeLabelProvider;
import org.argeo.slc.client.ui.dist.model.DistParentElem;
-import org.argeo.slc.client.ui.dist.model.ModularDistBaseElem;
+import org.argeo.slc.client.ui.dist.model.ModularDistVersionBaseElem;
import org.argeo.slc.client.ui.dist.model.RepoElem;
import org.argeo.slc.client.ui.dist.model.WkspGroupElem;
import org.argeo.slc.client.ui.dist.model.WorkspaceElem;
IWorkbenchWindow window = DistPlugin.getDefault().getWorkbench()
.getActiveWorkbenchWindow();
+ // Most of the implemented commands support only one selected
+ // element
+ boolean singleElement = ((IStructuredSelection) viewer.getSelection())
+ .size() == 1;
+ // Get Current selected item :
+ Object firstElement = ((IStructuredSelection) viewer.getSelection())
+ .getFirstElement();
+
try {
- // Most of the implemented commands support only one selected
- // element
- boolean singleElement = ((IStructuredSelection) viewer
- .getSelection()).size() == 1;
- // Get Current selected item :
- Object firstElement = ((IStructuredSelection) viewer.getSelection())
- .getFirstElement();
if (firstElement instanceof TreeParent
|| firstElement instanceof DistParentElem) {
String targetRepoPath = null, workspaceName = null, workspacePrefix = null;
+ String modularDistBasePath = null;
// String targetRepoUri = null;
// Build conditions depending on element type
- boolean isDistribElem = false, isModularDistBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
+ boolean isDistribElem = false, isModularDistVersionBaseElem = false, isRepoElem = false, isDistribGroupElem = false;
boolean isLocal = false, isReadOnly = true;
RepoElem re = null;
- if (firstElement instanceof WorkspaceElem) {
- WorkspaceElem de = (WorkspaceElem) firstElement;
- re = (RepoElem) de.getParent().getParent();
- isDistribElem = true;
- isReadOnly = de.isReadOnly();
- workspaceName = de.getWorkspaceName();
- isLocal = de.inHome();
- } else if (firstElement instanceof RepoElem) {
+ if (firstElement instanceof RepoElem) {
re = (RepoElem) firstElement;
isRepoElem = true;
isLocal = re.inHome();
isReadOnly = re.isReadOnly();
- } else if (firstElement instanceof ModularDistBaseElem) {
- ModularDistBaseElem mdbe = (ModularDistBaseElem) firstElement;
- re = (RepoElem) mdbe.getParent().getParent().getParent();
- isModularDistBaseElem = true;
- isLocal = re.inHome();
- isReadOnly = re.isReadOnly();
} else if (firstElement instanceof WkspGroupElem) {
WkspGroupElem wge = (WkspGroupElem) firstElement;
isReadOnly = wge.isReadOnly();
isDistribGroupElem = true;
re = (RepoElem) wge.getParent();
workspacePrefix = wge.getName();
+ } else if (firstElement instanceof WorkspaceElem) {
+ WorkspaceElem we = (WorkspaceElem) firstElement;
+ re = we.getRepoElem();
+ isDistribElem = true;
+ isReadOnly = we.isReadOnly();
+ workspaceName = we.getWorkspaceName();
+ isLocal = we.inHome();
+ } else if (firstElement instanceof ModularDistVersionBaseElem) {
+ ModularDistVersionBaseElem mdbe = (ModularDistVersionBaseElem) firstElement;
+ isModularDistVersionBaseElem = true;
+ re = mdbe.getWkspElem().getRepoElem();
+ isLocal = re.inHome();
+ isReadOnly = re.isReadOnly();
+ workspaceName = mdbe.getWkspElem().getWorkspaceName();
+ modularDistBasePath = mdbe.getModularDistBase().getPath();
}
- // TODO add case for goups
-
if (re != null) {
- // targetRepoUri = re.getUri();
- targetRepoPath = re.getRepoNode().getPath();
+ targetRepoPath = re.getRepoNodePath();
}
// Display repo info
CreateWorkspace.ID, CreateWorkspace.DEFAULT_LABEL,
CreateWorkspace.DEFAULT_ICON,
(isRepoElem || isDistribGroupElem) && singleElement
- && !isReadOnly && !isLocal, params);
+ && !isReadOnly && !isLocal, params);
// TODO Manage the case where it is not a java workspace
params = new HashMap<String, String>();
params.put(CreateLocalJavaWorkspace.PARAM_WORKSPACE_PREFIX,
workspacePrefix);
CommandUtils.refreshParametrizedCommand(menuManager, window,
- CreateLocalJavaWorkspace.ID, CreateLocalJavaWorkspace.DEFAULT_LABEL,
+ CreateLocalJavaWorkspace.ID,
+ CreateLocalJavaWorkspace.DEFAULT_LABEL,
CreateLocalJavaWorkspace.DEFAULT_ICON,
(isRepoElem || isDistribGroupElem) && singleElement
&& !isReadOnly && isLocal, params);
-
+
// Register a remote repository
CommandUtils.refreshCommand(menuManager, window,
RegisterRepository.ID,
CopyWorkspace.ID, CopyWorkspace.DEFAULT_LABEL,
CopyWorkspace.DEFAULT_ICON, isDistribElem
&& singleElement && !isLocal, params);
-
+
params = new HashMap<String, String>();
params.put(CopyLocalJavaWorkspace.PARAM_SOURCE_WORKSPACE_NAME,
workspaceName);
CommandUtils.refreshParametrizedCommand(menuManager, window,
- CopyLocalJavaWorkspace.ID, CopyLocalJavaWorkspace.DEFAULT_LABEL,
+ CopyLocalJavaWorkspace.ID,
+ CopyLocalJavaWorkspace.DEFAULT_LABEL,
CopyLocalJavaWorkspace.DEFAULT_ICON, isDistribElem
- && singleElement&& isLocal, params);
+ && singleElement && isLocal, params);
// Clear Workspace
params = new HashMap<String, String>();
CommandUtils.refreshParametrizedCommand(submenu, window,
RunInOsgi.ID, RunInOsgi.DEFAULT_LABEL,
RunInOsgi.DEFAULT_ICON, isDistribElem && singleElement
- && isLocal, params);// Run in OSGi
+ && isLocal, params);
- CommandUtils.refreshCommand(submenu, window,
+ // Open generate binaries
+ params = new HashMap<String, String>();
+ params.put(OpenGenerateBinariesWizard.PARAM_REPO_NODE_PATH,
+ targetRepoPath);
+ params.put(OpenGenerateBinariesWizard.PARAM_MODULE_PATH,
+ modularDistBasePath);
+ params.put(OpenGenerateBinariesWizard.PARAM_WORKSPACE_NAME,
+ workspaceName);
+
+ CommandUtils.refreshParametrizedCommand(submenu, window,
OpenGenerateBinariesWizard.ID,
OpenGenerateBinariesWizard.DEFAULT_LABEL,
OpenGenerateBinariesWizard.DEFAULT_ICON,
- isModularDistBaseElem && !isReadOnly);
+ isModularDistVersionBaseElem && !isReadOnly, params);
if (submenu.getSize() > 0)
menuManager.add(submenu);
}
} catch (RepositoryException e) {
throw new SlcException("unexpected errror while "
- + "building context menu", e);
+ + "building context menu for element " + firstElement, e);
}
}
import java.util.ArrayList;
import java.util.List;
-import javax.jcr.Credentials;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
-import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.dist.DistPlugin;
import org.argeo.slc.client.ui.dist.PrivilegedJob;
+import org.argeo.slc.client.ui.dist.RepoService;
import org.argeo.slc.client.ui.dist.utils.ViewerUtils;
import org.argeo.slc.jcr.SlcTypes;
import org.argeo.slc.repo.RepoConstants;
.getLog(GenerateBinariesWizard.class);
// Business objects
- private String groupNodePath;
- private Repository repository;
- private Credentials credentials;
+ private final RepoService repoService;
+ private final String repoNodePath;
private String wkspName;
+ private String groupNodePath;
// The pages
private RecapPage recapPage;
private Text latestVersionTxt;
private Text highestArtifactVersionTxt;
- public GenerateBinariesWizard(Repository repository,
- Credentials credentials, String wkspName, String groupNodePath) {
+ public GenerateBinariesWizard(RepoService repoService, String repoNodePath,
+ String wkspName, String groupNodePath) {
super();
- this.repository = repository;
- this.credentials = credentials;
+ this.repoService = repoService;
+ this.repoNodePath = repoNodePath;
this.wkspName = wkspName;
this.groupNodePath = groupNodePath;
}
"Confirm Launch", msg);
if (result) {
- GenerateBinaryJob job = new GenerateBinaryJob(repository,
- credentials, wkspName, groupNodePath,
+ GenerateBinaryJob job = new GenerateBinaryJob(repoService,
+ repoNodePath, wkspName, groupNodePath,
versionTxt.getText());
job.setUser(true);
job.schedule();
private void refreshValues() {
Session session = null;
try {
- session = repository.login(credentials, wkspName);
+ session = repoService.getRemoteSession(repoNodePath, null,
+ wkspName);
Node groupNode = session.getNode(groupNodePath);
GenerateBinaries gb = GenerateBinaries.preProcessGroupNode(
groupNode, null);
*/
private class GenerateBinaryJob extends PrivilegedJob {
- private final Repository repository;
- private final Credentials credentials;
+ private final RepoService repoService;
+ private final String repoNodePath;
private final String wkspName;
private final String groupNodePath;
private final String version;
- public GenerateBinaryJob(Repository repository,
- Credentials credentials, String wkspName, String groupNodePath,
- String version) {
+ public GenerateBinaryJob(RepoService repoService, String repoNodePath,
+ String wkspName, String groupNodePath, String version) {
super("Fetch");
this.version = version;
- this.repository = repository;
- this.credentials = credentials;
+ this.repoService = repoService;
+ this.repoNodePath = repoNodePath;
this.wkspName = wkspName;
this.groupNodePath = groupNodePath;
}
Session session = null;
try {
ArgeoMonitor monitor = new EclipseArgeoMonitor(progressMonitor);
- session = repository.login(credentials, wkspName);
+ session = repoService.getRemoteSession(repoNodePath, null,
+ wkspName);
Node groupBaseNode = session.getNode(groupNodePath);
GenerateBinaries.processGroupNode(groupBaseNode, version,
monitor);
/**
* Shortcut to retrieve a session given variable information: Handle the
* case where we only have an URI of the repository, that we want to connect
- * as anonymous or the case of a identified connexion to a local or remote
+ * as anonymous or the case of a identified connection to a local or remote
* repository.
*
* Callers must close the session once it has been used
*/
- public static Session getCorrespondingSession(
- RepositoryFactory repositoryFactory, Keyring keyring,
- Node repoNode, String uri, String workspaceName) {
+ public static Session getRemoteSession(RepositoryFactory repositoryFactory,
+ Keyring keyring, Node repoNode, String uri, String workspaceName) {
try {
if (repoNode == null && uri == null)
throw new SlcException(
}
}
+ /**
+ * Shortcut to retrieve a session on a remote Jrc Repository from
+ * information stored in a local argeo node or from an URI: Handle the case
+ * where we only have an URI of the repository, that we want to connect as
+ * anonymous or the case of a identified connection to a local or remote
+ * repository.
+ *
+ * Callers must close the session once it has been used
+ */
+ public static Session getRemoteSession(RepositoryFactory repositoryFactory,
+ Keyring keyring, Repository localRepository, String repoNodePath,
+ String uri, String workspaceName) {
+ Session localSession = null;
+ Node repoNode = null;
+ try {
+ localSession = localRepository.login();
+ if (repoNodePath != null && localSession.nodeExists(repoNodePath))
+ repoNode = localSession.getNode(repoNodePath);
+
+ return RepoUtils.getRemoteSession(repositoryFactory, keyring,
+ repoNode, uri, workspaceName);
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot log to workspace " + workspaceName
+ + " for repo defined in " + repoNodePath, e);
+ } finally {
+ JcrUtils.logoutQuietly(localSession);
+ }
+ }
+
/**
* Write group indexes: 'binaries' lists all bundles and their versions,
* 'sources' list theire sources, and 'sdk' aggregates both.
- slc:groupBaseId (STRING) m
// Mark a given group base as relevant to create modular distribution in the current workspace
-[slc:category]
-mixin
+// [slc:category]
+// mixin
[slc:distribution] > slc:artifactVersion
mixin
[slc:modularDistributionBase]
mixin
-// Inherit from > slc:categorizedNameVersion ??
-// (not possible without migration)
+// Question: Extend slc:categorizedNameVersion ? (not possible without migration)
[slc:modularDistribution]
mixin
+ slc:modules (nt:unstructured) m
// shared OSGi
public final static String SLC_SYMBOLIC_NAME = "slc:symbolic-name";
public final static String SLC_BUNDLE_VERSION = "slc:bundle-version";
- public final static String SLC_BUNDLE_DESCRIPTION = "slc:Bundle-Description";
// slc:osgiBaseVersion
public final static String SLC_MAJOR = "slc:major";
public final static String SLC_FRAGMENT_HOST = "slc:fragmentHost";
// Distribution management
- public final static String SLC_CATEGORY = "slc:category";
+ // public final static String SLC_CATEGORY = "slc:category";
public final static String SLC_MODULAR_DISTRIBUTION_BASE = "slc:modularDistributionBase";
public final static String SLC_MODULAR_DISTRIBUTION = "slc:modularDistribution";
public final static String SLC_MODULE_COORDINATES = "slc:moduleCoordinates";