Bing Translator API with Coldfusion - azure

In my coldfusion application im using Microsoft Bing Translation API.
To be honest I don't know where to start? let me write what I have already done.
Registered (https://datamarket.azure.com/account)
Got 3 things from Microsoft
Primary Account Key Eg(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
Customer ID Eg(xxxxxxxxxxxxx)
App ID Eg(mynameid)
What I have already tried OR Failed Attempts :
ColdFusion:
<cfhttp url="http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=mynameid&from=en&to=de&text=HELLO" result="rs" method="post"></cfhttp>
OUTPUT:
'to' must be a valid language Parameter name
<cfhttp url="http://api.microsofttranslator.com/v2/Http.svc/Translate" result="rs" method="post">
<cfhttpparam name="appId" type="header" value="mynameid" />
<cfhttpparam type="header" name="method" value="POST" />
<cfhttpparam type="header" name="from" value="en" />
<cfhttpparam type="header" name="to" value="de" />
<cfhttpparam type="header" name="text" value="HELLO" />
</cfhttp>
<cfdump var="#rs#">

Related

Liferay search container in Spring MVC portlets

Is it possible to use Liferay search container in spring portlets? when i tried, nothing is rendering in the page. i have enclosed the code. am just adding the data in session and trying to show in search container.
<%
final PortletSession sessData = renderRequest.getPortletSession();
List<Detail> details = (List<Detail>) sessData.getAttribute("DETAILS",PortletSession.PORTLET_SCOPE);
%>
<liferay-ui:search-container delta="3" emptyResultsMessage="No Details found" headerNames="User ID, First Name, Last Name, Address">
<%
int numOfRecords = details.size();
%>
<liferay-ui:search-container-results results="<%= details %>" total="${numOfRecords}">
</liferay-ui:search-container-results>
<liferay-ui:search-container-row className="Detail" modelVar="detailData">
<liferay-ui:search-container-column-text name="User ID" property="userId" />
<liferay-ui:search-container-column-text name="First Name" property="firstName" />
<liferay-ui:search-container-column-text name="Last Name" property="lastName" />
<liferay-ui:search-container-column-text name="Address" property="address" />
</liferay-ui:search-container-row>
</liferay-ui:search-container>
I missed to add the search-iterator.
<liferay-ui:search-iterator searchContainer="<%=searchContainer%>"
paginate="<%=isNeeded%>" />

Query optimization in liferay

I have created a portlet where I want to print the list of users based on some parameter. So for showing list of users I use the following code,
<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found">
<liferay-ui:search-container-results
results="<%= UserLocalServiceUtil.getUsers(0, UserLocalServiceUtil.getUsersCount())%>"
/>
<liferay-ui:search-container-row
className="com.liferay.portal.model.User"
keyProperty="userId"
modelVar="user"
>
<liferay-ui:search-container-column-text
name="name"
value="<%= user.getFullName() %>"
/>
<liferay-ui:search-container-column-text
name="first-name"
property="firstName"
/>
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<liferay-ui:search-container delta="10" emptyResultsMessage="no-users-were-found">
But i don't want all the users list. I need only the list of users whose facebookId = 12345. How can query the condition? Any suggestions please..
Thanks in advance

SignatureDoesNotMatch error with Amazon S3 and ColdFusion PutObject request

Probably simple issue but pulling hair out trying to figure it out.
This code to generate a signature and make a rest post to s3 works perfectly:
<cfset cs = "PUT\n\n#arguments.contentType#\n#dateTimeString#\nx-amz-acl:#arguments.acl#\nx-amz-storage-class:#arguments.storageClass#\n/#arguments.bucketName#/#arguments.keyName#">
...
<cfhttp method="PUT" url="https://s3.amazonaws.com/#arguments.bucketName#/#arguments.keyName#" timeout="#arguments.HTTPtimeout#">
<cfhttpparam type="header" name="Authorization" value="AWS #variables.accessKeyId#:#signature#">
<cfhttpparam type="header" name="Content-Type" value="#arguments.contentType#">
<cfhttpparam type="header" name="Date" value="#dateTimeString#">
<cfhttpparam type="header" name="x-amz-acl" value="#arguments.acl#">
<cfhttpparam type="header" name="x-amz-storage-class" value="#arguments.storageClass#">
<cfhttpparam type="body" value="#binaryFileData#">
</cfhttp>
But I want to add s3 managed AES256 encryption which if I understand right should be as simple as adding the x-amz-server-side​-encryption header with the value of AES256 but this does not work:
<cfset cs = "PUT\n\n#arguments.contentType#\n#dateTimeString#\nx-amz-acl:#arguments.acl#\nx-amz-storage-class:#arguments.storageClass#\nx-amz-server-side​-encryption:aes256\n/#arguments.bucketName#/#arguments.keyName#">
...
<cfhttp method="PUT" url="https://s3.amazonaws.com/#arguments.bucketName#/#arguments.keyName#" timeout="#arguments.HTTPtimeout#">
<cfhttpparam type="header" name="Authorization" value="AWS #variables.accessKeyId#:#signature#">
<cfhttpparam type="header" name="Content-Type" value="#arguments.contentType#">
<cfhttpparam type="header" name="Date" value="#dateTimeString#">
<cfhttpparam type="header" name="x-amz-acl" value="#arguments.acl#">
<cfhttpparam type="header" name="x-amz-storage-class" value="#arguments.storageClass#">
<cfhttpparam type="header" name="x-amz-server-side​-encryption" value="aes256">
<cfhttpparam type="body" value="#binaryFileData#">
</cfhttp>
The signature method is:
<cffunction name="createSignature" returntype="string" access="public" output="false">
<cfargument name="stringIn" type="string" required="true" />
<!--- Replace "\n" with "chr(10) to get a correct digest --->
<cfset var fixedData = replace(arguments.stringIn,"\n","#chr(10)#","all")>
<!--- Calculate the hash of the information --->
<cfset var digest = HMac(fixedData, variables.secretAccessKey, "HMACSHA1", "utf-8")>
<!--- fix the returned data to be a proper signature --->
<cfset var signature = ToBase64( binaryDecode(digest, "hex" ) )>
<cfreturn signature>
</cffunction>
When trying to use encryption I get "The request signature we calculated does not match the signature you provided. Check your key and signing method."
Its not the keys themselves since I can add/remove/list just fine. I just can't add the encryption header.
Anybody tell me what is wrong?
...And I tried both 'AES256' and 'aes256' as values.
Turns out it was stupid...and it took much digging to find a single line mention it in the docs.
The Amazon headers need to be listed in alphabetical order.
Moving x-amz-server-side​-encryption above x-amz-storage-class and using AES256 solved the problem.

Ext Net TimeField in an editable grid

I have a grid panel which display two TimeSpans in two columns and all is well when I load the page but when I go server side the validation on my editors always fail. I don't understand why the store can display the TimeSpans but cannot return it after...
Here my code :
<ext:GridPanel ID="WeekParams" runat="server" >
<Store>
<ext:Store runat="server">
<Reader>
<ext:JsonReader IDProperty="GUID">
<Fields>
<ext:RecordField Name="Day" Type="String" />
<ext:RecordField Name="UATNumber" Type="int" />
<ext:RecordField Name="From" Type="Date" />
<ext:RecordField Name="To" Type="Date" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ColumnID="Day" DataIndex="Day" />
<ext:NumberColumn ColumnID="UATNumber" DataIndex="UATNumber" Format="0" />
<ext:DateColumn ColumnID="From" DataIndex="From" Format="dd/MM/yyyy" >
<Renderer Format="Date" FormatArgs="'HH:mm'" />
<Editor>
<ext:TimeField runat="server" />
</Editor>
</ext:DateColumn>
<ext:DateColumn ColumnID="To" DataIndex="To" Format="dd/MM/yyyy" >
<Renderer Format="Date" FormatArgs="'HH:mm'" />
<Editor>
<ext:TimeField runat="server" />
</Editor>
</ext:DateColumn>
</Columns>
</ColumnModel>
<Plugins>
<ext:EditableGrid runat="server" />
</Plugins>
</ext:GridPanel>
And here the result when I'm going to the server side :

How to add editor to the textarea in my custom component in joomla 2.5?

I have created a custom component in joomla 2.5 where the fields are creating in an xml file.
Here is the code.
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
<field
name="id"
type="hidden"
/>
<field
name="title"
type="text"
label="Title"
description="This is the title"
size="40"
class="inputbox"
default=""
style="width:294px;height:135px;"
/>
<field
name="description"
type="textarea"
label="Description"
description="This is the description"
rows="20"
cols="10"
class="inputbox"
default=""
/>
</fieldset>
</form>
I want to the description text area to be an editor just like in the new article form.
How will I do this?
I solved my problem.
Just change the type of the description field.
<field
name="description"
type="editor"
label="Description"
description="This is the description"
filter="safehtml"
class="inputbox"
default=""
/>

Resources