How to read an installed feature (eclipse PDE)? - eclipse

Is it possible to read a feature like its possible to read a plugin use the eclipse PDE API? Currently I read plugins using:
Bundle[] bundles = Platform.getBundles(name, version);
if (bundles == null) {
throw new NullPointerException("No bundle found with ID: " + name
+ " and version: " + version);
} else {
for (Bundle bundle : bundles) {
System.out.println(bundle.getSymbolicName());
}
}
But if I specify the name of an installed feature I just get null. Is there some other way that features should be read?
And when I have read the feature I would like to iterate all the plugins that it reference.

You can try to use p2 API to query the installed feature. P2 is the manager of eclipse installation.
// IProvisioningAgent is a OSGi service
IProvisioningAgent agent = ...;
IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME);
IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);
IQueryResult rt = profile.query(QueryUtil.createIUPropertyQuery("org.eclipse.equinox.p2.eclipse.type", "feature"), null);

Related

Using Nuget.Protocol to delete a package from Azure DevOps

I'm writing a simple application to implement package retention in our AzureDevOps NuGet feed, but I can't delete a package -- nothing happens.
(I want to keep all release packages, but delete all pre-release packages for branches that nolonger exist and keep only the latest three pre-release packages for branches that do exist.)
// Log in and whatnot.
PackageSource packageSource = new PackageSource("https://pkgs.dev.azure.com/Organisation/_packaging/Organisation/nuget/v3/index.json")
{
Credentials = new PackageSourceCredential(
source: "https://pkgs.dev.azure.com/Organisation/_packaging/Organisation/nuget/v3/index.json",
username: "rwb#organisation.co.uk",
passwordText: _Pat,
isPasswordClearText: true,
validAuthenticationTypesText: null)
};
NuGet.Protocol.Core.Types.SourceRepository repository = NuGet.Protocol.Core.Types.Repository.Factory.GetCoreV3(packageSource);
PackageSearchResource packageSearch = repository.GetResourceAsync<NuGet.Protocol.Core.Types.PackageSearchResource>().Result;
PackageUpdateResource packageUpdate = repository.GetResourceAsync<PackageUpdateResource>().Result;
// Delete a package -- doesn't work!
packageUpdate.Delete("Organisation.MyDll", "1.0.1-branch.build", packageSource => _Pat, packageSource => true, false, _Logger);
The .Delete doesn't throw an exception or log any error, but the package remains in AzureDevOps.
I think I need to add .Wait() because of the async nonsense, but even so: the packages appear srikethrough in the Azure DevOps website, but not in the feed's recycle bin, and they're still listed in NuGet package manager in VisualStudio.
How do you actually delete the things?
Update
So apparently the C# only delists and you have to use the HTTP API directly to actually delete. However, it's impossible to authenticate.
private static void Delete(NuGet.Packaging.Core.PackageIdentity packageIdentity)
{
// https://learn.microsoft.com/en-us/nuget/api/package-publish-resource
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("X-NuGet-ApiKey", "VSTS");
//httpClient.DefaultRequestHeaders.Add("X-NuGet-ApiKey", _Pat);
//httpClient.DefaultRequestHeaders.Add("X-NuGet-ApiKey", "rwb#organisation.co.uk:" + _Pat);
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", ":" + _Pat);
//httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", "rwb#organisation.co.uk:" + _Pat);
//httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", _Pat);
// https://learn.microsoft.com/en-us/rest/api/azure/devops/artifactspackagetypes/nuget/delete-package-version?view=azure-devops-rest-6.0
HttpResponseMessage rx = httpClient.DeleteAsync($"https://pkgs.dev.azure.com/Organisation/_apis/packaging/feeds/FeedName/nuget/packages/{packageIdentity.Id}/versions/{packageIdentity.Version}?api-version=6.0-preview.1").Result;
}
I had exactly the same issue that the standard NuGet delete will only delist the package.
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "", _Pat))));
What worked for me (authentication-wise) was the ToBase64String conversion.

Enterprise Architect - Import relations

