03-12-2009 01:01 PM
for each (field in formdata.fields)
{
if (field.name == "oldpassword")
{
oldpass = field.value;
}
else if (field.name == "newpassword1")
{
newpass1 = field.value;
}
else if (field.name == "newpassword2")
{
newpass2 = field.value;
}
else if (field.name == "username")
{
username = field.value;
}
}
// ensure we have valid values and that the new passwords match
if (newpass1.equals(newpass2))
{
// perform the REST API to change the user password
var params = new Array(2);
params["oldpw"] = oldpass;
params["newpw"] = newpass1;
var connector = remote.connect("alfresco");
var user = people.getPerson(username);
var result = connector.post(
"/api/person/changepassword/" + stringUtils.urlEncode(user.name),
jsonUtils.toJSONString(params),
"application/json");
var repoJSON = eval('(' + result + ')');
//test.content = test.content + "\n repoJSON" + repoJSON ;
if (repoJSON.success !== undefined)
{
model.success = repoJSON.success;
}
else
{
model.success = false;
model.errormsg = repoJSON.message;
}
}
else
{
model.success = false;
}
03-04-2010 03:04 AM
One very useful root script object available for Alfresco Share or SURF extension is the “remote” object which is a configurable object that enables webscript controller ( the JavaScript template ) to invoke other REST-style services including both external services ( such as Yahoo Weather service) and internal services ( such as Alfresco CMIS services).
However the remote root script object is not enabled as default and you won’t be able to use it for repository side webscripts. To enable and use it in your repository side webscripts, you only need to make change to the following two configuration XML files.
1) WEB-INF\classes\alfresco\web-scripts-application-context.xml
You need to add a new entry which references to the remote object to the scriptObjects property of the webscripts.container bean.
<bean id="webscripts.container"
class="org.alfresco.repo.web.scripts.RepositoryContainer"
parent="webscripts.abstractcontainer">
<property name="name"><value>Repository</value></property>
<property name="scriptObjects">
<map merge="true">
<entry key="paging">
<ref bean="webscripts.js.paging" />
</entry>
<!– add remote entry –>
<entry key="remote" value-ref="webscripts.script.remote" />
</map>
</property>
……
</bean>
2) WEB-INF\classes\alfresco\webscript-framework-config.xml
To invoke external services, we need to add the http endpoint
……
<endpoint>
<id>http</id>
<name>HTTP access</name>
<description>Generic HTTP connector</description>
<connector-id>http</connector-id>
<endpoint-url></endpoint-url>
<identity>none</identity>
<unsecure>true</unsecure>
</endpoint>
……
Once we make the changes, we need to restart Alfresco server and we should be able to use the remote object in our web scripts.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.