Autoupgrade of an Eclipse (Lotus Notes 8.5.2) plugin - eclipse-plugin

I am trying to provide an autoupdate feature for a Lotus Notes 8.5.2. The plugin is being developed under Eclipse 3.4.2. So far I haven't managed to find a standard way for doing this by hooking into the Lotus Notes API. What comes to my mind are the following two approaches.
use the Eclipse p2 SDK to perform the autoupgrade at runtime (at early startup of the plugin the updater will be checking for new versions and update the plugin). This entry describes the approach -> http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fp2_api_overview.htm. Unfortunately the SDK is not part of Eclipse 3.4.2 and I didn't manage to use this approach with 3.4.2.
use an external process that closes Lotus Notes, removes the old version of the plugin from the plugin directory of Lotus, copies the new version to the plugin directory, starts Lotus Notes again and terminates the process.
The second approach seems reasonable but requires closing of Lotus Notes during the autoupgrade process. So my question is - is there any approach similar to the first one above or any other standard procedure for Lotus Notes ? Thanks in advance.

Have a read of the widget catalog. It will do what you want.
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.help.domino.admin85.doc/H_MANAGING_CLIENTS_USING_WIDGETS_AND_THE_WIDGETS_CATALOG_OVER.html
You will still need to restart the client after any plugin updates though.

Thanks for the suggestion Simon - I have found a more direct way using the suggestion from this post -> http://www.eclipsezone.com/eclipse/forums/t97689.html
with the addition of a configure operation (IConfigureFeatureOperation) for update the version of the feature to the platform.xml file of Lotus Notes.
Here is a sample snippet that illustrates the approach:
String updateSiteUrl = configuration.getUpdateSiteUrl();
IProgressMonitor monitor = new NullProgressMonitor();
ISite updateSite = SiteManager.getSite(new URL(updateSiteUrl),
monitor);
IFeatureReference[] siteFeatures = updateSite
.getFeatureReferences();
ILocalSite localSite = SiteManager.getLocalSite();
List<IInstallFeatureOperation> installOps = new ArrayList<IInstallFeatureOperation>();
List<IConfigFeatureOperation> configOps = new ArrayList<IConfigFeatureOperation>();
IConfiguredSite[] configuredSites = localSite
.getCurrentConfiguration().getConfiguredSites();
for (IConfiguredSite configuredSite : configuredSites) {
IFeatureReference[] localSiteFeatures = configuredSite
.getConfiguredFeatures();
for (IFeatureReference siteFeature : siteFeatures) {
for (IFeatureReference localSiteFeature : localSiteFeatures) {
VersionedIdentifier featureVi = siteFeature
.getVersionedIdentifier();
VersionedIdentifier localFeatureVi = localSiteFeature
.getVersionedIdentifier();
if (featureVi.getIdentifier().equals(
localFeatureVi.getIdentifier())) {
if (featureVi.getVersion().isGreaterThan(
localFeatureVi.getVersion())) {
installOps
.add(OperationsManager
.getOperationFactory()
.createInstallOperation(
configuredSite,
siteFeature
.getFeature(monitor),
null, null, null));
configOps
.add(OperationsManager
.getOperationFactory()
.createConfigOperation(
configuredSite,
siteFeature
.getFeature(monitor),
null, null));
}
}
}
}
}
if (installOps.size() > 0) {
// install new feature
for (Iterator<?> iter = installOps.iterator(); iter
.hasNext();) {
IInstallFeatureOperation op = (IInstallFeatureOperation) iter
.next();
op.execute(monitor, null);
}
// configure new feature
for (Iterator<?> iter = configOps.iterator(); iter
.hasNext();) {
IConfigFeatureOperation op = (IConfigFeatureOperation) iter
.next();
op.execute(monitor, null);
}
localSite.save();}

Related

Run a shell command when a specific object is detected in YOLO

