KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > content > explorer > component > model > JCRNodeDescriptor


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.content.explorer.component.model;
6
7 import java.util.ArrayList JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10 import javax.jcr.Node;
11 import org.exoplatform.portlets.content.MimeTypeManager;
12 /**
13  * @email: tuan08@users.sourceforge.net
14  * @version: $Id: NodeDescriptor.java,v 1.2 2004/11/02 20:02:54 geaz Exp $
15  */

16 public class JCRNodeDescriptor implements NodeDescriptor {
17   private String JavaDoc uri_ ;
18   private String JavaDoc parentUri_ ;
19   private String JavaDoc name_ ;
20   private String JavaDoc owner_ ;
21   private MimeTypeManager.MimeType mimeType_ ;
22   private Date JavaDoc createdDate_ ;
23   private Date JavaDoc modifiedDate_ ;
24   private boolean isVersioning_ ;
25   private boolean isLeafNode_ ;
26   private List JavaDoc children_ ;
27   private String JavaDoc cacheContent_ ;
28   
29   public JCRNodeDescriptor(String JavaDoc parentURI, Node node) {
30     name_ = node.getName();
31     parentUri_ = parentURI ;
32     uri_ = node.getPath() ;
33     String JavaDoc type = node.getPrimaryNodeType().getName() ;
34     if ("/".equals(uri_) || "nt:folder".equals(type)) {
35       isLeafNode_ = false ;
36       mimeType_ = MimeTypeManager.getInstance().getDirectoryType() ;
37     } else {
38       isLeafNode_ = true ;
39       mimeType_ = MimeTypeManager.getInstance().getMimeTypeByOfFile(name_) ;
40     }
41   }
42
43   public String JavaDoc getUri() { return uri_ ; }
44   public String JavaDoc getParentUri() { return parentUri_ ; }
45   public String JavaDoc getName() { return name_ ; }
46   public String JavaDoc getOwner() { return "NA" ; }
47   public Date JavaDoc getModifiedDate() { return null ; }
48   public Date JavaDoc getCreatedDate() { return null ; }
49   public boolean isVersioning() { return isVersioning_ ; }
50   public boolean isLeafNode() { return isLeafNode_ ; }
51   public String JavaDoc getNodeType() { return mimeType_.getMimeType() ;}
52   public String JavaDoc getIcon() { return mimeType_.getIcon() ;}
53   
54   public List JavaDoc getChildren() {
55     if(children_ == null) children_ = new ArrayList JavaDoc() ;
56     return children_ ;
57   }
58   
59   public void setChildren(List JavaDoc list) {
60     children_ = list ;
61   }
62   
63   public String JavaDoc getCacheContent() { return cacheContent_ ; }
64   public void setCacheContent(String JavaDoc s) { cacheContent_ = s ; }
65 }
Popular Tags