generating thumbnails in Alfresco 4.0.d - web-services

I am using the Java web services in Alfresco Community 4.0.d and currently looking to add thumbnail functionality to my site. I noticed the thumbnails are not available immediately after posting a new image; I was wondering if someone can recommend a good approach to have the generation triggered manually?

Answered your question in the forums as well. Using the JavaScript API you can ask a document to generate its thumbnail, like this:
document.createThumbnail("doclib");
In this case, "doclib" is the name of the thumbnail configuration for the document library thumbnails in Share, but this could be any thumbnail definition you've created.
Docs live at http://docs.alfresco.com/4.0/topic/com.alfresco.enterprise.doc/references/API-JS-Thumbnail-createThumbnail.html
For Java, look at the org.alfresco.repo.thumbnail.CreateThumbnailActionExecuter class source. In your own class you could do something similar. Or, better yet, use the actionService to invoke the create-thumbnail action.
To use the Action Service, all you need is the name of the action and the parameters it expects. For example, here's what it looks like when you use the mail action:
ActionService actionService = getServiceRegistry().getActionService();
Action mailAction = actionService.createAction(MailActionExecuter.NAME);
mailAction.setParameterValue(MailActionExecuter.PARAM_SUBJECT, ExternalReviewNotification.SUBJECT);
mailAction.setParameterValue(MailActionExecuter.PARAM_TO, recipient);
mailAction.setParameterValue(MailActionExecuter.PARAM_FROM, ExternalReviewNotification.FROM_ADDRESS);
mailAction.setParameterValue(MailActionExecuter.PARAM_TEXT, sb.toString());
actionService.executeAction(mailAction, null);
To do this for thumbnails, you'll use "create-thumbnail" for the name (or CreateThumbnailActionExecuter.NAME). Looking at the source for that class I see that it takes two parameters, PARAM_CONTENT_PROPERTY, which would be "cm:content", and PARAM_THUMBNAIL_NAME which would be "doclib" for the normal document library thumbnail or your thumbnail name if you've defined your own.
One thing to note, in the executeAction call, that second argument is the "actioned upon noderef". In your case, you'll want that to be the node you are generating the thumbnail for.

Related

HelloSign: how to duplicate a template though API?

The following screenshot is the manual approach to duplicate a template.
Is there an API to do it?
# API like this
HelloSignClient.duplicate_template(template_id)
This is Hazem from HelloSign API Support team.
Take a look at the /template endpoints - to replicate the "Duplicate" feature on hellosign.com for templates, you'd use GET /template/files (if you need the original files), and then POST /template/update_files. That creates a new template using the original template's overlay, and the "new" or the same documents that you pass in (which in this case would be files from your GET /template/files call).
For more details about this endpoint, please check the links below:
*Update Template Files
https://app.hellosign.com/api/reference#update_template_files
*Get Template Files
https://app.hellosign.com/api/reference#get_template_files

drf-yasg Customize SwaggerUIRenderer

I'd like to customize the style (font, colors, logo, etc) of drf_yasg generated docs.
I see that I can extend drf_yasg/swagger-ui.html with the blocks extra_head, extra_styles, extra_body, extra_scripts, and can even overwrite the other blocks if I need to.
What I am not clear on is how I point to my template that extends swagger-ui.html.
I started with
class MyCustomSwaggerUIRenderer(SwaggerUIRenderer):
template = 'api/custom-swagger-ui.html'
I want to replace SwaggerUIRenderer with MyCustomSwaggerUIRenderer in get_schema_view but do not understand how/where to do it without explicitly trying to enumerate all the other Renderers required too in some subclass of rest_framework.views.APIView and that seems convoluted.
Pointers to docs or examples are appreciated. I've already read https://drf-yasg.readthedocs.io/ without success.
You don't have to create a custom class for this. You just need to create a directory with the name drf-yasg under new or existing app and then place a file with the name swagger-ui.html underneath it with your custom template. For example, if you already have an app with the name api, you can just put it under api/templates/drf-yasg/swagger-ui.html. Make sure the app api is specified before drf-yasg in INSTALLED_APPS.
Reference: https://github.com/axnsan12/drf-yasg/issues/294#issuecomment-464461773

OTRS search via deep link possible?