Hi I don't have much experience in C or YOLO so does anyone know what edits in demo.c I should make to be able to run a shell command whenever a specific object is detected?
Many thanks
Maybe you have some experience with .NET/C#.
You need install this two nuget packages in your project after this you can copy my exampel code. If yolo detect a motorbike a external process are starting. If you need some other objects you can use your own yolo model instead of YoloV2TinyVocData.
Install-Package Alturos.Yolo
Install-Package Alturos.YoloV2TinyVocData
Example code
var configurationDetector = new ConfigurationDetector();
var config = configurationDetector.Detect();
using (var yoloWrapper = new YoloWrapper(config))
{
var items = yoloWrapper.Detect(#"image.jpg");
foreach(var item in items)
{
if (item.Type.Equals("Motorbike", StringComparison.OrdinalIgnoreCase))
{
Process.Start("yourcommand.exe");
}
}
}

Spring shell 2.0 how to read inputs with mask

Is there any way to mask user inputs in Spring Shell 2.0.x ?
I need to collect password from user.. did not find any shell api to do that.
Thanks!!
Found that LineReader#readLine(msg,mask) provides that option.
All you have to do is inject the LineReader bean.
If you don't want to rely on third party libraries, you can always do a standard Java console input, something like:
private String inputPassword() {
Console console = System.console();
return new String(console.readPassword());
}
Note though that when running this in an IDE, the System.console() might be null. So you should probably handle that if running in an IDE is something you want to support (for testing for example..) something like:
private String inputPassword() {
Console console = System.console();
// Console can be null when running in an IDE
if (console == null) {
System.out.println("WARNING - CAN'T HIDE PASSWORD");
return new Scanner(System.in).next();
}
return new String(console.readPassword());
}

How do I launch a certain project using SWTBot

Not every plugin can be tested without project. For example, I want to test CDT-Plug-in, therefore I need to import a C-project. But there is no such point in Run Configuration and when I'm trying to record importing actions via SWT Plug-in Test recorder SWTBot can't replay them afterwards. Google is silent on this topic. How do I do that?
A nice way to do this is using the eclipse recource model
Have a look at the package
org.eclipse.core.resources
Here is a method, that creates a new project in the workspace
private IProject getNewOpenProject(IWorkspace wks, String name)
throws CoreException {
System.out.print("Creating project " + name + "...");
IProjectDescription prj1ProjectDescription = wks
.newProjectDescription(name);
IProject prj = wks.getRoot().getProject(name);
prj.create(prj1ProjectDescription, null);
prj.open(null);
System.out.println(" [OK]");
return prj;
}
This method will import your content into the eclipse project
private void importDirIntoProject(File srcPath, IProject prj,
IOverwriteQuery overwriteQuery) throws InvocationTargetException,
InterruptedException {
ImportOperation op = new ImportOperation(prj.getFullPath(), srcPath,
FileSystemStructureProvider.INSTANCE, overwriteQuery);
op.setCreateContainerStructure(false);
op.run(new NullProgressMonitor());
}
This approach uses native eclipse mechanisms. I think this is better than using the inconvenient way over SWTBot.
It's the responsibility of your test to create the necessary resources in its setup method, and clean them after. It's not something to configure in the Run Configuration, but to code in your test.
You can either use SWTBot to import/create a C project, or use the project APIs suggested by beanie.

Error when trying add data to RavenDb

I'm using autofac and the interfaces are correctly resolved but this code fails with "No connection could be made because the target machine actively refused it 127.0.0.1:8081"
using (var store = GetService<IDocumentStore>())
{
using (var session = store.OpenSession())
{
session.Store(new Entry { Author = "bob", Comment = "My son says this", EntryId = Guid.NewGuid(), EntryTime = DateTime.Now, Quote = "I hate you dad." });
session.SaveChanges();
}
}
Here is the registration
builder.Register<IDocumentStore>(c =>
{
var store = new DocumentStore { Url = "http://localhost:8081" };
store.Initialize();
return store;
}).SingleInstance();
When I navigate to http://localhost:8081 I do get the silverlight management UI. Although I'm running a Windows VM and vmware and Silverlight5 don't play together. That's another issue entirely. Anyways does anyone see what I'm doing wrong here or what I should be doing differently? Thanks for any code, tips, or tricks.
On a side note, can I enter some dummy records from a command line interface? Any docs or examples of how I can do that?
Thanks All.
Just curious, are you switching RavenDB to listen on 8081? The default is 8080. If you're getting the management studio to come up, I suspect you are.
I'm not too familiar with autofac but, it looks like you're wrapping your singleton DocumentStore in a using statement.
Try:
using (var session = GetService<IDocumentStore>().OpenSession())
{
}
As far as dummy records go, the management studio will ask you if you want to generate some dummy data if your DB is empty. If you can't get silverlight to work in the VM, I'm not sure if there's another automated way to do it.
Perhaps using smuggler:
http://ravendb.net/docs/server/administration/export-import
But you'd have to find something to import.

eclipse RCP UI through java code

Can I implement Eclipse RCP UI using java code only and not plugin.xml?
While it might be possible in theory (eclipse plugins are OSGi bundle which are read by the extension registry), I don't think it is practical (unless you re-implement the extension registry lifecycle).
Eclipse Equinox precisely extends the concept of bundles with the concept of extension points, hence the mandatory presence of plugin.xml.
You can programmatically add and remove extensions. See following example methods (adapt on demand):
public void addExtension() throws UnsupportedEncodingException {
String pluginXmlAsString = "<a string with the content of plugin.xml";
InputStream pluginXmlIs = new ByteArrayInputStream(pluginXmlAsString.getBytes(StandardCharsets.UTF_8.name()));
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
Object token = ((ExtensionRegistry) extensionRegistry).getTemporaryUserToken();
IContributor contributor = ContributorFactoryOSGi.createContributor(Platform.getBundle("org.acme.mybundle"));
extensionRegistry.addContribution(pluginXmlIs, contributor, false, null, null, token);
}
public static void removeExtensionsContributedByMe() {
String extensionPointId = "<ID of the extension point for remove an extension of";
String extensionContributor = "org.acme.mybundle";
ExtensionRegistry extensionRegistry = (ExtensionRegistry) Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(extensionPointId);
IExtension[] extensions = extensionPoint.getExtensions();
Object token = extensionRegistry.getTemporaryUserToken();
for (IExtension extension : extensions) {
if (extensionContributor.equals(extension.getContributor().getName())) {
extensionRegistry.removeExtension(extension, token);
}
}
}
We use this for unit tests which add extensions as preparation and remove extension to clean up. This way the tests do not influence each other (which would be the case if the extensions are "hard coded" in plugin.xml or fragment.xml).