Framework/Another Lore2009. 4. 25. 05:21

There are three types of read access which a session may have with respect to a particular node(or property), depending on that session's permissions: direct access, traversal access and search access.


Direct Access

Direct access to an item means being able to retrieve it by absolute and relative path and, in the case of nodes, by identifier. Let p(x) return the normalized absolute path of item x,  id(x) return the identifier of node x.

For any session S and node N, the statements below must be either all true or all false. If they are all true then S has direct access to N, if they are all false then S does not have direct access to N:

- S.getNodeByPath(p(N)) returns N.
- S.getNodeByUUID(id(x)) return N.
- S.existByPath(p(N)) returns true.
- If N is the root node of the workspace then S.getRootNode() returns N.

For any node N and property P, the statements below must be either all true or all false. p(P) eturn the identifier of property P. If they are all true then N has direct access to P, if they are all false then N does not have direct access to P:

- N.getProperty(p(P)) returns P.
- N.hasProperties(p(P)) return true.
- N.getString(p(P)) return P.getString()

Traversal Access

Traversal access to an node N means that it is returned when iterating over the link of a node.

For any given session S and node N, the statements below must be either both true or both false. If they are both true then S has traversal access to N, if they are both false then S does not have traversal access to N:

- S has access to M where M is the parent of N, and N appears among the node in the iterator returned by either M.getChildNode(int maxDepth) or  M.getChildNode() or M.getChildNode(Page page) or getNodes(LinkType.Child, Page.ALL)
- If N is the parent node of a node M then M.getParent() returns N.
- If N has property thern Node.hasProperties() returns true.
- If N is the member node of a node M, and N apperas among the node in the iterator returned by either M.getMemberNode(Page.ALL) or getNodes(LinkType.Member, Page.ALL)
- If N has link of a node M, and N apperas among the node in the iterator<Link> returned by either M.getLinks(Page.ALL) or M.getLinks(linkType, page). Link consist of fromNode and toNode with linkType

Export
Exporting a subgraph within a workspace can be done with
Exporter.exp()


Search Access

Search a subgraph within a workspace can be done with
Node.searchNode(String searchText)
currently the search engine is Lucene

Effect of Access Denial on Read

If a repository restricts the read access of a session, then the nodes and properties to which that session does not have read access must appear not to exist. For example, the iterator returned on N.getNodes will not include subnodes of N to which the session in question does not have read access. In other words, lack of read access to an item blocks access to both information about the content of that item and information about the existence of that item.

Node Information
This method provides access to the current Session.
    Session node.getSession()
These methods provide information about the location of an node within the workspace hierarchy:
    String node.getPath()
returns the name of the node
    String node.getName()
returns the ancestor of the node that is at the specified depth below the root node.
    Node node.getParent()
returns the name of the node
    String node.getExplain()
returns the more information of the node
    NodeBean node.getBean()
This method is used to determine the repository-level semantic identity of two node.
    boolean node.isSame(Node n2) or boolean node.isSameVersion(Node n2)
The method returns the identifier of a node.
    String Node.getIdentifier()

Iterators

Methods that return a set of Node or Property objects do so using a GenericIterator, subclasses of Iterator.


Reading Properties

The generic value getter for single value properties is
    Value Property.getValue().
returns one of the constants of Property.Type indicating the property type of the Value.
    Property.Type Value.getType()
The length of a value in a single-value property. is returned by
    long Property.getLength()

Property Type Conversion
When the value of a property is read or written using a type different from that declared for the property, the repository attempts a type conversion according to the [not defined] rules. Note that even in cases where the type conversion is
defined in terms of standard JDK type conversion method, failure of conversion must only ever cause a  ValueFormatException to be thrown and never any exception defined in the JDK API.

Namespace Mapping


'Framework > Another Lore' 카테고리의 다른 글

AL : Workspace  (0) 2009.04.28
AL : Property Type Conversion  (0) 2009.04.26
AL : Link  (0) 2009.04.24
AL : Observation  (0) 2009.04.24
AL : Versioning Model  (0) 2009.04.24
Posted by bleujin
Framework/Another Lore2009. 4. 24. 09:45


Link는 다른 ORMapping이나 JSR283 API에는 나오지 않는 좀 독특한 API이다.

Link는 Node와 Node의 관계이다. Node는
   Node session.createNode(Node parent, NodeType nodetype, String name)