I have a model in Enterprise Architect and I need to import some relationships (of already existing elements) that I have in an Excel. I tried running a JScript but wasn't able to run it (haven't still figured out why).
How can I import a massive amount of relationship into my model?
Thanks in advance.
My Script is:
!INC Local Scripts.EAConstants-JScript
var connectorArray = new Array(
['{870632BA-154F-4564-AD51-C508C1A7E537}','{4B291196-7B4B-490b-B51D-04B9925CAA2A}','Dependency','','RME1']
);
function main()
{
var source as EA.Element;
var target as EA.Element;
var connector as EA.Connector;
var sourceGUID,targetGUID,type,stereotype,alias;
for(var i = 0; i < connectorArray.length; i++) {
sourceGUID = connectorArray[i][0];
targetGUID = connectorArray[i][1];
type = connectorArray[i][2];
stereotype = connectorArray[i][3];
alias = connectorArray[i][4];
source = Repository.GetElementByGuid(sourceGUID);
target = Repository.GetElementByGuid(targetGUID);
Session.Output("Processing connector: " + alias);
if(source != null && target != null) {
connector = source.Connectors.AddNew("",type);
if(stereotype != "") {
connector.Stereotype = stereotype;
}
connector.SupplierID = target.ElementID;
connector.Alias = alias;
connector.Update();
}
source.Connectors.Refresh();
}
Session.Output("END OF SCRIPT");
}
main();
My errors are:
[423447640] Hilo de registro de pila establecido para marcos 3
[423447879] Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[423447879] Agent dll found: C:\Program Files (x86)\Sparx Systems\EA\vea\x86\SSScriptAgent32.DLL
[423447879] Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[423447879] Agent: Started
[423447967] Microsoft Process Debug Manager creation Failed: 0x80040154
[423447967] This is included as part of various Microsoft products.
[423447967] Download the Microsoft Script Debugger to install it.
[423447967] Failed to initialize JScript engine
[423447967] SesiĆ³n de depuraciĆ³n terminada
Thanks again.
Well, may be I'm wrong, but you can see the error Download the Microsoft Script Debugger to install it. I guess, that you're trying to run the script "Debug" button instead of "Run script".
If you want to debug your scrtipt, you"ll must to install any Microsoft product that contains debagger. Microsoft Script Debugger.
FYI Did you try the Excel Import \ Export feature of Sparx Systems in MDG Office Integration .
You can create \ update \ Synchronise model elements, connectors and other details inside enterprise architect in a single click.

wixsharp service not getting installed

