ARESTC

General

In order to use the library in practice, it needs two configuration files: the communication configuration file and the services configuration file.

Communications Configuration

For the communications configuration file things are simple. All that needs to be configured is special servers that require authentication to access. An example would be:

<?xml version="1.0" encoding="UTF-8"?>
<client xmlns="checkerSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ng.lu/checkerSchema checker.xsd ">
	<!-- <method>HEAD<method> -->
	<preemptive>false</preemptive>
	<hosts>
		<host>
			<preemptive>false</preemptive>
			<username>admin</username>
			<password>admin</password>
			<server>localhost</server>
			<port>80</port>
		</host>
	</hosts>
	<proxy>
		<username>admin</username>
		<password>admin</password>
		<server>localhost</server>
		<port>80</port>
	</proxy>
</client>
			

The configuration factory expects at least on host and a proxy but it will not use them unless the server being accessed requires some authentication

Services configuration

For the configuration of the services you need to be more careful. Services registered here are the only ones to be available so make sure their names are the ones you'll use inside your code. The context path is the path (apart from the server and the port) that the service listence's to. The context path may contain parameters in the form {parametername} but it cannot contain nested parameters. You pass these parameters normally to the request as you would any other type of parameter. In order for the proper handling of url parameters they must be declared in the parameters section of the service with value-type=url. Special services may need authentication. To declare that use the authentication section. If you wish to use user credentials that you will provide to the request every time you access the service, use a content such as 'user' but if you wish to provide in this configuration admin credentials to be used in the services you need to use a content such as 'admin'. An example of the file would be:

<?xml version="1.0" encoding="UTF-8"?>
<conf>
	<admin username="admin" password="admin" />
	<server url="http://localhost" port="8080" />
	<services>
		<service name="login" context-path="alfresco/service/api/login"
			method="GET" returns="xml">
			<params>
				<param name="u" value-type="query" />
				<param name="pw" value-type="query" />
			</params>
			<authentication required="false"></authentication>
		</service>
		<service name="nodeRetrieve"
			context-path="alfresco/service/api/node/{store_type}/{store_id}/{id}/permissions"
			method="GET" returns="xml">
			<params>
				<param name="store_type" value-type="url" />
				<param name="store_id" value-type="url" />
				<param name="id" value-type="url" />
			</params>
			<authentication required="true">admin</authentication>
		</service>
		<service name="nodeDelete"
			context-path="alfresco/service/api/node/{store_type}/{store_id}/{id}/descendants"
			method="DELETE" returns="nobody">
			<params>
				<param name="store_type" value-type="url" />
				<param name="store_id" value-type="url" />
				<param name="id" value-type="url" />
			</params>
			<authentication required="true">admin</authentication>
		</service>

		<service name="nodeCreate"
			context-path="alfresco/service/api/node/{store_type}/{store_id}/{id}/children"
			method="POST" returns="atom" content-type="application/atom+xml;type=entry">
			<params>
				<param name="store_type" value-type="url" />
				<param name="store_id" value-type="url" />
				<param name="id" value-type="url" />
			</params>
			<authentication required="true">admin</authentication>
		</service>
		<service name="uploadFile"
			context-path="alfresco/service/api/node/{store_type}/{store_id}/{id}/content"
			method="PUT" returns="xml" content-type="application/binary">
			<params>
				<param name="store_type" value-type="url" />
				<param name="store_id" value-type="url" />
				<param name="id" value-type="url" />
			</params>
			<authentication required="true">admin</authentication>
		</service>
		<service name="downloadFile"
			context-path="alfresco/service/api/node/{store_type}/{store_id}/{id}/file"
			method="GET" returns="stream" content-type="application/binary">
			<params>
				<param name="store_type" value-type="url" />
				<param name="store_id" value-type="url" />
				<param name="id" value-type="url" />
			</params>
			<authentication required="true">admin</authentication>
		</service>
		<service name="uploadMultipart"
			context-path="alfresco/service/api/node/{store_type}/{store_id}/{id}/filemulti"
			method="POST" returns="xml" content-type="multipart/form-data">
			<params>
				<param name="store_type" value-type="url" />
				<param name="store_id" value-type="url" />
				<param name="id" value-type="url" />
			</params>
			<authentication required="true">admin</authentication>
		</service>
	</services>
</conf>
				

File names and location

The default name for the communications xml is httpconfiguration.xml and the services configuration is services.xml. They must both be in the classh path in order for the configuration factories to find and retrieve the configuations. Using files on other locations is a feature to come in the next release