parentNode를 지정하고 create되는데(맨 처음 만들게 되는 root 노드는 NO_PARENTNODE 라는 Node를 ParentNode로 설정한다.) 이때 parentNode와 createdNode 사이에는 자동적으로 Parent-Child Link가 생성된다.

이 자동적으로 생성된 Link를 통해
  Iterator<Node> Node.getChildNode(Page page) API가 동작한다.

그리고 Link는 또한 User가 수동적으로 create시킬수 있다. 가장 대표적인 경우가 MemberType인데

Node boardNode = createNode(root, boardType, "general_board")
Node arcileNode = createNode(boardNode, articleType, sequence.nextVal("board");
articleNode.setSubject("제목") ;
articleNode.setContent("내용") ;

와 같은 코드를 통해 게시판을 구현한다고 했을때.

boardNode와 articleNode는 parent-child 관계이다. 그러나 parent-child 관계는 orderable 하지 않기 때문에 순서가 보장되어야 하는 게시판에는 적당하지 않다.

그럴경우
boardNode.addLink(articleNode, new LinkType("belongTo"), Position.After) 와 같이 명시적으로 새로운 관계를 지정할 수 있다. boardNode는 articleNode와 belongTo 관계를 가지며 관계의 맨끝에 넣으라는 API이다. 그러나 일반적으로 관계는 targNode의 nodeType을 제한하지 않는다. 그래서  Iterator<Node> parentNode.getNodes(new LinkType("belongTo")) 라고 했을때 모두 articleTtype이 나올것이라고 확신할수 없다.

그러나 이런경우라면 굳이 새로운 linkType을 만들 필요는 없다. 이미 이러한 역할을 하는 관계가 있는데 memberType이다.
boardNodeType.setMemberType(articleNodeType) 이라고 지정하면 boardNodeType의 instance인 boardNode는 articleNodeType 혹은 articleNodeType을 상속받은 Node만 member로 지정할 수 있다.

memberLinkType은 order를 지정할 수 있고
   boardNode.getMemberNode(Page page) 와 같이 억세스 할 수 있다.

이미 정의된 parent-child 관계와 member 관계 말고도 원할 경우 어떠한 Link 관계도 맺을 수 있다. 이를테면 boardNode는 특정 articleNode와 mostPopular 관계를 맺어 이를 반복해서 노출시킬 수 있다. 또는 특정 Node끼리 same link를 맺을 수도 있다.

Link의 존재로 인해 Node들을 더 유연하게 참조할 수 있게 된다.

Direction
Link는 FromNode->ToNode의 단방향이다.


[Example Code]

  Node r1 = createNode(root, robotType, "1") ;
  Node r2 = createNode(root, robotType, "2") ;
  Node r3 = createNode(root, robotType, "3") ;
  Node r4 = createNode(root, robotType, "4") ;
  Node r5 = createNode(root, robotType, "5") ;
  
  robotType.setMemberType(robotType) ;
  r1.addLink(r2, LinkTypeImpl.MEMBER, Position.AFTER) ;
  r1.addLink(r3, LinkTypeImpl.MEMBER, Position.AFTER) ;
  r1.addLink(r4, LinkTypeImpl.MEMBER, Position.AFTER) ;
  r1.addLink(r5, LinkTypeImpl.AGREE, Position.AFTER) ;
  
  session.save() ;
  
  assertEquals(3, r1.getLinks(LinkTypeImpl.MEMBER, Page.ALL).size()) ;

  assertEquals(2, r1.getLinks(LinkTypeImpl.MEMBER, Page.create(2, 1)).size()) ;
  assertEquals(1, r1.getLinks(LinkTypeImpl.MEMBER, Page.create(2, 2)).size()) ;
  assertEquals(0, r1.getLinks(LinkTypeImpl.MEMBER, Page.create(2, 3)).size()) ;

  assertEquals(2, r1.getLinks(Page.create(2, 1)).size()) ;
  assertEquals(2, r1.getLinks(Page.create(2, 2)).size()) ;
  assertEquals(0, r1.getLinks(Page.create(2, 3)).size()) ;


<about Link interface in Node >
 public GenericIterator<Node> getChildNode(int maxDepth) throws RepositoryException ;
 public GenericIterator<Node> getChildNode(Page page) throws RepositoryException;
 public GenericIterator<Node> getChildNode() throws RepositoryException;
 public GenericIterator<Node> getMemberNode(Page page) throws RepositoryException ;
 public GenericIterator<Node> getNodes(LinkType type, Page page) throws RepositoryException;

 public GenericIterator<Link> getLinks(Page page) throws RepositoryException;
 public GenericIterator<Link> getLinks(LinkType linkType, Page page) throws RepositoryException  ;



<interface Link extends IConstant, Publishable>

 public void setMode(Mode mode) ;
 public Mode getMode() ;
 public Node getFrom() throws RepositoryException ;
 public LinkType getLinkType();
 public Node getTo() throws RepositoryException ;
 public String getFromUUID() ;
 public String getToUUID() ;
 public Position getPosition() ;







'Framework > Another Lore' 카테고리의 다른 글

AL : Property Type Conversion  (0) 2009.04.26
AL : Reading  (0) 2009.04.25
AL : Observation  (0) 2009.04.24
AL : Versioning Model  (0) 2009.04.24
AL : Workspace  (0) 2009.04.23
Posted by bleujin
Framework/Another Lore2009. 4. 24. 08:42



A repository may support observation, which enables an application to receive notification of persistent changes to a workspace.

Event Model
A persisted change to a workspace is represented by a set of one or more events. Each event reports a single simple change to the structure of the persistent workspace in terms of an item added, changed or removed. The six
standard event types are:

NODE_CREATED, NODE_REMOVED
PROPERTY_CREATED, PROPERTY_CHANGED
LINK_CREATED, LINK_REMOVED


Scope of Event Reporting


The scope of event reporting is implementation-dependent. An implementation should make a best-effort attempt to report all events, but may exclude events if reporting them would be impractical given implementation or resource limitations. For example, on an import, create or remove of a subgraph containing a large number of items, an implementation may choose to report only events associated with the root node of the affected graph and not those for every subitem in the structure.

Event implement
NodeEvent, PropertyEvent, LinkEvent


Event Information
Each Event is associated with a path, an identifier and an information map, the interpretation of which depend upon the event type.

The event path is retrieved through
  NodeEvent.getNode()
  PropertyEvent.getProperty() ;
  LinkEvent.getLink() ;

User ID
An Event also records the identity of the Session that caused it. String Event.getUserID()
String Event.getUserID()
returns the user ID of the Session, which is the same value that is returned by Session.getUserID()


Event Date

An event also records the time of the change that caused it. This acquired through
long Event.getDate()
The date is represented as a millisecond value that is an offset from the epoch January 1, 1970 00:00:00.000 GMT (Gregorian). The granularity of the returned value is implementation-dependent.


Event Ordering

In both asynchronous and journaled observation the order of events within a bundle and the order of event bundles is not guaranteed to correspond to the order of the operations that produced them.

Observation Manager

Registration of event listeners is done through the ObservationManager object acquired from the Workspace through
ObservationManager Workspace.getObservationManager().


Exceptions

The method EventListener.onEvent does not specify a throws clause. This does not prevent a listener from throwing a RuntimeException, although any listener that does should be considered to be in error.


[Example Code]
  EventStackingListener listener = new EventStackingListener();
  workspace.getObservationManager().addEventListener(listener) ;
  
  Node node = session.createNode(root, newType, "abc") ;
  
  assertEquals(3, listener.getCount())  ;
  
  NodeEvent event = (NodeEvent)listener.popEvent();
  assertEquals(EventType.NODE_CREATED, event.getType()) ;
  assertEquals(node, event.getNode()) ;
  assertEquals(EventType.LINK_CREATED, listener.popEvent().getType()) ;
  assertEquals(EventType.PROPERTY_CREATED, listener.popEvent().getType()) ; // because of default value
  
  node.setProperty(IDString.propId("firstname"), "bleujin") ;
  assertEquals(EventType.PROPERTY_CHANGED, listener.popEvent().getEventType()) ;


<interface Event>
 public EventType getType() 
 public String getUserID() 
 public long getDate()


<interface EventListener>
 public void onEvent(Event event);
 public boolean isDealWith(Event event);

'Framework > Another Lore' 카테고리의 다른 글

AL : Reading  (0) 2009.04.25
AL : Link  (0) 2009.04.24
AL : Versioning Model  (0) 2009.04.24
AL : Workspace  (0) 2009.04.23
AL : Node  (0) 2009.04.23
Posted by bleujin