This may be a newbie question so excuse me for that.
My installation works fine without any error, All the files get copied to the install folder BUT there is no service installed? Any help is appreciated.
I have a simple installation that copies few files into the install directory and then installs the service from one of the installed files. Here is the my program.cs relevant code
WixSharp.File service;
var project = new ManagedProject("DMACSServer",
new Dir( #"%ProgramFiles%\DRR\DMACS SLM",
new DirFiles(#"Z:\DEV\current\FrameworkDLLS\*.*")));
new Dir(#"%ProgramFiles%\DRR\DMACS SLM",
service = new WixSharp.File(#"Z:\DEV\current\FrameworkDLLS\SLMService.exe"));
service.ServiceInstaller = new ServiceInstaller
{
Name = "DMACS SLM Service",
StartOn = SvcEvent.Install, //set it to null if you don't want service to start as during deployment
StopOn = SvcEvent.InstallUninstall_Wait,
RemoveOn = SvcEvent.Uninstall_Wait,
//DelayedAutoStart = true,
};
project.GUID = new Guid("97b17bfe-6086-4072-8f23-6859a44c4fa4");
project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;
project.ManagedUI = ManagedUI.Empty; //no standard UI dialogs
project.ManagedUI = ManagedUI.Default; //all standard UI dialogs
//custom set of standard UI dialogs
project.ManagedUI = new ManagedUI();
project.ManagedUI.InstallDialogs.Add(Dialogs.Welcome)
.Add<EnvironmentDialog>()
.Add<RolesDialog>()
.Add(Dialogs.InstallDir)
.Add(Dialogs.Progress)
.Add(Dialogs.Exit);
project.ManagedUI.ModifyDialogs.Add(Dialogs.MaintenanceType)
.Add(Dialogs.Features)
.Add(Dialogs.Progress)
.Add(Dialogs.Exit);
project.Load += Msi_Load;
project.BeforeInstall += Msi_BeforeInstall;
project.AfterInstall += Msi_AfterInstall;
project.PreserveTempFiles = true;
//project.SourceBaseDir = "<input dir path>";
//project.OutDir = "<output dir path>";
project.BuildMsi();

Getting currentThreadsBusy in Jboss Enterprise Application Platform (EAP) 7.0.0

We are migrating an application from JBoss 4.2.1 GA to JBos EAP 7.0.0. The application audits currentThreadsBusy that is thread count. This does not work on EAP.
Below is the code snippent
javax.management.MBeanServerConnection server = java.lang.management.ManagementFactory.getPlatformMBeanServer();
javax.management.QueryExp qe = javax.management.Query.finalSubString(javax.management.Query.attr("name"), javax.management.Query.value("-" + request.getLocalPort()));
System.out.println("qu = "+qe.toString());
Set<ObjectInstance> set = server.queryMBeans(new javax.management.ObjectName("jboss.web:type=ThreadPool,*"),qe);
System.out.println("Set = "+set);
String objectName = "";
for (ObjectInstance objectInstance : set) {
if (objectInstance.getObjectName().getCanonicalName().contains("=http")) {
objectName = objectInstance.getObjectName().getCanonicalName();
}
}
System.out.println("objectName = "+objectName);
Object object = server.getAttribute(new ObjectName(objectName),"currentThreadsBusy");
System.out.println("object "+object);
The issue is the Set returned is NULL.
The issue could be we need to enable web thread monitoring on EAP 7 before we can query the mbean service.
In the jConsole too we cannot see the web thread component.
Any pointer or help is appreciated here.

How to set Gradle Artifactory Publish plugin default configuration/properties from custom plugin

I have been trying to set the properties of publish(PublisherConfig), defaults(defaultsClosure) from my custom plugin. What is the best way to do this ?
I tried the following;
Approach 1: Tried setting the properties on the extensions
project.getExtensions().publishing.getProperties().each { println it }
Approach 2: Tried adding compile time dependency on the Gradle Artifactory plugin and importing the plugin classes...
```
if (project.plugins.hasPlugin("com.jfrog.artifactory")) {
println "I found jfrog.artifactory plugin"
Plugin jfrogArtifactory = project.getPlugins().getPlugin("com.jfrog.artifactory")
ArtifactoryPluginConvention apc = new ArtifactoryPluginConvention(project);
project.getExtensions().add("artifactory", apc);
apc.contextUrl = 'https://myrepo.com/artifactory/'
PublisherConfig pc = new PublisherConfig(apc);
pc.defaults {
println "in my plugin pc.defaults : " + it.metaClass
publications('mavenJava')
publishConfigs('archives', 'published')
properties = ['my.gitCommitUrl': project.getExtensions().findByType(BuildPropertiesPluginExtension.class).gitCommitUrl, 'my.gitHash': project.getExtensions().findByType(BuildPropertiesPluginExtension.class).gitHash, 'my.gitBranch': project.getExtensions().findByType(BuildPropertiesPluginExtension.class).gitBranch]
publishBuildInfo = true //Publish build-info to Artifactory (true by default)
publishArtifacts = true //Publish artifacts to Artifactory (true by default)
publishPom = true //Publish generated POM files to Artifactory (true by default).
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default).
}
pc.repository {
println "in my plugin pc.repository : " + it.metaClass
repoKey = 'my-mvn' //The Artifactory repository key to publish to
username = project.findProperty("artifactory_user") ?: "" //The publisher user name
password = project.findProperty("artifactory_api_key") ?: "" //The publisher password
}
apc.setPublisherConfig(pc)
}
```
Compile and Build are successful, artifact and its info is not published.
:artifactoryPublish
BUILD SUCCESSFUL
Total time: 3.313 secs
Here is what worked for me!!!
`
if (project.plugins.hasPlugin("com.jfrog.artifactory")) {
Plugin jfrogArtifactory = project.getPlugins().getPlugin("com.jfrog.artifactory")
//maven install task is required to publishPom (using artifactory plugin)
if (!project.plugins.hasPlugin("maven")) {
project.apply(plugin: MavenPlugin)
}
Closure artifactoryPublishClosure = {
contextUrl = 'https://myrepo.com/artifactory/'
publications('mavenJava')
publishConfigs('archives', 'published')
properties = ['gitCommitUrl': project.getExtensions().findByType(BuildPropertiesPluginExtension.class).gitCommitUrl, 'gitHash': project.getExtensions().findByType(BuildPropertiesPluginExtension.class).gitHash, 'gitBranch': project.getExtensions().findByType(BuildPropertiesPluginExtension.class).gitBranch]
publishBuildInfo = true //Publish build-info to Artifactory (true by default)
publishArtifacts = true //Publish artifacts to Artifactory (true by default)
publishPom = true //Publish generated POM files to Artifactory (true by default).
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default).
// Redefine basic properties of the build info object
clientConfig.setIncludeEnvVars(true)
clientConfig.timeout = 600 // Artifactory connection timeout (in seconds). The default timeout is 300 seconds.
publish {
//A closure defining publishing information
repository {
repoKey = 'my-mvn' //The Artifactory repository key to publish to
username = project.findProperty("artifactory_user") ?: "" //The publisher user name
password = project.findProperty("artifactory_api_key") ?: "" //The publisher password
}
}
resolve {
repository {
repoKey = 'my-mvn' //The Artifactory (preferably virtual) repository key to resolve from
}
}
}
project.getTasks().findByName("artifactoryPublish").configure(artifactoryPublishClosure)
}
`