diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-05-07 17:33:13 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-05-08 16:37:39 +0200 |
| commit | a1f0ecbb6a2bea6aa214322c412af2f3c5ce124b (patch) | |
| tree | 4d74229b6dd9cfd7ce054e06bf740b9a63a578d6 /src/main/java/com/c2kernel/lookup/EntityPath.java | |
| parent | 6dfa1bbe05a712174e937af89d5223e98d9d7d06 (diff) | |
Agent now extends Item, so they can have workflows. All traces of the
old 'Entity' superclasses should be removed, including proxies and
paths. Very large change, breaks API compatibility with CRISTAL 2.x.
Fixes #135
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/EntityPath.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lookup/EntityPath.java | 175 |
1 files changed, 0 insertions, 175 deletions
diff --git a/src/main/java/com/c2kernel/lookup/EntityPath.java b/src/main/java/com/c2kernel/lookup/EntityPath.java deleted file mode 100644 index 4f9b771..0000000 --- a/src/main/java/com/c2kernel/lookup/EntityPath.java +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************
- * EntityPath.java
- *
- * $Revision: 1.14 $
- * $Date: 2006/03/03 13:52:21 $
- *
- * Copyright (C) 2001 CERN - European Organization for Nuclear Research
- * All rights reserved.
- **************************************************************************/
-
-package com.c2kernel.lookup;
-
-import java.util.ArrayList;
-
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.process.Gateway;
-import com.novell.ldap.LDAPAttribute;
-import com.novell.ldap.LDAPAttributeSet;
-
-
-/**
-* Extends Path to enforce SystemKey structure and support int form
-*
-* @version $Revision: 1.14 $ $Date: 2006/03/03 13:52:21 $
-* @author $Author: abranson $
-**/
-public class EntityPath extends Path
-{
- // no of components in a syskey
- public static final int elementNo = 3;
- // no of digits in a syskey component
- public static final int elementLen = 3;
- // maximum possible int syskey
- public static final int maxSysKey = (int)Math.pow(10, elementNo*elementLen)-1;
- protected static String mTypeRoot;
- /*
- * From syskey int
- * Note no EntityPath constructors allow setting of CONTEXT or ENTITY:
- * The object decides that for itself from the number of components
- */
-
- public EntityPath(int syskey) throws InvalidEntityPathException {
- super();
- setSysKey(syskey);
- }
-
- /*
- */
- public EntityPath()
- {
- super();
- }
-
-
- /*
- */
- public EntityPath(String[] path) throws InvalidEntityPathException
- {
- super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath()
- checkSysPath();
- }
-
- /*
- */
- public EntityPath(String path) throws InvalidEntityPathException
- {
- super(path, Path.CONTEXT);
- checkSysPath();
- }
-
- /*
- */
- public EntityPath(EntityPath parent, String child) throws InvalidEntityPathException {
- super(parent, child);
- checkSysPath();
- }
-
- // EntityPaths root in /entity
- @Override
- public String getRoot() {
- return "entity";
- }
-
- @Override
- public EntityPath getEntity() throws ObjectNotFoundException {
- return this;
- }
-
- public byte[] getOID() {
- if (mSysKey == Path.INVALID) return null;
- return String.valueOf(mSysKey).getBytes();
- }
-
- /*************************************************************************/
-
- /** Returns int form of syskey (if possible)
- */
- @Override
- public int getSysKey() {
- if (mSysKey == Path.INVALID && mType == Path.ENTITY)
- try {
- if (mPath.length != elementNo)
- throw new InvalidEntityPathException("Incorrect number of components for a system key");
- mSysKey = 0;
- for (String keypart : mPath) {
- if (keypart.length()!=elementLen+1)
- throw new InvalidEntityPathException("Component '"+keypart+"' is not the correct size for a system key");
- for(int j=1; j<elementLen+1; j++) // skip the 'd' prefix
- {
- char c = keypart.charAt(j);
- if((c >= '0') && (c <='9'))
- mSysKey = mSysKey*10 + c - '0';
- else
- throw new InvalidEntityPathException("Component '"+keypart+"' contained a non-numeric char (excluding first char 'd').");
-
- }
- }
- } catch (InvalidEntityPathException ex) {
- mSysKey = Path.INVALID;
- }
- return mSysKey;
- }
-
- /** Sets path from int syskey
- */
- public void setSysKey(int sysKey) throws InvalidEntityPathException
- {
- if (sysKey < 0 || sysKey > maxSysKey)
- throw new InvalidEntityPathException("System key "+sysKey+" out of range");
- String stringPath = Integer.toString(sysKey);
- ArrayList<String> newKey = new ArrayList<String>();
- for (int i=0; i<elementNo; i++) {
- StringBuffer nextComponent = new StringBuffer("d");
- int start = stringPath.length()-elementLen;
- if (start < 0) {
- nextComponent.append("000000".substring(0,Math.abs(start))).append(stringPath);
- stringPath = "";
- }
- else {
- nextComponent.append(stringPath.substring(start));
- stringPath = stringPath.substring(0, start);
- }
- newKey.add(0, nextComponent.toString());
- }
-
- mPath = (newKey.toArray(mPath));
- mSysKey = sysKey;
- mStringPath = null;
- mDN = null;
- mType = Path.ENTITY;
- checkSysPath();
- }
-
- public void checkSysPath() throws InvalidEntityPathException {
- if (mPath.length > elementNo)
- throw new InvalidEntityPathException("EntityPath cannot have more than "+elementNo+" components: "+toString());
- if (mPath.length == elementNo)
- mType = Path.ENTITY;
- else
- mType = Path.CONTEXT;
- }
-
- @Override
- public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated {
- LDAPAttributeSet attrs = new LDAPAttributeSet();
- attrs.add(new LDAPAttribute("objectclass","cristalentity"));
- attrs.add(new LDAPAttribute("intsyskey",Integer.toString(mSysKey)));
- attrs.add(new LDAPAttribute("cn", getPath()[getPath().length-1]));
- if (mIOR != null)
- attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(mIOR)));
- return attrs;
- }
-}
-
|
