I thought having my server resource code here may help, so :

package com.ar.restlet.resources;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.ServerResource;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.ar.xu.business.CommunicationService;
import com.ar.xu.model.Communication;

public class StatusServerResource extends ServerResource implements 
ApplicationContextAware{
        private static Log                      LOG                             
= LogFactory.getLog(LogsServerResource.class);
        private ApplicationContext ctx = null;
        
        @Override
        public void setApplicationContext(ApplicationContext arg0)
                        throws BeansException {
                this.ctx = arg0;
        }

        @Override
        public Representation get() {
                String officeIdStr  = 
(String)getRequest().getAttributes().get("officeId");
                int officeId = Integer.parseInt(officeIdStr);
                String candidateListIdStr  = 
(String)getRequest().getAttributes().get("candidateListId");
                int communicationId = Integer.parseInt(candidateListIdStr);
                CommunicationService communicationService = 
(CommunicationService) ctx.getBean("communicationService"); 
                Communication communication = 
communicationService.getCommunicationById(officeId, communicationId);
                if (communication==null){
                        LOG.error("Communication with id " + communicationId + 
" in office " + officeId + " doesn't exist");
                        return new StringRepresentation("Invalid id");
                }
                return new 
StringRepresentation(communication.getStatus().getId().getStatus());
        }

}

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2931261

Reply via email to