class DocumentServiceImpl extends RemoteServiceServlet implements DocumentService {

	@Override
	public GUIAttribute[] getAttributes(long templateId) throws ServerException {
		ServiceUtil.validateSession(getThreadLocalRequest());

		TemplateDAO templateDao = (TemplateDAO) Context.get().getBean(TemplateDAO.class);
		Template template = templateDao.findById(templateId);
		templateDao.initialize(template);

		GUIAttribute[] attributes = prepareGUIAttributes(template, null);
		Arrays.sort(attributes, new Comparator<GUIAttribute>() {

			@Override
			public int compare(GUIAttribute o1, GUIAttribute o2) {
				return Integer.valueOf(o1.getPosition()).compareTo(Integer.valueOf(o2.getPosition()));
			}
		});

		return attributes;
	}

}