Custom Node Service

cancel
Showing results for 
Search instead for 
Did you mean: 
lamba
Member II

Custom Node Service

Bonjour,

Quelqu'un SVP, pour m'expliquer comment créer un Node Service personnalisé.

En fait, ce que je veux modifier c'est la méthode public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) qui permet de charger les fils d'un espace lors de sa consultation, n'est ce pas?

Et pour se faire j'ai créé la classe ci-dessous:


public class CustomNodeServiceImpl implements NodeService {
       
        private ServiceRegistry services;
   private NodeService nodeService;
   
   //Constructor
   public CustomNodeServiceImpl(ServiceRegistry services, NodeService nodeService) {
      super();
      this.services = services;
      this.nodeService = nodeService;
   }
   
   //MAJ dynamique du contenu
   public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) throws InvalidNodeRefException{
      …
                //Mon code personnalisé
                …            
   }

   //Getters and Setters
   public void setServices(ServiceRegistry services) {
      this.services = services;
   }
   
   public void setNodeService(NodeService nodeService){
      this.nodeService = nodeService;
       }

      private NodeService getNodeService(){
       if (nodeService == null){
            nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
        }
        return nodeService;
    }

//Unimplemented Methods

   @Override
   public void addAspect(NodeRef nodeRef, QName aspectTypeQName,
         Map<QName, Serializable> aspectProperties)
         throws InvalidNodeRefException, InvalidAspectException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public ChildAssociationRef addChild(NodeRef parentRef, NodeRef childRef,
         QName assocTypeQName, QName qname) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> addChild(Collection<NodeRef> parentRefs,
         NodeRef childRef, QName assocTypeQName, QName qname)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public void addProperties(NodeRef nodeRef,
         Map<QName, Serializable> properties) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public AssociationRef createAssociation(NodeRef sourceRef,
         NodeRef targetRef, QName assocTypeQName)
         throws InvalidNodeRefException, AssociationExistsException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public ChildAssociationRef createNode(NodeRef parentRef,
         QName assocTypeQName, QName assocQName, QName nodeTypeQName)
         throws InvalidNodeRefException, InvalidTypeException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public ChildAssociationRef createNode(NodeRef parentRef,
         QName assocTypeQName, QName assocQName, QName nodeTypeQName,
         Map<QName, Serializable> properties)
         throws InvalidNodeRefException, InvalidTypeException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public StoreRef createStore(String protocol, String identifier)
         throws StoreExistsException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public void deleteNode(NodeRef nodeRef) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void deleteStore(StoreRef storeRef) {
      // TODO Auto-generated method stub
      
   }

   @Override
   public boolean exists(StoreRef storeRef) {
      // TODO Auto-generated method stub
      return false;
   }

   @Override
   public boolean exists(NodeRef nodeRef) {
      // TODO Auto-generated method stub
      return false;
   }

   @Override
   public Set<QName> getAspects(NodeRef nodeRef)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef,
         Set<QName> childNodeTypeQNames) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef,
         QNamePattern typeQNamePattern, QNamePattern qnamePattern)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef,
         QNamePattern typeQNamePattern, QNamePattern qnamePattern,
         boolean preload) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public Collection<ChildAssociationRef> getChildAssocsWithoutParentAssocsOfType(
         NodeRef parent, QName assocTypeQName) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public NodeRef getChildByName(NodeRef nodeRef, QName assocTypeQName,
         String childName) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> getChildrenByName(NodeRef nodeRef,
         QName assocTypeQName, Collection<String> childNames) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public Status getNodeStatus(NodeRef nodeRef) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<ChildAssociationRef> getParentAssocs(NodeRef nodeRef,
         QNamePattern typeQNamePattern, QNamePattern qnamePattern)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public Path getPath(NodeRef nodeRef) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<Path> getPaths(NodeRef nodeRef, boolean primaryOnly)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public ChildAssociationRef getPrimaryParent(NodeRef nodeRef)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public Map<QName, Serializable> getProperties(NodeRef nodeRef)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public Serializable getProperty(NodeRef nodeRef, QName qname)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public NodeRef getRootNode(StoreRef storeRef)
         throws InvalidStoreRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<AssociationRef> getSourceAssocs(NodeRef targetRef,
         QNamePattern qnamePattern) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public NodeRef getStoreArchiveNode(StoreRef storeRef) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<StoreRef> getStores() {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public List<AssociationRef> getTargetAssocs(NodeRef sourceRef,
         QNamePattern qnamePattern) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public QName getType(NodeRef nodeRef) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public boolean hasAspect(NodeRef nodeRef, QName aspectTypeQName)
         throws InvalidNodeRefException, InvalidAspectException {
      // TODO Auto-generated method stub
      return false;
   }

   @Override
   public ChildAssociationRef moveNode(NodeRef nodeToMoveRef,
         NodeRef newParentRef, QName assocTypeQName, QName assocQName)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public void removeAspect(NodeRef nodeRef, QName aspectTypeQName)
         throws InvalidNodeRefException, InvalidAspectException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void removeAssociation(NodeRef sourceRef, NodeRef targetRef,
         QName assocTypeQName) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void removeChild(NodeRef parentRef, NodeRef childRef)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public boolean removeChildAssociation(ChildAssociationRef childAssocRef) {
      // TODO Auto-generated method stub
      return false;
   }

   @Override
   public void removeProperty(NodeRef nodeRef, QName qname)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public boolean removeSeconaryChildAssociation(
         ChildAssociationRef childAssocRef) {
      // TODO Auto-generated method stub
      return false;
   }

   @Override
   public NodeRef restoreNode(NodeRef archivedNodeRef,
         NodeRef destinationParentNodeRef, QName assocTypeQName,
         QName assocQName) {
      // TODO Auto-generated method stub
      return null;
   }

   @Override
   public void setChildAssociationIndex(ChildAssociationRef childAssocRef,
         int index) throws InvalidChildAssociationRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void setProperties(NodeRef nodeRef,
         Map<QName, Serializable> properties) throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void setProperty(NodeRef nodeRef, QName qname, Serializable value)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   @Override
   public void setType(NodeRef nodeRef, QName typeQName)
         throws InvalidNodeRefException {
      // TODO Auto-generated method stub
      
   }

   
}

Merci pour votre aide.
2 Replies
rivarola
Active Member

Re: Custom Node Service

Bonjour,

c'est la méthode public List<ChildAssociationRef> getChildAssocs(NodeRef nodeRef) qui permet de charger les fils d'un espace lors de sa consultation, n'est ce pas?

Ca dépend… Consultation par quel biais : Web Client, Share, FTP, CIFS ?

De toutes manières c'un peu violent de vouloir redéfinir le NodeService juste pour modifier une méthode. Et la modification de cette méthode peut amener pas mal de bugs…
Je conseillerais de plutôt faire la modification un cran au-dessus, dans du code plus "fonctionnel", ou éventuellement dans le FileFolderService (méthodes list ou listFiles).
lamba
Member II

Re: Custom Node Service

Merci Philippe Smiley Happy Tu as raison … Smiley Surprisedops:

Donc, je vais repartir de ta proposition et personnaliser la méthode listFiles(NodeRef contextNodeRef) de la classe FileFolderService et les méthodes en relation (listSimple(NodeRef contextNodeRef, boolean folders, boolean files), toFileInfo(List<NodeRef> nodeRefs), FileInfo toFileInfo(NodeRef nodeRef, boolean addTranslations) …)


Pour la consultation, je m'intéresse dans un premier temps par le Web Client puis Share.


Merci.