I want to link to our OTRS (version 5) -- is it possible to create a URL in such a way that a special parametrized search is performed within OTRS?
I'd like to link from a webpage to something like:
https://otrs.charite.de?Ralf.Hildebrandt#charite.de
and that should display all tickets in the queue XYZ and customeruser == Ralf.Hildebrandt#charite.de
Unfortunately that's not possible out of the box - at least in the way you probably intend to use it. All real search functions in OTRS (that I'm aware of) use HTTP-POST. Parameterized POST request using an URL is in principle possible, but strongly discouraged and wouldn't really work if you intend to store those searches as bookmarks or something like that.
The good news - you can create a saved search and trigger that via a URL like this:
https://url.to.otrs.de/otrs/index.pl?Action=AgentTicketSearch;Subaction=Search;TakeLastSearch=1;SaveProfile=1;Profile=current%20Changes
In this case the Profile=current%20Changes would be replaced by the name of the search profile (Special Characters must be encoded).

Can a Custom DataProvider class expose Custom Templates?

I am currently in the process of writing a custom DataProvider. Using the Intergrate External Data documentation.
I've managed to show the external data in the Sitecore back end. However whenever I try to view the data in the items I created, I am getting an error
Null ids are not allowed. <br> Parameter name: displayName
There seems to be precious little on the subject on how to create a custom DataProvider on the Sitecore Developer Network.
The example on their website seems to only show how to import a SINGLE item into a static database. However I am simply trying to merge some items into the hierarchy and I can't find any useful documentation.
It seems that one of your methods that should return an ID doesn't. It might be GetChildIds and/or GetParentId.
Nick Wesselman wrote a good article about it gathering all the information including an example on the Marketplace. I think that is your best start. You can read it here.
Turns out I needed to include at the very least, the Fields->Section->Template in the GetParent method. To be on the safe side I included the Fields/Sections/Templates into my implementations of
GetChildIDs
GetItemDefinition
GetParentID
It wasn't obvious that this was the case, since I had in fact implemented the GetTemplates method correctly, and I had expected that should be enough.

SharePoint Web Services - Updating ContentType field Required property?

I've been trying to programmatically reproduce the behavior of editing a Content Type's field properties in the SharePoint site management screen and selecting the "Required" radio button with no sucess using the WSS 3.0 web service's Webs.asmx "UpdateContentType" method.
The first difficulty was the issue with the MSDN documentation that said fields should be of a FieldRef type when in fact they need to be of a Field type (reference). Adding fields and deleting fields works fine after the fix, but updating fields seems to not function at all. (It should also be noted that I followed the recommendation on the previous link to use Method="2" for updating fields but it changes nothing, and using Method values other than 1 for adding or other than 3 for deleting also function correctly).
Here's the web service call (slightly modified with strings instead of XmlNode objects for readability):
SharePointWebServices.Webs webService = new SharePointWebServices.Webs();
webService.Url = "http://mysharepointserver/site";
webService.UseDefaultCredentials = true;
webService.UpdateContentType(
#"0x01005A089D9EC8A382458FB1F6C72096D52A",
#"<ContentType />",
#"<Fields />",
#"<Fields><Method ID=""1""><Field Name=""SomeField"" ID=""{8a4803c4-6545-4a7a-804d-237eebff0ce3}"" Required=""TRUE"" Hidden=""FALSE"" ReadOnly=""FALSE"" PITarget="""" PIAttribute="""" PrimaryPIAttribute="""" Aggregation="""" Node="""" /></Method></Fields>",
#"<Fields />");
After the call, the field is still Required="FALSE".
A quick look into the stssoap.dll assembly indicates that the "Required" property is apparently ignored during the update process. Is this normal behavior? If so, what is the recommended method for programmatically changing the "Required" field from client code (not executing on the SharePoint server)?
Any help would be greatly appreciated.
I've investigated this and found the same thing. I also tried adding the attribute Cmd="Update" to the Method element without success. This example of how to use UpdateContentType was helpful too.
I don't believe you will be able to do this with the out-of-the-box SharePoint services. You've verified from looking at stssoap.dll that this doesn't appear to work correctly. Another 'client'-style option is to use RPC methods but none appear to provide functionality for content types at all.
The web services are particularly frustrating because this type of not-so-edge case regularly comes up. It is very rare that I consider using them because of the time wasting involved with their limitations.
Do you have any option of deploying custom code to the server? You could develop this functionality using the object model and wrap it in your own custom web service (there is a walkthrough here) quite easily.
Here is an example adapted from Gabe Wishnie that does what you require:
SPContentType myContentType = myWeb.ContentTypes["myContentType"];
string internalName = myContentType.Fields["fieldToUpdate"].InternalName;
myContentType.FieldLinks[internalName].Required = false;
myContentType.Update(true);
Sorry this isn't more helpful but it's a common story when using the WSS 3.0 / SharePoint 2007 web services.