From fdf76211620565b39f293a4b385049690fbe874c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Wed, 9 Apr 2008 11:08:57 +0000 Subject: [PATCH] *** empty log message *** --- org.glite.jobid.api-java/nbproject/build-impl.xml | 627 +++++++++++++++++++++ .../nbproject/genfiles.properties | 8 + .../nbproject/private/config.properties | 0 .../nbproject/private/private.properties | 6 + .../nbproject/private/private.xml | 4 + .../nbproject/project.properties | 59 ++ org.glite.jobid.api-java/nbproject/project.xml | 17 + .../org/apache/commons/codec/BinaryDecoder.java | 41 ++ .../org/apache/commons/codec/BinaryEncoder.java | 41 ++ .../src/org/apache/commons/codec/Decoder.java | 54 ++ .../org/apache/commons/codec/DecoderException.java | 37 ++ .../src/org/apache/commons/codec/Encoder.java | 45 ++ .../org/apache/commons/codec/EncoderException.java | 39 ++ .../org/glite/jobid/api_java/CheckedString.java | 59 ++ .../src/org/glite/jobid/api_java/Jobid.java | 253 +++++++++ 15 files changed, 1290 insertions(+) create mode 100755 org.glite.jobid.api-java/nbproject/build-impl.xml create mode 100755 org.glite.jobid.api-java/nbproject/genfiles.properties create mode 100644 org.glite.jobid.api-java/nbproject/private/config.properties create mode 100755 org.glite.jobid.api-java/nbproject/private/private.properties create mode 100644 org.glite.jobid.api-java/nbproject/private/private.xml create mode 100755 org.glite.jobid.api-java/nbproject/project.properties create mode 100755 org.glite.jobid.api-java/nbproject/project.xml create mode 100644 org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryDecoder.java create mode 100644 org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryEncoder.java create mode 100644 org.glite.jobid.api-java/src/org/apache/commons/codec/Decoder.java create mode 100644 org.glite.jobid.api-java/src/org/apache/commons/codec/DecoderException.java create mode 100644 org.glite.jobid.api-java/src/org/apache/commons/codec/Encoder.java create mode 100644 org.glite.jobid.api-java/src/org/apache/commons/codec/EncoderException.java create mode 100755 org.glite.jobid.api-java/src/org/glite/jobid/api_java/CheckedString.java create mode 100755 org.glite.jobid.api-java/src/org/glite/jobid/api_java/Jobid.java diff --git a/org.glite.jobid.api-java/nbproject/build-impl.xml b/org.glite.jobid.api-java/nbproject/build-impl.xml new file mode 100755 index 0000000..d27c53e --- /dev/null +++ b/org.glite.jobid.api-java/nbproject/build-impl.xml @@ -0,0 +1,627 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + diff --git a/org.glite.jobid.api-java/nbproject/genfiles.properties b/org.glite.jobid.api-java/nbproject/genfiles.properties new file mode 100755 index 0000000..bb605a8 --- /dev/null +++ b/org.glite.jobid.api-java/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=dbd878b7 +build.xml.script.CRC32=3fb96f09 +build.xml.stylesheet.CRC32=be360661 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=dbd878b7 +nbproject/build-impl.xml.script.CRC32=02cb42d1 +nbproject/build-impl.xml.stylesheet.CRC32=f1d9da08 diff --git a/org.glite.jobid.api-java/nbproject/private/config.properties b/org.glite.jobid.api-java/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/org.glite.jobid.api-java/nbproject/private/private.properties b/org.glite.jobid.api-java/nbproject/private/private.properties new file mode 100755 index 0000000..b6aa80e --- /dev/null +++ b/org.glite.jobid.api-java/nbproject/private/private.properties @@ -0,0 +1,6 @@ +do.depend=false +do.jar=true +javac.debug=true +javadoc.preview=true +jaxws.endorsed.dir=/home/pavel/netbeans-6.0.1/java1/modules/ext/jaxws21/api +user.properties.file=/home/pavel/.netbeans/6.0/build.properties diff --git a/org.glite.jobid.api-java/nbproject/private/private.xml b/org.glite.jobid.api-java/nbproject/private/private.xml new file mode 100644 index 0000000..c1f155a --- /dev/null +++ b/org.glite.jobid.api-java/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/org.glite.jobid.api-java/nbproject/project.properties b/org.glite.jobid.api-java/nbproject/project.properties new file mode 100755 index 0000000..7505f5c --- /dev/null +++ b/org.glite.jobid.api-java/nbproject/project.properties @@ -0,0 +1,59 @@ +application.title=jobid-api-java +application.vendor=xpiskac +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/jobid-api-java.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=1.5 +javac.target=1.5 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=org.glite.test.Test +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/org.glite.jobid.api-java/nbproject/project.xml b/org.glite.jobid.api-java/nbproject/project.xml new file mode 100755 index 0000000..0db31a3 --- /dev/null +++ b/org.glite.jobid.api-java/nbproject/project.xml @@ -0,0 +1,17 @@ + + + org.netbeans.modules.java.j2seproject + + + jobid-api-java + 1.6.5 + + + + + + + + + + diff --git a/org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryDecoder.java b/org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryDecoder.java new file mode 100644 index 0000000..cdf3589 --- /dev/null +++ b/org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryDecoder.java @@ -0,0 +1,41 @@ +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.codec; + +/** + * Defines common decoding methods for byte array decoders. + * + * @author Apache Software Foundation + * @version $Id$ + */ +public interface BinaryDecoder extends Decoder { + + /** + * Decodes a byte array and returns the results as a byte array. + * + * @param pArray A byte array which has been encoded with the + * appropriate encoder + * + * @return a byte array that contains decoded content + * + * @throws DecoderException A decoder exception is thrown + * if a Decoder encounters a failure condition during + * the decode process. + */ + byte[] decode(byte[] pArray) throws DecoderException; +} + diff --git a/org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryEncoder.java b/org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryEncoder.java new file mode 100644 index 0000000..00f7c3f --- /dev/null +++ b/org.glite.jobid.api-java/src/org/apache/commons/codec/BinaryEncoder.java @@ -0,0 +1,41 @@ +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.codec; + +/** + * Defines common encoding methods for byte array encoders. + * + * @author Apache Software Foundation + * @version $Id$ + */ +public interface BinaryEncoder extends Encoder { + + /** + * Encodes a byte array and return the encoded data + * as a byte array. + * + * @param pArray Data to be encoded + * + * @return A byte array containing the encoded data + * + * @throws EncoderException thrown if the Encoder + * encounters a failure condition during the + * encoding process. + */ + byte[] encode(byte[] pArray) throws EncoderException; +} + diff --git a/org.glite.jobid.api-java/src/org/apache/commons/codec/Decoder.java b/org.glite.jobid.api-java/src/org/apache/commons/codec/Decoder.java new file mode 100644 index 0000000..02ecb5f --- /dev/null +++ b/org.glite.jobid.api-java/src/org/apache/commons/codec/Decoder.java @@ -0,0 +1,54 @@ +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.codec; + +/** + *

Provides the highest level of abstraction for Decoders. + * This is the sister interface of {@link Encoder}. All + * Decoders implement this common generic interface.

+ * + *

Allows a user to pass a generic Object to any Decoder + * implementation in the codec package.

+ * + *

One of the two interfaces at the center of the codec package.

+ * + * @author Apache Software Foundation + * @version $Id$ + */ +public interface Decoder { + + /** + * Decodes an "encoded" Object and returns a "decoded" + * Object. Note that the implementation of this + * interface will try to cast the Object parameter + * to the specific type expected by a particular Decoder + * implementation. If a {@link java.lang.ClassCastException} occurs + * this decode method will throw a DecoderException. + * + * @param pObject an object to "decode" + * + * @return a 'decoded" object + * + * @throws DecoderException a decoder exception can + * be thrown for any number of reasons. Some good + * candidates are that the parameter passed to this + * method is null, a param cannot be cast to the + * appropriate type for a specific encoder. + */ + Object decode(Object pObject) throws DecoderException; +} + diff --git a/org.glite.jobid.api-java/src/org/apache/commons/codec/DecoderException.java b/org.glite.jobid.api-java/src/org/apache/commons/codec/DecoderException.java new file mode 100644 index 0000000..e473c57 --- /dev/null +++ b/org.glite.jobid.api-java/src/org/apache/commons/codec/DecoderException.java @@ -0,0 +1,37 @@ +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.codec; + +/** + * Thrown when a Decoder has encountered a failure condition during a decode. + * + * @author Apache Software Foundation + * @version $Id$ + */ +public class DecoderException extends Exception { + + /** + * Creates a DecoderException + * + * @param pMessage A message with meaning to a human + */ + public DecoderException(String pMessage) { + super(pMessage); + } + +} + diff --git a/org.glite.jobid.api-java/src/org/apache/commons/codec/Encoder.java b/org.glite.jobid.api-java/src/org/apache/commons/codec/Encoder.java new file mode 100644 index 0000000..f9f6c47 --- /dev/null +++ b/org.glite.jobid.api-java/src/org/apache/commons/codec/Encoder.java @@ -0,0 +1,45 @@ +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.codec; + +/** + *

Provides the highest level of abstraction for Encoders. + * This is the sister interface of {@link Decoder}. Every implementation of + * Encoder provides this common generic interface whic allows a user to pass a + * generic Object to any Encoder implementation in the codec package.

+ * + * @author Apache Software Foundation + * @version $Id$ + */ +public interface Encoder { + + /** + * Encodes an "Object" and returns the encoded content + * as an Object. The Objects here may just be byte[] + * or Strings depending on the implementation used. + * + * @param pObject An object ot encode + * + * @return An "encoded" Object + * + * @throws EncoderException an encoder exception is + * thrown if the encoder experiences a failure + * condition during the encoding process. + */ + Object encode(Object pObject) throws EncoderException; +} + diff --git a/org.glite.jobid.api-java/src/org/apache/commons/codec/EncoderException.java b/org.glite.jobid.api-java/src/org/apache/commons/codec/EncoderException.java new file mode 100644 index 0000000..bcdf8a8 --- /dev/null +++ b/org.glite.jobid.api-java/src/org/apache/commons/codec/EncoderException.java @@ -0,0 +1,39 @@ +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.codec; + +/** + * Thrown when there is a failure condition during the encoding process. This + * exception is thrown when an Encoder encounters a encoding specific exception + * such as invalid data, inability to calculate a checksum, characters outside of the + * expected range. + * + * @author Apache Software Foundation + * @version $Id$ + */ +public class EncoderException extends Exception { + + /** + * Creates a new instance of this exception with an useful message. + * + * @param pMessage a useful message relating to the encoder specific error. + */ + public EncoderException(String pMessage) { + super(pMessage); + } +} + diff --git a/org.glite.jobid.api-java/src/org/glite/jobid/api_java/CheckedString.java b/org.glite.jobid.api-java/src/org/glite/jobid/api_java/CheckedString.java new file mode 100755 index 0000000..ec8dedd --- /dev/null +++ b/org.glite.jobid.api-java/src/org/glite/jobid/api_java/CheckedString.java @@ -0,0 +1,59 @@ +package org.glite.jobid.api_java; + +/** + * Class which escapes \ and new line signs in string which is set as parameter + * in constructor + * + * @author Pavel Piskac (173297@mail.muni.cz) + * @version 15. 3. 2008 + */ +public class CheckedString { + + String checkedString; + + /** + * Creates new instance of CheckedString. + * + * @param checkedString string which will be converted + * @throws java.lang.IllegalArgumentException if checkedString is null + */ + public CheckedString(String checkedString) { + if (checkedString == null) { + throw new IllegalArgumentException("checkedString is null"); + } + + checkedString = checkedString.replaceAll("[\\\"]", "\\\\\""); + checkedString = checkedString.replaceAll("[\n]", "\\\\\\\\n"); + this.checkedString = checkedString; + } + + /** + * Gets converted string. + * + * @return converted string + */ + public String getCheckedString() { + return checkedString; + } + + /** + * Sets string which will be converted. + * + * @param checkedString string which will be converted. + */ + public void setCheckedString(String checkedString) { + checkedString = checkedString.replaceAll("[\\\"]", "\\\\\""); + checkedString = checkedString.replaceAll("[\n]", "\\\\\\\\n"); + this.checkedString = checkedString; + } + + /** + * Returns converted string. + * + * @return converted string + */ + public String toString() { + return checkedString; + } + +} diff --git a/org.glite.jobid.api-java/src/org/glite/jobid/api_java/Jobid.java b/org.glite.jobid.api-java/src/org/glite/jobid/api_java/Jobid.java new file mode 100755 index 0000000..9cdedea --- /dev/null +++ b/org.glite.jobid.api-java/src/org/glite/jobid/api_java/Jobid.java @@ -0,0 +1,253 @@ +package org.glite.jobid.api_java; + +import java.math.BigInteger; +import java.net.UnknownHostException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Calendar; +import java.util.Random; +//import org.apache.commons.codec.binary.Base64; +import org.apache.commons.codec.binary.Base64; + +/** + * Class representing jobId + * + * @author Pavel Piskac (173297@mail.muni.cz) + * @version 15. 3. 2008 + */ +public class Jobid { + + String unique; + String bkserver; + int port; + + /** + * Creates new instance of Jobid class. + */ + public Jobid() { + } + + /** + * Creates new instace of JobId with BK server address and port number, unique part + * is generated + * + * @param bkserver BK server address + * @param port BK server port + * @throws java.land.IllegalArgumentException if bkserver is null + * @throws java.lang.IllegalArgumentException if port is lower than 1 or + * bigger than 65535 + */ + + public Jobid(String bkserver, int port) { + if (bkserver == null) { + throw new IllegalArgumentException("Jobid bkserver"); + } + + if (port < 1 || port > 65535) { + throw new IllegalArgumentException("Jobid port"); + } + + if (bkserver.indexOf("https://") == -1) { + throw new IllegalArgumentException("wrong jobid https"); + } + + this.bkserver = bkserver; + this.port = port; + + MessageDigest digest = null; + + try { + String hostname = ""; + try { + hostname = java.net.InetAddress.getLocalHost().getHostName(); + } catch (UnknownHostException ex) { + System.err.println(ex); + } + + digest = java.security.MessageDigest.getInstance("MD5"); + unique = hostname + bkserver + port + Calendar.getInstance().getTimeInMillis() + + new Random().nextInt(999999); + + digest.update(unique.getBytes(),0,unique.length()); + unique = new BigInteger(1,digest.digest()).toString(16); + + } catch (NoSuchAlgorithmException ex) { + System.err.println(ex); + } + + Base64 base64 = new Base64(); + byte[] tmp = base64.decode(unique.getBytes()); + boolean test = false; + while(!test) { + test = true; + for (int i = 0; i < tmp.length; i++) { + if (tmp[i] < 0) { + tmp[i] = (byte)(-1*tmp[i]); + test = false; + } + if (tmp[i] <= 47) { + tmp[i] = (byte)(10+tmp[i]); + test = false; + } + if (tmp[i] <= 64 && tmp[i] >= 58) { + tmp[i] = (byte)(7+tmp[i]); + test = false; + } + if (tmp[i] <= 96 && tmp[i] >= 91) { + tmp[i] = (byte)(6+tmp[i]); + test = false; + } + if (tmp[i] >= 123) { + tmp[i] = (byte)(5-tmp[i]); + test = false; + } + } + } + unique = new String(tmp); + } + + /** + * Creates new instace of Jobid with BK server address, port number and + * unique part as parameters. + * + * @param bkserver BK server address + * @param port BK server port + * @param unique unique part of jobid + * @throws java.lang.IllegalArgumentException if bkserver is null + * @throws java.lang.IllegalArgumentException if port is lower than 1 or + * bigger than 65535 + * @throws java.lang.IllegalArgumentException if unique is null + */ + public Jobid(String bkserver, int port, String unique) { + if (bkserver == null) { + throw new IllegalArgumentException("Jobid bkserver"); + } + + if (port < 1 || port > 65535) { + throw new IllegalArgumentException("Jobid port"); + } + + if (unique == null) { + throw new IllegalArgumentException("Jobid unique"); + } + + this.bkserver = bkserver; + this.port = port; + this.unique = (new CheckedString(unique)).toString(); + } + + /** + * Creates new instace of Jobid from string which represents jobid + * + * @param jobidString jobid string representation + * @throws java.lang.IllegalArgumentException if jobidString is null + */ + public Jobid(String jobidString) { + if (jobidString == null) { + throw new IllegalArgumentException("Jobid jobidString"); + } + + int doubleSlashPosition = jobidString.indexOf("https://"); + if (doubleSlashPosition == -1) { + throw new IllegalArgumentException("wrong jobid https"); + } + + int colonPosition = jobidString.indexOf(":", doubleSlashPosition + 8); + if (colonPosition == -1) { + throw new IllegalArgumentException("wrong jobid colon"); + } + + int dashAfterPort = jobidString.indexOf("/", colonPosition); + String bkserverS = jobidString.substring(0, colonPosition); + Integer portS = new Integer(jobidString.substring(colonPosition+1, + dashAfterPort)); + String uniqueS = jobidString.substring(dashAfterPort+1, jobidString.length()); + + this.bkserver = bkserverS; + this.port = portS; + this.unique = (new CheckedString(uniqueS)).toString(); + } + + /** + * Returns BK server address + * + * @return bkserver BK server address + */ + public String getBkserver() { + return bkserver; + } + + /** + * Sets BK server address + * + * @param bkserver BK server address + * @throws java.lang.IllegalArgumentException if bkserver is null + */ + public void setBkserver(String bkserver) { + + if (bkserver == null) { + throw new IllegalArgumentException("Jobid bkserver"); + } + + this.bkserver = bkserver; + } + + /** + * Returns unique part of jobId + * + * @return unique part of jobId + */ + public String getUnique() { + return unique; + } + + /** + * Sets unique part of jobId + * + * @param unique + * @throws java.lang.IllegalArgumentException if unique is null + */ + public void setUnique(String unique) { + + if (unique == null) { + throw new IllegalArgumentException("Jobid unique"); + } + + this.unique = (new CheckedString(unique)).toString(); + } + + /** + * Returns port number + * + * @return port number + */ + public int getPort() { + return port; + } + + /** + * Sets port number + * + * @param port number + * @throws java.lang.IllegalArgumentException if port is lower than 0 or + * bigger than 65535 + */ + public void setPort(int port) { + + if (port <= 0 || port >= 65536) { + throw new IllegalArgumentException("Jobid port"); + } + + this.port = port; + } + + /** + * Returns Jobid string representation in format bkserver:port/unique + * + * @return Jobid string representation in format bkserver:port/unique + */ + @Override + public String toString() { + return bkserver + ":" + port + "/" + unique; + } +} -- 1.8.2.3