03-09-2011 04:47 PM
 
AuthenticationUtils.startSession("admin", "MYPASSWORD");
FacesContext fc = FacesContext.getCurrentInstance();
ServiceRegistry services = Repository.getServiceRegistry(fc);
DictionaryService dd = services.getDictionaryService();
List<PropertyDefinition> res = new ArrayList<PropertyDefinition>();
      
QName typeQName = Repository.resolveToQName("sc:sc_article");
      
System.out.println("Type QNAME:" + typeQName);
   
   if (typeQName != null) {
          
      TypeDefinition typeDef = dd.getType(typeQName);
         System.out.println("Type Def:" + typeDef);
         if (typeDef != null) {
            Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> props = typeDef.getProperties();
            for (QName prop : props.keySet()) {
               System.out.println("Prop Name:" + prop);
               PropertyDefinition propDef = (PropertyDefinition) props.get(prop);
               System.out.println("Prop DEF:" + propDef);
               res.add(propDef);
            }
         }
      }
Exception in thread "main" java.lang.IllegalArgumentException: FacesContext must not be null
   at org.springframework.util.Assert.notNull(Assert.java:112)
   at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:50)
   at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
   at org.alfresco.web.bean.repository.Repository.getServiceRegistry(Repository.java:584)
   at ritornaProprieta.main(ritornaProprieta.java:25)
 
					
				
		
03-10-2011 02:49 AM
03-10-2011 03:55 AM
08-29-2011 09:11 AM
package genericmodel.main;
import javax.faces.context.FacesContext;
import org.alfresco.service.ServiceRegistry;
public class GetServiceRegistry {
   private ServiceRegistry serviceRegistry;
   private FacesContext context= context = FacesContext.getCurrentInstance();
   
   public GetServiceRegistry(){
      serviceRegistry=org.alfresco.web.bean.repository.Repository.getServiceRegistry(context);
   }
   
   public ServiceRegistry getServiceRegistry() {
      return serviceRegistry;
   }
   
   public void setServiceRegistry(ServiceRegistry serviceRegistry) {
      this.serviceRegistry = serviceRegistry;
   }
   public FacesContext getContext() {
      return context;
   }
   public void setContext(FacesContext context) {
      this.context = context;
   }
}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
   <bean id="getServiceRegistry" class="genericmodel.main.GetServiceRegistry">
      <property name="serviceRegistry">
         <ref bean="ServiceRegistry"/>
      </property>
   </bean>
   
</beans> 
					
				
				
			
		
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.