Call a custom document converter using Sharepoint Object Model - sharepoint

How to call a custom SharePoint converter that is activated for a specific website.
For example, the below code is used to get the GUID of that converter
foreach (SPDocumentConverter converter in converters)
{
//Console.WriteLine(converter.DisplayName);
if (converter.ConvertFrom.ToLower().Equals("pdf") && converter.ConvertTo.ToLower().Equals("jpg"))
pdfToJpgConverterId = converter.Id;
}
and the SPFile.Convert method is used to call the converter usually. But when I am trying to call the document converter using SpFile.Convert method, its not calling it.
My custom conveter takes 2 command line arguments. How can I pass them to my converter when I called it using SharePointObject model or some other.
Update:
A document converter is custom executable file, which is deployed to a specific website as a feature. I want to transform the given pdf file into images by supplying the file name to the document converter using Sharepoint object model. SPFile.Convert method has an argument like "-config", which is a third parameter where we pass the required information(parameters). Can anyone help in this regard?

You may want to consider invoking the process directly using Process.Start and passing the command line arguments.

Related

JAXB how to remove anything from JDefinedClass

i am using jaxb to generate code from an xsd.
The generated code contains a lot of annotations; for classes and fields.
I am trying to use com.sun.tools.internal.xjc.Plugin to modify the generated code.
In the plugin run() method we are given an Outline class from which we can get ClassOutline. ClassOutline has an JDefinedClass final member which has the info about actual class which will be generated.
If i want to add anything, there are apis in JDefinedClass which can be used. But if i want to remove something, there is no way.
e.g. i cannot clear annotations, because the JDefinedClass.annotations() method returns an UnmodifiableCollection. so i cannot clear it or remove anything from it.
i tried to create another JDefinedClass by invoking the _class method but the ClassOutline.implClass variable is final, so i cannot set it.
how to get a JDefinedClass which does not have any annotations?
is there another phase of code generation which i can trap into to really control the generation of JDefinedClass?
The code model is, indeed mostly "write only". But, speaking of annotations, you have probably missed the methods like com.sun.codemodel.JDefinedClass.removeAnnotation(JAnnotationUse) and com.sun.codemodel.JMethod.removeAnnotation(JAnnotationUse) (implemented from com.sun.codemodel.JAnnotatable.removeAnnotation(JAnnotationUse)).
So they're there. You can remove annotations with the normal CodeModel API.
As I can see, you can also remove fields and methods from classes. So what exactly are you missing?
JDefinedClass.annotations() It return an unmodifiable collection object and you cannot modify them.
So work around for this, you can restrict annotation addition/deletion at class and field level before building JCodeModel.
You need to create a custom Jackson2Annotator class which extends Jackson2Annotator and override their methods according to your requirement.
Following are few methods which are being used for specific type of annotation property:
propertyOrder(OTB JsonPropertyOrder)
propertyInclusion(OTB JsonInclude)
propertyField(can be used for custom defined annotation at field level)
More you can discover by looking Jackson2Annotator class what fit into your need.

How can I update the status of a Test

We are automating tests using selenium, and I would like to be able to update the test to their latest status based on the result of the automated test.
I'm able to identify the test, but it appears the Status property does not have a setter.
It sounds like you're using the Object Model library.
The Object Model library does not, in fact, have a setter for that property. It may expect you to use an Operation on that asset to adjust status, such as .Close()
The SDK API library has more fine-grained access and allows more arbitrary asset editing. You may also hit the rest-1.v1 API endpoint directly with an XML body describing your attribute change. You'd need to know the ID of the TestStatus list item you want to set it to, and do a single-valued relation update
Do you have code you can share?
Once I have a VersionOne.SDK.ObjectModel.Test object I was able to do the following:
Test test = null;
test = FindTest(regressionTest); // This finds the Test object.
test.Status.CurrentValue = status;
test.Save();

Dynamic method parameters

I writing a node.js application using rethinkdb as a backend.
To retrieve a json value you can use:
r.table('users').get(1).run()
That method call will return the full json document, there is however a method that allows you to specify the attributes to retrieve e.g:
r.table('users').get(1).pick('firstName', 'lastName').run()
I want to make use of this functionality and I have the attributes I want to 'pick' stored in an array. I can't seem to figure out a way to convert this array to a parameter list for the .pick method.
Please advice.
Just use the native apply method to directly pass the arguments array:
r.table('users').get(1).pick.apply(this,yourArray).run()
further reading

Custom Control Custom Methods?

I have been making good use of custom properties withing custom controls. Is there such thing as custom methods? Say I want something to happen in a CC. A good example is the show method of the dialog box extension. If I have a cc with a extension dialog inside, I want my custom control to have a Show method which insulates the end user programmer from the extension pages Shoe method.
Is there anyway to do this?
At runtime, all Custom Control elements become instances of the UIIncludeComposite class; as such, there are many built in methods that you can call against any given control instance, but there is no way to specify custom methods, as opposed to custom properties.
There are, however, at least two ways you could achieve the result you're after:
Convert your Custom Control to a component (this NotesIn9 episode describes the simplest approach to this process). Once you've migrated the class that Designer generated to one that won't get overridden every time you build your NSF, you can add custom methods without fear that the next build will just wipe them out again. Since Custom Controls are essentially just IBM's implementation of the JSF 2.0 notion of "composite components", you could also create a component from scratch that has the same behavior as your existing Custom Control but also supports custom behavior. Note that either approach does not necessarily require that you create an OSGi library... you can define these components directly in an NSF; you only need to push them to a library if you want to reuse them across multiple NSFs without having to copy the various files to each.
In the custom properties for your control, include one property that accepts an API object. In other words, you could create any object (say, a Java class or SSJS object) that supports the custom methods you wish to define, and pass that object to the control. You could then call those methods by getting a handle on the object via the CC's property map.
For example:
<myCC id="myCustomControl" API="#{someObject}" />
Assuming whatever #{someObject} resolves to includes a show() method, you can call that method by getting a handle on the instance that has been passed to the control:
var cc = getComponent("myCustomControl");
var ccProperties = cc.getPropertyMap();
var ccAPI = ccProperties.get("API");
ccAPI.show(cc);
In the above example, I'm passing the actual Custom Control to the show() method, because the object itself isn't aware of the Custom Control it was passed to. So if that method needs to get a handle on its children to toggle their rendered property, for example, then it needs some other way of determining its context.
Tim's solution with passing in the object is a great solution to that.
Just something that popped into my head, would be easy to make a property similar to the rendered property on a control. Pass in a value and inside the custom control do something based on its value ie. if true display dialog, else hide, in the XPage during run time modify this value and partial refresh the control, the logic will be re run by this and the control will display etc.
Another solution could be to include a JavaScript library in your custom control providing functions (your custom control methods) where you'd have to pass in the id of the custom control instance.

JSF: How do I include parameters in an action method's return string?

I'm writing an action method that will store a new object in a database. Once this is done, I want to navigate to view that newly created object. To do this, I was planning to include a querystring or some sort of parameter in the return String of the action method, but I can't figure out how. If I append a query string manually, it appears that it's being ignored. Also, manually adding parameters by concatenating strings doesn't seem like a good idea to me. Is it possible to do this in a type-safe manner?
The way I've always handled this is to get a reference to the bean which provides the content for the page you'll be displaying, and just set its properties directly. The navigation string returned from an action method isn't meant for passing parameters, but you don't need it to; all they'd be used for is setting bean properties anyway.

Resources