link start!
This commit is contained in:
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
+1
@@ -0,0 +1 @@
|
||||
DA§ÓfÉ;ò&smßé÷î¼üàÄ3UÊ)ºHœÏÌW²-Ý^ä„à aÙNѨH'9Çö±<2¦¦·(ùΓ"iÂ0$„
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarEntry;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class FastTarStream {
|
||||
private boolean debug;
|
||||
private boolean hasHitEOF;
|
||||
private TarEntry currEntry;
|
||||
private InputStream inStream;
|
||||
private int recordSize;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public TarEntry getNextEntry() throws IOException {
|
||||
int n;
|
||||
int n2;
|
||||
if (this.hasHitEOF) {
|
||||
return null;
|
||||
}
|
||||
if (this.currEntry != null && this.currEntry.getSize() > 0L && (n2 = ((int)this.currEntry.getSize() + (this.recordSize - 1)) / this.recordSize) > 0) {
|
||||
this.inStream.skip(n2 * this.recordSize);
|
||||
}
|
||||
byte[] byArray = new byte[this.recordSize];
|
||||
int n3 = 0;
|
||||
int n4 = this.recordSize;
|
||||
while (n4 > 0) {
|
||||
n = this.inStream.read(byArray, n3, n4);
|
||||
if (n == -1) {
|
||||
this.hasHitEOF = true;
|
||||
break;
|
||||
}
|
||||
n3 += n;
|
||||
n4 -= n;
|
||||
}
|
||||
if (!this.hasHitEOF) {
|
||||
this.hasHitEOF = true;
|
||||
n4 = 0;
|
||||
while (n4 < byArray.length) {
|
||||
if (byArray[n4] != 0) {
|
||||
this.hasHitEOF = false;
|
||||
break;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
}
|
||||
if (this.hasHitEOF) {
|
||||
this.currEntry = null;
|
||||
} else {
|
||||
try {
|
||||
this.currEntry = new TarEntry(byArray);
|
||||
if (this.debug) {
|
||||
byte[] byArray2 = new byte[byArray.length];
|
||||
n = 0;
|
||||
while (n < byArray.length) {
|
||||
byArray2[n] = byArray[n] == 0 ? 20 : byArray[n];
|
||||
++n;
|
||||
}
|
||||
String string = new String(byArray2);
|
||||
System.out.println("\n" + string);
|
||||
}
|
||||
if (byArray[257] != 117 || byArray[258] != 115 || byArray[259] != 116 || byArray[260] != 97 || byArray[261] != 114) {
|
||||
throw new InvalidHeaderException("header magic is not'ustar', but '" + byArray[257] + byArray[258] + byArray[259] + byArray[260] + byArray[261] + "', or (dec) " + byArray[257] + ", " + byArray[258] + ", " + byArray[259] + ", " + byArray[260] + ", " + byArray[261]);
|
||||
}
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
this.currEntry = null;
|
||||
throw invalidHeaderException;
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) {
|
||||
boolean bl = false;
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
TarEntry tarEntry;
|
||||
int n = 0;
|
||||
if (stringArray.length > 0) {
|
||||
if (stringArray[n].equals("-d")) {
|
||||
bl = true;
|
||||
++n;
|
||||
}
|
||||
inputStream = stringArray[n].endsWith(".gz") || stringArray[n].endsWith(".tgz") ? new GZIPInputStream(new FileInputStream(stringArray[n])) : new FileInputStream(stringArray[n]);
|
||||
} else {
|
||||
inputStream = System.in;
|
||||
}
|
||||
FastTarStream fastTarStream = new FastTarStream(inputStream);
|
||||
fastTarStream.setDebug(bl);
|
||||
int n2 = 56;
|
||||
int n3 = 9;
|
||||
int n4 = 8;
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
while ((tarEntry = fastTarStream.getNextEntry()) != null) {
|
||||
if (tarEntry.isDirectory()) {
|
||||
System.out.print("D ");
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getName());
|
||||
stringBuffer.setLength(stringBuffer.length() - 1);
|
||||
if (stringBuffer.length() > n2) {
|
||||
stringBuffer.setLength(n2);
|
||||
}
|
||||
while (stringBuffer.length() < n2) {
|
||||
stringBuffer.append('_');
|
||||
}
|
||||
stringBuffer.append('_');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
while (stringBuffer.length() < n3) {
|
||||
stringBuffer.insert(0, '_');
|
||||
}
|
||||
stringBuffer.append(' ');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getUserName());
|
||||
if (stringBuffer.length() > n4) {
|
||||
stringBuffer.setLength(n4);
|
||||
}
|
||||
while (stringBuffer.length() < n4) {
|
||||
stringBuffer.append(' ');
|
||||
}
|
||||
System.out.print(stringBuffer.toString());
|
||||
} else {
|
||||
System.out.print("F ");
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getName());
|
||||
if (stringBuffer.length() > n2) {
|
||||
stringBuffer.setLength(n2);
|
||||
}
|
||||
while (stringBuffer.length() < n2) {
|
||||
stringBuffer.append(' ');
|
||||
}
|
||||
stringBuffer.append(' ');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getSize());
|
||||
if (stringBuffer.length() > n3) {
|
||||
stringBuffer.setLength(n3);
|
||||
}
|
||||
while (stringBuffer.length() < n3) {
|
||||
stringBuffer.insert(0, ' ');
|
||||
}
|
||||
stringBuffer.append(' ');
|
||||
System.out.print(stringBuffer.toString());
|
||||
stringBuffer.setLength(0);
|
||||
stringBuffer.append(tarEntry.getUserName());
|
||||
if (stringBuffer.length() > n4) {
|
||||
stringBuffer.setLength(n4);
|
||||
}
|
||||
while (stringBuffer.length() < n4) {
|
||||
stringBuffer.append(' ');
|
||||
}
|
||||
System.out.print(stringBuffer.toString());
|
||||
}
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.currEntry = null;
|
||||
this.inStream = null;
|
||||
this.recordSize = 512;
|
||||
}
|
||||
|
||||
public FastTarStream(InputStream inputStream) {
|
||||
this(inputStream, 512);
|
||||
}
|
||||
|
||||
public FastTarStream(InputStream inputStream, int n) {
|
||||
this.this();
|
||||
this.inStream = inputStream;
|
||||
this.hasHitEOF = false;
|
||||
this.currEntry = null;
|
||||
this.recordSize = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class InvalidHeaderException
|
||||
extends IOException {
|
||||
public InvalidHeaderException() {
|
||||
}
|
||||
|
||||
public InvalidHeaderException(String string) {
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarInputStream;
|
||||
import com.ice.tar.TarOutputStream;
|
||||
import com.ice.tar.TarProgressDisplay;
|
||||
import com.ice.tar.TarTransFileTyper;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public class TarArchive {
|
||||
protected boolean verbose;
|
||||
protected boolean debug;
|
||||
protected boolean keepOldFiles;
|
||||
protected boolean asciiTranslate;
|
||||
protected int userId;
|
||||
protected String userName;
|
||||
protected int groupId;
|
||||
protected String groupName;
|
||||
protected String rootPath;
|
||||
protected String tempPath;
|
||||
protected String pathPrefix;
|
||||
protected int recordSize;
|
||||
protected byte[] recordBuf;
|
||||
protected TarInputStream tarIn;
|
||||
protected TarOutputStream tarOut;
|
||||
protected TarTransFileTyper transTyper;
|
||||
protected TarProgressDisplay progressDisplay;
|
||||
|
||||
private final void initialize(int n) {
|
||||
this.recordSize = n;
|
||||
this.rootPath = null;
|
||||
this.pathPrefix = null;
|
||||
this.tempPath = System.getProperty("user.dir");
|
||||
this.userId = 0;
|
||||
this.userName = "";
|
||||
this.groupId = 0;
|
||||
this.groupName = "";
|
||||
this.debug = false;
|
||||
this.verbose = false;
|
||||
this.keepOldFiles = false;
|
||||
this.progressDisplay = null;
|
||||
this.recordBuf = new byte[this.getRecordSize()];
|
||||
}
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.setDebug(bl);
|
||||
} else if (this.tarOut != null) {
|
||||
this.tarOut.setDebug(bl);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return this.verbose;
|
||||
}
|
||||
|
||||
public void setVerbose(boolean bl) {
|
||||
this.verbose = bl;
|
||||
}
|
||||
|
||||
public void setTarProgressDisplay(TarProgressDisplay tarProgressDisplay) {
|
||||
this.progressDisplay = tarProgressDisplay;
|
||||
}
|
||||
|
||||
public void setKeepOldFiles(boolean bl) {
|
||||
this.keepOldFiles = bl;
|
||||
}
|
||||
|
||||
public void setAsciiTranslation(boolean bl) {
|
||||
this.asciiTranslate = bl;
|
||||
}
|
||||
|
||||
public void setTransFileTyper(TarTransFileTyper tarTransFileTyper) {
|
||||
this.transTyper = tarTransFileTyper;
|
||||
}
|
||||
|
||||
public void setUserInfo(int n, String string, int n2, String string2) {
|
||||
this.userId = n;
|
||||
this.userName = string;
|
||||
this.groupId = n2;
|
||||
this.groupName = string2;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return this.groupName;
|
||||
}
|
||||
|
||||
public String getTempDirectory() {
|
||||
return this.tempPath;
|
||||
}
|
||||
|
||||
public void setTempDirectory(String string) {
|
||||
this.tempPath = string;
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
if (this.tarIn != null) {
|
||||
return this.tarIn.getRecordSize();
|
||||
}
|
||||
if (this.tarOut != null) {
|
||||
return this.tarOut.getRecordSize();
|
||||
}
|
||||
return 512;
|
||||
}
|
||||
|
||||
public void closeArchive() throws IOException {
|
||||
if (this.tarIn != null) {
|
||||
this.tarIn.close();
|
||||
} else if (this.tarOut != null) {
|
||||
this.tarOut.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void listContents() throws IOException, InvalidHeaderException {
|
||||
while (true) {
|
||||
TarEntry tarEntry;
|
||||
if ((tarEntry = this.tarIn.getNextEntry()) == null) {
|
||||
if (!this.debug) break;
|
||||
System.err.println("READ EOF RECORD");
|
||||
break;
|
||||
}
|
||||
if (this.progressDisplay == null) continue;
|
||||
this.progressDisplay.showTarProgressMessage(tarEntry.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void extractContents(File file) throws IOException, InvalidHeaderException {
|
||||
while (true) {
|
||||
TarEntry tarEntry;
|
||||
if ((tarEntry = this.tarIn.getNextEntry()) == null) {
|
||||
if (!this.debug) break;
|
||||
System.err.println("READ EOF RECORD");
|
||||
break;
|
||||
}
|
||||
this.extractEntry(file, tarEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private final void extractEntry(File file, TarEntry tarEntry) throws IOException {
|
||||
if (this.verbose && this.progressDisplay != null) {
|
||||
this.progressDisplay.showTarProgressMessage(tarEntry.getName());
|
||||
}
|
||||
String string = tarEntry.getName();
|
||||
string = string.replace('/', File.separatorChar);
|
||||
File file2 = new File(file, string);
|
||||
if (tarEntry.isDirectory()) {
|
||||
if (!file2.exists() && !file2.mkdirs()) {
|
||||
throw new IOException("error making directory path '" + file2.getPath() + '\'');
|
||||
}
|
||||
} else {
|
||||
File file3 = new File(file2.getParent());
|
||||
if (!file3.exists() && !file3.mkdirs()) {
|
||||
throw new IOException("error making directory path '" + file3.getPath() + '\'');
|
||||
}
|
||||
if (this.keepOldFiles && file2.exists()) {
|
||||
if (this.verbose && this.progressDisplay != null) {
|
||||
this.progressDisplay.showTarProgressMessage("not overwriting " + tarEntry.getName());
|
||||
}
|
||||
} else {
|
||||
int n;
|
||||
boolean bl = false;
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(file2);
|
||||
PrintWriter printWriter = null;
|
||||
if (bl) {
|
||||
printWriter = new PrintWriter(fileOutputStream);
|
||||
}
|
||||
byte[] byArray = new byte[32768];
|
||||
while ((n = this.tarIn.read(byArray)) != -1) {
|
||||
if (bl && printWriter != null) {
|
||||
int n2 = 0;
|
||||
int n3 = 0;
|
||||
while (n3 < n) {
|
||||
if (byArray[n3] == 10) {
|
||||
String string2 = new String(byArray, n2, n3 - n2);
|
||||
printWriter.println(string2);
|
||||
n2 = n3 + 1;
|
||||
}
|
||||
++n3;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
fileOutputStream.write(byArray, 0, n);
|
||||
}
|
||||
if (bl && printWriter != null) {
|
||||
printWriter.close();
|
||||
} else {
|
||||
fileOutputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEntry(TarEntry tarEntry, boolean bl) throws IOException {
|
||||
boolean bl2 = tarEntry.isUnixTarFormat();
|
||||
File file = tarEntry.getFile();
|
||||
TarEntry tarEntry2 = (TarEntry)tarEntry.clone();
|
||||
if (this.verbose && this.progressDisplay != null) {
|
||||
this.progressDisplay.showTarProgressMessage(tarEntry2.getName());
|
||||
}
|
||||
String string = null;
|
||||
if (this.rootPath != null && tarEntry2.getName().startsWith(this.rootPath)) {
|
||||
string = tarEntry2.getName().substring(this.rootPath.length() + 1);
|
||||
}
|
||||
if (this.pathPrefix != null) {
|
||||
String string2 = string = string == null ? this.pathPrefix + '/' + tarEntry2.getName() : this.pathPrefix + '/' + string;
|
||||
}
|
||||
if (string != null) {
|
||||
tarEntry2.setName(string);
|
||||
}
|
||||
this.tarOut.putNextEntry(tarEntry2);
|
||||
if (tarEntry2.isDirectory()) {
|
||||
if (bl) {
|
||||
TarEntry[] tarEntryArray = tarEntry2.getDirectoryEntries();
|
||||
int n = 0;
|
||||
while (n < tarEntryArray.length) {
|
||||
TarEntry tarEntry3 = tarEntryArray[n];
|
||||
if (bl2) {
|
||||
tarEntry3.setUnixTarFormat();
|
||||
}
|
||||
this.writeEntry(tarEntry3, bl);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int n;
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
byte[] byArray = new byte[32768];
|
||||
while ((n = fileInputStream.read(byArray, 0, byArray.length)) != -1) {
|
||||
this.tarOut.write(byArray, 0, n);
|
||||
}
|
||||
fileInputStream.close();
|
||||
this.tarOut.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
public TarArchive(InputStream inputStream) {
|
||||
this(inputStream, 10240);
|
||||
}
|
||||
|
||||
public TarArchive(InputStream inputStream, int n) {
|
||||
this(inputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarArchive(InputStream inputStream, int n, int n2) {
|
||||
this.tarIn = new TarInputStream(inputStream, n, n2);
|
||||
this.initialize(n2);
|
||||
}
|
||||
|
||||
public TarArchive(OutputStream outputStream) {
|
||||
this(outputStream, 10240);
|
||||
}
|
||||
|
||||
public TarArchive(OutputStream outputStream, int n) {
|
||||
this(outputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarArchive(OutputStream outputStream, int n, int n2) {
|
||||
this.tarOut = new TarOutputStream(outputStream, n, n2);
|
||||
this.initialize(n2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class TarBuffer {
|
||||
public static final int DEFAULT_RCDSIZE = 512;
|
||||
public static final int DEFAULT_BLKSIZE = 10240;
|
||||
private InputStream inStream;
|
||||
private OutputStream outStream;
|
||||
private byte[] blockBuffer;
|
||||
private int currBlkIdx;
|
||||
private int currRecIdx;
|
||||
private int blockSize;
|
||||
private int recordSize;
|
||||
private int recsPerBlock;
|
||||
private boolean debug;
|
||||
|
||||
private final void initialize(int n, int n2) {
|
||||
this.debug = false;
|
||||
this.blockSize = n;
|
||||
this.recordSize = n2;
|
||||
this.recsPerBlock = this.blockSize / this.recordSize;
|
||||
this.blockBuffer = new byte[this.blockSize];
|
||||
if (this.inStream != null) {
|
||||
this.currBlkIdx = -1;
|
||||
this.currRecIdx = this.recsPerBlock;
|
||||
} else {
|
||||
this.currBlkIdx = 0;
|
||||
this.currRecIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlockSize() {
|
||||
return this.blockSize;
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.recordSize;
|
||||
}
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public boolean isEOFRecord(byte[] byArray) {
|
||||
int n = 0;
|
||||
int n2 = this.getRecordSize();
|
||||
while (n < n2) {
|
||||
if (byArray[n] != 0) {
|
||||
return false;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void skipRecord() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("SkipRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.inStream == null) {
|
||||
throw new IOException("reading (via skip) from an output buffer");
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock && !this.readBlock()) {
|
||||
return;
|
||||
}
|
||||
++this.currRecIdx;
|
||||
}
|
||||
|
||||
public byte[] readRecord() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("ReadRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.inStream == null) {
|
||||
throw new IOException("reading from an output buffer");
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock && !this.readBlock()) {
|
||||
return null;
|
||||
}
|
||||
byte[] byArray = new byte[this.recordSize];
|
||||
System.arraycopy(this.blockBuffer, this.currRecIdx * this.recordSize, byArray, 0, this.recordSize);
|
||||
++this.currRecIdx;
|
||||
return byArray;
|
||||
}
|
||||
|
||||
private final boolean readBlock() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("ReadBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.inStream == null) {
|
||||
throw new IOException("reading from an output buffer");
|
||||
}
|
||||
this.currRecIdx = 0;
|
||||
int n = 0;
|
||||
int n2 = this.blockSize;
|
||||
while (n2 > 0) {
|
||||
long l = this.inStream.read(this.blockBuffer, n, n2);
|
||||
if (l == (long)-1) break;
|
||||
n = (int)((long)n + l);
|
||||
n2 = (int)((long)n2 - l);
|
||||
if (l == (long)this.blockSize || !this.debug) continue;
|
||||
System.err.println("ReadBlock: INCOMPLETE READ " + l + " of " + this.blockSize + " bytes read.");
|
||||
}
|
||||
++this.currBlkIdx;
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCurrentBlockNum() {
|
||||
return this.currBlkIdx;
|
||||
}
|
||||
|
||||
public int getCurrentRecordNum() {
|
||||
return this.currRecIdx - 1;
|
||||
}
|
||||
|
||||
public void writeRecord(byte[] byArray) throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
if (byArray.length != this.recordSize) {
|
||||
throw new IOException("record to write has length '" + byArray.length + "' which is not the record size of '" + this.recordSize + '\'');
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.writeBlock();
|
||||
}
|
||||
System.arraycopy(byArray, 0, this.blockBuffer, this.currRecIdx * this.recordSize, this.recordSize);
|
||||
++this.currRecIdx;
|
||||
}
|
||||
|
||||
public void writeRecord(byte[] byArray, int n) throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("WriteRecord: recIdx = " + this.currRecIdx + " blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
if (n + this.recordSize > byArray.length) {
|
||||
throw new IOException("record has length '" + byArray.length + "' with offset '" + n + "' which is less than the record size of '" + this.recordSize + '\'');
|
||||
}
|
||||
if (this.currRecIdx >= this.recsPerBlock) {
|
||||
this.writeBlock();
|
||||
}
|
||||
System.arraycopy(byArray, n, this.blockBuffer, this.currRecIdx * this.recordSize, this.recordSize);
|
||||
++this.currRecIdx;
|
||||
}
|
||||
|
||||
private final void writeBlock() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("WriteBlock: blkIdx = " + this.currBlkIdx);
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
this.outStream.write(this.blockBuffer, 0, this.blockSize);
|
||||
this.outStream.flush();
|
||||
this.currRecIdx = 0;
|
||||
++this.currBlkIdx;
|
||||
}
|
||||
|
||||
private final void flushBlock() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("TarBuffer.flushBlock() called.");
|
||||
}
|
||||
if (this.outStream == null) {
|
||||
throw new IOException("writing to an input buffer");
|
||||
}
|
||||
if (this.currRecIdx > 0) {
|
||||
int n = this.currRecIdx * this.recordSize;
|
||||
byte[] byArray = new byte[this.blockSize - n];
|
||||
System.arraycopy(byArray, 0, this.blockBuffer, n, byArray.length);
|
||||
this.writeBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
if (this.debug) {
|
||||
System.err.println("TarBuffer.closeBuffer().");
|
||||
}
|
||||
if (this.outStream != null) {
|
||||
this.flushBlock();
|
||||
if (this.outStream != System.out && this.outStream != System.err) {
|
||||
this.outStream.close();
|
||||
this.outStream = null;
|
||||
}
|
||||
} else if (this.inStream != null && this.inStream != System.in) {
|
||||
this.inStream.close();
|
||||
this.inStream = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TarBuffer(InputStream inputStream) {
|
||||
this(inputStream, 10240);
|
||||
}
|
||||
|
||||
public TarBuffer(InputStream inputStream, int n) {
|
||||
this(inputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarBuffer(InputStream inputStream, int n, int n2) {
|
||||
this.inStream = inputStream;
|
||||
this.outStream = null;
|
||||
this.initialize(n, n2);
|
||||
}
|
||||
|
||||
public TarBuffer(OutputStream outputStream) {
|
||||
this(outputStream, 10240);
|
||||
}
|
||||
|
||||
public TarBuffer(OutputStream outputStream, int n) {
|
||||
this(outputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarBuffer(OutputStream outputStream, int n, int n2) {
|
||||
this.inStream = null;
|
||||
this.outStream = outputStream;
|
||||
this.initialize(n, n2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarHeader;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
|
||||
public class TarEntry
|
||||
implements Cloneable {
|
||||
protected File file;
|
||||
protected TarHeader header;
|
||||
protected boolean unixFormat;
|
||||
protected boolean ustarFormat;
|
||||
protected boolean gnuFormat;
|
||||
|
||||
private final void initialize() {
|
||||
this.file = null;
|
||||
this.header = new TarHeader();
|
||||
this.gnuFormat = false;
|
||||
this.ustarFormat = true;
|
||||
this.unixFormat = false;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
TarEntry tarEntry = null;
|
||||
try {
|
||||
tarEntry = (TarEntry)super.clone();
|
||||
if (this.header != null) {
|
||||
tarEntry.header = (TarHeader)this.header.clone();
|
||||
}
|
||||
if (this.file != null) {
|
||||
tarEntry.file = new File(this.file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
catch (CloneNotSupportedException cloneNotSupportedException) {
|
||||
cloneNotSupportedException.printStackTrace(System.err);
|
||||
}
|
||||
return tarEntry;
|
||||
}
|
||||
|
||||
public boolean isUSTarFormat() {
|
||||
return this.ustarFormat;
|
||||
}
|
||||
|
||||
public void setUSTarFormat() {
|
||||
this.ustarFormat = true;
|
||||
this.gnuFormat = false;
|
||||
this.unixFormat = false;
|
||||
}
|
||||
|
||||
public boolean isGNUTarFormat() {
|
||||
return this.gnuFormat;
|
||||
}
|
||||
|
||||
public void setGNUTarFormat() {
|
||||
this.gnuFormat = true;
|
||||
this.ustarFormat = false;
|
||||
this.unixFormat = false;
|
||||
}
|
||||
|
||||
public boolean isUnixTarFormat() {
|
||||
return this.unixFormat;
|
||||
}
|
||||
|
||||
public void setUnixTarFormat() {
|
||||
this.unixFormat = true;
|
||||
this.ustarFormat = false;
|
||||
this.gnuFormat = false;
|
||||
}
|
||||
|
||||
public boolean equals(TarEntry tarEntry) {
|
||||
return this.header.name.toString().equals(tarEntry.header.name.toString());
|
||||
}
|
||||
|
||||
public boolean isDescendent(TarEntry tarEntry) {
|
||||
return tarEntry.header.name.toString().startsWith(this.header.name.toString());
|
||||
}
|
||||
|
||||
public TarHeader getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.header.name.toString();
|
||||
}
|
||||
|
||||
public void setName(String string) {
|
||||
this.header.name = new StringBuffer(string);
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return this.header.userId;
|
||||
}
|
||||
|
||||
public void setUserId(int n) {
|
||||
this.header.userId = n;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return this.header.groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(int n) {
|
||||
this.header.groupId = n;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.header.userName.toString();
|
||||
}
|
||||
|
||||
public void setUserName(String string) {
|
||||
this.header.userName = new StringBuffer(string);
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return this.header.groupName.toString();
|
||||
}
|
||||
|
||||
public void setGroupName(String string) {
|
||||
this.header.groupName = new StringBuffer(string);
|
||||
}
|
||||
|
||||
public void setIds(int n, int n2) {
|
||||
this.setUserId(n);
|
||||
this.setGroupId(n2);
|
||||
}
|
||||
|
||||
public void setNames(String string, String string2) {
|
||||
this.setUserName(string);
|
||||
this.setGroupName(string2);
|
||||
}
|
||||
|
||||
public void setModTime(long l) {
|
||||
this.header.modTime = l / 1000L;
|
||||
}
|
||||
|
||||
public void setModTime(Date date) {
|
||||
this.header.modTime = date.getTime() / 1000L;
|
||||
}
|
||||
|
||||
public Date getModTime() {
|
||||
return new Date(this.header.modTime * 1000L);
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return this.file;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return this.header.size;
|
||||
}
|
||||
|
||||
public void setSize(long l) {
|
||||
this.header.size = l;
|
||||
}
|
||||
|
||||
public boolean isDirectory() {
|
||||
if (this.file != null) {
|
||||
return this.file.isDirectory();
|
||||
}
|
||||
if (this.header != null) {
|
||||
if (this.header.linkFlag == 53) {
|
||||
return true;
|
||||
}
|
||||
if (this.header.name.toString().endsWith("/")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void getFileTarHeader(TarHeader tarHeader, File file) throws InvalidHeaderException {
|
||||
this.file = file;
|
||||
String string = file.getPath();
|
||||
String string2 = System.getProperty("os.name");
|
||||
if (string2 != null) {
|
||||
String string3 = "windows";
|
||||
if (string2.toLowerCase().startsWith(string3) && string.length() > 2) {
|
||||
char c = string.charAt(0);
|
||||
char c2 = string.charAt(1);
|
||||
if (c2 == ':' && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) {
|
||||
string = string.substring(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
string = string.replace(File.separatorChar, '/');
|
||||
while (string.startsWith("/")) {
|
||||
string = string.substring(1);
|
||||
}
|
||||
tarHeader.linkName = new StringBuffer("");
|
||||
tarHeader.name = new StringBuffer(string);
|
||||
if (file.isDirectory()) {
|
||||
tarHeader.size = 0L;
|
||||
tarHeader.mode = 16877;
|
||||
tarHeader.linkFlag = (byte)53;
|
||||
if (tarHeader.name.charAt(tarHeader.name.length() - 1) != '/') {
|
||||
tarHeader.name.append("/");
|
||||
}
|
||||
} else {
|
||||
tarHeader.size = file.length();
|
||||
tarHeader.mode = 33188;
|
||||
tarHeader.linkFlag = (byte)48;
|
||||
}
|
||||
tarHeader.modTime = file.lastModified() / 1000L;
|
||||
tarHeader.checkSum = 0;
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
}
|
||||
|
||||
public TarEntry[] getDirectoryEntries() throws InvalidHeaderException {
|
||||
if (this.file == null || !this.file.isDirectory()) {
|
||||
return new TarEntry[0];
|
||||
}
|
||||
String[] stringArray = this.file.list();
|
||||
TarEntry[] tarEntryArray = new TarEntry[stringArray.length];
|
||||
int n = 0;
|
||||
while (n < stringArray.length) {
|
||||
tarEntryArray[n] = new TarEntry(new File(this.file, stringArray[n]));
|
||||
++n;
|
||||
}
|
||||
return tarEntryArray;
|
||||
}
|
||||
|
||||
public long computeCheckSum(byte[] byArray) {
|
||||
long l = 0L;
|
||||
int n = 0;
|
||||
while (n < byArray.length) {
|
||||
l += (long)(0xFF & byArray[n]);
|
||||
++n;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public void writeEntryHeader(byte[] byArray) throws InvalidHeaderException {
|
||||
int n = 0;
|
||||
if (this.isUnixTarFormat() && this.header.name.length() > 100) {
|
||||
throw new InvalidHeaderException("file path is greater than 100 characters, " + this.header.name);
|
||||
}
|
||||
n = TarHeader.getFileNameBytes(this.header.name.toString(), byArray);
|
||||
n = TarHeader.getOctalBytes(this.header.mode, byArray, n, 8);
|
||||
n = TarHeader.getOctalBytes(this.header.userId, byArray, n, 8);
|
||||
n = TarHeader.getOctalBytes(this.header.groupId, byArray, n, 8);
|
||||
long l = this.header.size;
|
||||
n = TarHeader.getLongOctalBytes(l, byArray, n, 12);
|
||||
int n2 = n = TarHeader.getLongOctalBytes(this.header.modTime, byArray, n, 12);
|
||||
int n3 = 0;
|
||||
while (n3 < 8) {
|
||||
byArray[n++] = 32;
|
||||
++n3;
|
||||
}
|
||||
byArray[n++] = this.header.linkFlag;
|
||||
n = TarHeader.getNameBytes(this.header.linkName, byArray, n, 100);
|
||||
if (this.unixFormat) {
|
||||
n3 = 0;
|
||||
while (n3 < 8) {
|
||||
byArray[n++] = 0;
|
||||
++n3;
|
||||
}
|
||||
} else {
|
||||
n = TarHeader.getNameBytes(this.header.magic, byArray, n, 8);
|
||||
}
|
||||
n = TarHeader.getNameBytes(this.header.userName, byArray, n, 32);
|
||||
n = TarHeader.getNameBytes(this.header.groupName, byArray, n, 32);
|
||||
n = TarHeader.getOctalBytes(this.header.devMajor, byArray, n, 8);
|
||||
n = TarHeader.getOctalBytes(this.header.devMinor, byArray, n, 8);
|
||||
while (n < byArray.length) {
|
||||
byArray[n++] = 0;
|
||||
}
|
||||
long l2 = this.computeCheckSum(byArray);
|
||||
TarHeader.getCheckSumOctalBytes(l2, byArray, n2, 8);
|
||||
}
|
||||
|
||||
public void parseTarHeader(TarHeader tarHeader, byte[] byArray) throws InvalidHeaderException {
|
||||
int n = 0;
|
||||
if (byArray[257] == 0 && byArray[258] == 0 && byArray[259] == 0 && byArray[260] == 0 && byArray[261] == 0) {
|
||||
this.unixFormat = true;
|
||||
this.ustarFormat = false;
|
||||
this.gnuFormat = false;
|
||||
} else if (byArray[257] == 117 && byArray[258] == 115 && byArray[259] == 116 && byArray[260] == 97 && byArray[261] == 114 && byArray[262] == 0) {
|
||||
this.ustarFormat = true;
|
||||
this.gnuFormat = false;
|
||||
this.unixFormat = false;
|
||||
} else if (byArray[257] == 117 && byArray[258] == 115 && byArray[259] == 116 && byArray[260] == 97 && byArray[261] == 114 && byArray[262] != 0 && byArray[263] != 0) {
|
||||
this.gnuFormat = true;
|
||||
this.unixFormat = false;
|
||||
this.ustarFormat = false;
|
||||
} else {
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
stringBuffer.append("header magic is not 'ustar' or unix-style zeros, it is '");
|
||||
stringBuffer.append(byArray[257]);
|
||||
stringBuffer.append(byArray[258]);
|
||||
stringBuffer.append(byArray[259]);
|
||||
stringBuffer.append(byArray[260]);
|
||||
stringBuffer.append(byArray[261]);
|
||||
stringBuffer.append(byArray[262]);
|
||||
stringBuffer.append(byArray[263]);
|
||||
stringBuffer.append("', or (dec) ");
|
||||
stringBuffer.append(byArray[257]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[258]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[259]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[260]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[261]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[262]);
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(byArray[263]);
|
||||
throw new InvalidHeaderException(stringBuffer.toString());
|
||||
}
|
||||
tarHeader.name = TarHeader.parseFileName(byArray);
|
||||
n = 100;
|
||||
tarHeader.mode = (int)TarHeader.parseOctal(byArray, n, 8);
|
||||
tarHeader.userId = (int)TarHeader.parseOctal(byArray, n += 8, 8);
|
||||
tarHeader.groupId = (int)TarHeader.parseOctal(byArray, n += 8, 8);
|
||||
tarHeader.size = TarHeader.parseOctal(byArray, n += 8, 12);
|
||||
tarHeader.modTime = TarHeader.parseOctal(byArray, n += 12, 12);
|
||||
tarHeader.checkSum = (int)TarHeader.parseOctal(byArray, n += 12, 8);
|
||||
n += 8;
|
||||
tarHeader.linkFlag = byArray[n++];
|
||||
tarHeader.linkName = TarHeader.parseName(byArray, n, 100);
|
||||
n += 100;
|
||||
if (this.ustarFormat) {
|
||||
tarHeader.magic = TarHeader.parseName(byArray, n, 8);
|
||||
tarHeader.userName = TarHeader.parseName(byArray, n += 8, 32);
|
||||
tarHeader.groupName = TarHeader.parseName(byArray, n += 32, 32);
|
||||
tarHeader.devMajor = (int)TarHeader.parseOctal(byArray, n += 32, 8);
|
||||
tarHeader.devMinor = (int)TarHeader.parseOctal(byArray, n += 8, 8);
|
||||
} else {
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
tarHeader.magic = new StringBuffer("");
|
||||
tarHeader.userName = new StringBuffer("");
|
||||
tarHeader.groupName = new StringBuffer("");
|
||||
}
|
||||
}
|
||||
|
||||
public void nameTarHeader(TarHeader tarHeader, String string) {
|
||||
boolean bl = string.endsWith("/");
|
||||
this.gnuFormat = false;
|
||||
this.ustarFormat = true;
|
||||
this.unixFormat = false;
|
||||
tarHeader.checkSum = 0;
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
tarHeader.name = new StringBuffer(string);
|
||||
tarHeader.mode = bl ? 16877 : 33188;
|
||||
tarHeader.userId = 0;
|
||||
tarHeader.groupId = 0;
|
||||
tarHeader.size = 0L;
|
||||
tarHeader.checkSum = 0;
|
||||
tarHeader.modTime = new Date().getTime() / 1000L;
|
||||
tarHeader.linkFlag = (byte)(bl ? 53 : 48);
|
||||
tarHeader.linkName = new StringBuffer("");
|
||||
tarHeader.userName = new StringBuffer("");
|
||||
tarHeader.groupName = new StringBuffer("");
|
||||
tarHeader.devMajor = 0;
|
||||
tarHeader.devMinor = 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer(128);
|
||||
return stringBuffer.append("[TarEntry name=").append(this.getName()).append(", isDir=").append(this.isDirectory()).append(", size=").append(this.getSize()).append(", userId=").append(this.getUserId()).append(", user=").append(this.getUserName()).append(", groupId=").append(this.getGroupId()).append(", group=").append(this.getGroupName()).append("]").toString();
|
||||
}
|
||||
|
||||
protected TarEntry() {
|
||||
}
|
||||
|
||||
public TarEntry(String string) {
|
||||
this.initialize();
|
||||
this.nameTarHeader(this.header, string);
|
||||
}
|
||||
|
||||
public TarEntry(File file) throws InvalidHeaderException {
|
||||
this.initialize();
|
||||
this.getFileTarHeader(this.header, file);
|
||||
}
|
||||
|
||||
public TarEntry(byte[] byArray) throws InvalidHeaderException {
|
||||
this.initialize();
|
||||
this.parseTarHeader(this.header, byArray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class TarEntryEnumerator
|
||||
implements Enumeration {
|
||||
private TarInputStream tis;
|
||||
private boolean eof;
|
||||
private TarEntry readAhead;
|
||||
|
||||
public Object nextElement() throws NoSuchElementException {
|
||||
if (this.eof && this.readAhead == null) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
TarEntry tarEntry = null;
|
||||
if (this.readAhead != null) {
|
||||
tarEntry = this.readAhead;
|
||||
this.readAhead = null;
|
||||
} else {
|
||||
tarEntry = this.getNext();
|
||||
}
|
||||
return tarEntry;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
if (this.eof) {
|
||||
return false;
|
||||
}
|
||||
boolean bl = false;
|
||||
this.readAhead = this.getNext();
|
||||
if (this.readAhead != null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
private final TarEntry getNext() {
|
||||
TarEntry tarEntry = null;
|
||||
try {
|
||||
tarEntry = this.tis.getNextEntry();
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace();
|
||||
}
|
||||
if (tarEntry == null) {
|
||||
this.eof = true;
|
||||
}
|
||||
return tarEntry;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.tis = null;
|
||||
this.eof = false;
|
||||
this.readAhead = null;
|
||||
}
|
||||
|
||||
public TarEntryEnumerator(TarInputStream tarInputStream) {
|
||||
this.this();
|
||||
this.tis = tarInputStream;
|
||||
this.eof = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class TarGzOutputStream
|
||||
extends TarOutputStream {
|
||||
private TarOutputStream tos;
|
||||
private GZIPOutputStream gzip;
|
||||
private ByteArrayOutputStream bos;
|
||||
private TarEntry currentEntry;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.tos.setDebug(bl);
|
||||
}
|
||||
|
||||
public void setBufferDebug(boolean bl) {
|
||||
this.tos.setBufferDebug(bl);
|
||||
}
|
||||
|
||||
public void finish() throws IOException {
|
||||
if (this.currentEntry != null) {
|
||||
this.closeEntry();
|
||||
}
|
||||
this.tos.finish();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.tos.close();
|
||||
this.gzip.finish();
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.tos.getRecordSize();
|
||||
}
|
||||
|
||||
public void putNextEntry(TarEntry tarEntry) throws IOException {
|
||||
if (tarEntry.getSize() != 0L) {
|
||||
this.tos.putNextEntry(tarEntry);
|
||||
} else {
|
||||
this.currentEntry = tarEntry;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeEntry() throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.closeEntry();
|
||||
} else {
|
||||
this.currentEntry.setSize(this.bos.size());
|
||||
this.tos.putNextEntry(this.currentEntry);
|
||||
this.bos.writeTo(this.tos);
|
||||
this.tos.closeEntry();
|
||||
this.currentEntry = null;
|
||||
this.bos = new ByteArrayOutputStream();
|
||||
}
|
||||
}
|
||||
|
||||
public void write(int n) throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.write(n);
|
||||
} else {
|
||||
this.bos.write(n);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.write(byArray);
|
||||
} else {
|
||||
this.bos.write(byArray);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.currentEntry == null) {
|
||||
this.tos.write(byArray, n, n2);
|
||||
} else {
|
||||
this.bos.write(byArray, n, n2);
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.tos = null;
|
||||
this.gzip = null;
|
||||
this.bos = null;
|
||||
this.currentEntry = null;
|
||||
}
|
||||
|
||||
public TarGzOutputStream(OutputStream outputStream) throws IOException {
|
||||
super(null);
|
||||
this.this();
|
||||
this.gzip = new GZIPOutputStream(outputStream);
|
||||
this.tos = new TarOutputStream(this.gzip);
|
||||
this.bos = new ByteArrayOutputStream();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
|
||||
public class TarHeader
|
||||
implements Cloneable {
|
||||
public static final int NAMELEN = 100;
|
||||
public static final int NAMEOFFSET = 0;
|
||||
public static final int PREFIXLEN = 155;
|
||||
public static final int PREFIXOFFSET = 345;
|
||||
public static final int MODELEN = 8;
|
||||
public static final int UIDLEN = 8;
|
||||
public static final int GIDLEN = 8;
|
||||
public static final int CHKSUMLEN = 8;
|
||||
public static final int SIZELEN = 12;
|
||||
public static final int MAGICLEN = 8;
|
||||
public static final int MODTIMELEN = 12;
|
||||
public static final int UNAMELEN = 32;
|
||||
public static final int GNAMELEN = 32;
|
||||
public static final int DEVLEN = 8;
|
||||
public static final byte LF_OLDNORM = 0;
|
||||
public static final byte LF_NORMAL = 48;
|
||||
public static final byte LF_LINK = 49;
|
||||
public static final byte LF_SYMLINK = 50;
|
||||
public static final byte LF_CHR = 51;
|
||||
public static final byte LF_BLK = 52;
|
||||
public static final byte LF_DIR = 53;
|
||||
public static final byte LF_FIFO = 54;
|
||||
public static final byte LF_CONTIG = 55;
|
||||
public static final String TMAGIC = "ustar";
|
||||
public static final String GNU_TMAGIC = "ustar ";
|
||||
public StringBuffer name;
|
||||
public int mode;
|
||||
public int userId;
|
||||
public int groupId;
|
||||
public long size;
|
||||
public long modTime;
|
||||
public int checkSum;
|
||||
public byte linkFlag;
|
||||
public StringBuffer linkName;
|
||||
public StringBuffer magic = new StringBuffer("ustar");
|
||||
public StringBuffer userName;
|
||||
public StringBuffer groupName;
|
||||
public int devMajor;
|
||||
public int devMinor;
|
||||
|
||||
public Object clone() {
|
||||
TarHeader tarHeader = null;
|
||||
try {
|
||||
tarHeader = (TarHeader)super.clone();
|
||||
tarHeader.name = this.name == null ? null : new StringBuffer(this.name.toString());
|
||||
tarHeader.mode = this.mode;
|
||||
tarHeader.userId = this.userId;
|
||||
tarHeader.groupId = this.groupId;
|
||||
tarHeader.size = this.size;
|
||||
tarHeader.modTime = this.modTime;
|
||||
tarHeader.checkSum = this.checkSum;
|
||||
tarHeader.linkFlag = this.linkFlag;
|
||||
tarHeader.linkName = this.linkName == null ? null : new StringBuffer(this.linkName.toString());
|
||||
tarHeader.magic = this.magic == null ? null : new StringBuffer(this.magic.toString());
|
||||
tarHeader.userName = this.userName == null ? null : new StringBuffer(this.userName.toString());
|
||||
tarHeader.groupName = this.groupName == null ? null : new StringBuffer(this.groupName.toString());
|
||||
tarHeader.devMajor = this.devMajor;
|
||||
tarHeader.devMinor = this.devMinor;
|
||||
}
|
||||
catch (CloneNotSupportedException cloneNotSupportedException) {
|
||||
cloneNotSupportedException.printStackTrace(System.err);
|
||||
}
|
||||
return tarHeader;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name.toString();
|
||||
}
|
||||
|
||||
public static long parseOctal(byte[] byArray, int n, int n2) throws InvalidHeaderException {
|
||||
long l = 0L;
|
||||
boolean bl = true;
|
||||
int n3 = n + n2;
|
||||
int n4 = n;
|
||||
while (n4 < n3) {
|
||||
if (byArray[n4] == 0) break;
|
||||
if (byArray[n4] == 32 || byArray[n4] == 48) {
|
||||
if (!bl) {
|
||||
if (byArray[n4] == 32) break;
|
||||
}
|
||||
} else {
|
||||
bl = false;
|
||||
l = (l << 3) + (long)(byArray[n4] - 48);
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public static StringBuffer parseFileName(byte[] byArray) {
|
||||
int n;
|
||||
StringBuffer stringBuffer = new StringBuffer(256);
|
||||
if (byArray[345] != 0) {
|
||||
n = 345;
|
||||
while (n < 500 && byArray[n] != 0) {
|
||||
stringBuffer.append((char)byArray[n]);
|
||||
++n;
|
||||
}
|
||||
stringBuffer.append("/");
|
||||
}
|
||||
n = 0;
|
||||
while (n < 100 && byArray[n] != 0) {
|
||||
stringBuffer.append((char)byArray[n]);
|
||||
++n;
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public static StringBuffer parseName(byte[] byArray, int n, int n2) throws InvalidHeaderException {
|
||||
StringBuffer stringBuffer = new StringBuffer(n2);
|
||||
int n3 = n + n2;
|
||||
int n4 = n;
|
||||
while (n4 < n3) {
|
||||
if (byArray[n4] == 0) break;
|
||||
stringBuffer.append((char)byArray[n4]);
|
||||
++n4;
|
||||
}
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
public static int getFileNameBytes(String string, byte[] byArray) throws InvalidHeaderException {
|
||||
if (string.length() > 100) {
|
||||
int n = string.indexOf("/", string.length() - 100);
|
||||
if (n == -1) {
|
||||
throw new InvalidHeaderException("file name is greater than 100 characters, " + string);
|
||||
}
|
||||
String string2 = string.substring(n + 1);
|
||||
String string3 = string.substring(0, n);
|
||||
if (string3.length() > 155) {
|
||||
throw new InvalidHeaderException("file prefix is greater than 155 characters");
|
||||
}
|
||||
TarHeader.getNameBytes(new StringBuffer(string2), byArray, 0, 100);
|
||||
TarHeader.getNameBytes(new StringBuffer(string3), byArray, 345, 155);
|
||||
} else {
|
||||
TarHeader.getNameBytes(new StringBuffer(string), byArray, 0, 100);
|
||||
}
|
||||
return 100;
|
||||
}
|
||||
|
||||
public static int getNameBytes(StringBuffer stringBuffer, byte[] byArray, int n, int n2) {
|
||||
int n3 = 0;
|
||||
while (n3 < n2 && n3 < stringBuffer.length()) {
|
||||
byArray[n + n3] = (byte)stringBuffer.charAt(n3);
|
||||
++n3;
|
||||
}
|
||||
while (n3 < n2) {
|
||||
byArray[n + n3] = 0;
|
||||
++n3;
|
||||
}
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public static int getOctalBytes(long l, byte[] byArray, int n, int n2) {
|
||||
int n3 = n2 - 1;
|
||||
byArray[n + n3] = 0;
|
||||
byArray[n + --n3] = 32;
|
||||
--n3;
|
||||
if (l == 0L) {
|
||||
byArray[n + n3] = 48;
|
||||
--n3;
|
||||
} else {
|
||||
long l2 = l;
|
||||
while (n3 >= 0 && l2 > 0L) {
|
||||
byArray[n + n3] = (byte)(48 + (byte)(l2 & 7L));
|
||||
l2 >>= 3;
|
||||
--n3;
|
||||
}
|
||||
}
|
||||
while (n3 >= 0) {
|
||||
byArray[n + n3] = 32;
|
||||
--n3;
|
||||
}
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public static int getLongOctalBytes(long l, byte[] byArray, int n, int n2) {
|
||||
byte[] byArray2 = new byte[n2 + 1];
|
||||
TarHeader.getOctalBytes(l, byArray2, 0, n2 + 1);
|
||||
System.arraycopy(byArray2, 0, byArray, n, n2);
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public static int getCheckSumOctalBytes(long l, byte[] byArray, int n, int n2) {
|
||||
TarHeader.getOctalBytes(l, byArray, n, n2);
|
||||
byArray[n + n2 - 1] = 32;
|
||||
byArray[n + n2 - 2] = 0;
|
||||
return n + n2;
|
||||
}
|
||||
|
||||
public TarHeader() {
|
||||
this.name = new StringBuffer();
|
||||
this.linkName = new StringBuffer();
|
||||
String string = System.getProperty("user.name", "");
|
||||
if (string.length() > 31) {
|
||||
string = string.substring(0, 31);
|
||||
}
|
||||
this.userId = 0;
|
||||
this.groupId = 0;
|
||||
this.userName = new StringBuffer(string);
|
||||
this.groupName = new StringBuffer("");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarBuffer;
|
||||
import com.ice.tar.TarEntry;
|
||||
import java.io.File;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class TarInputStream
|
||||
extends FilterInputStream {
|
||||
protected boolean debug;
|
||||
protected boolean hasHitEOF;
|
||||
protected long entrySize;
|
||||
protected long entryOffset;
|
||||
protected byte[] oneBuf;
|
||||
protected byte[] readBuf;
|
||||
protected TarBuffer buffer;
|
||||
protected TarEntry currEntry;
|
||||
protected EntryFactory eFactory;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public void setEntryFactory(EntryFactory entryFactory) {
|
||||
this.eFactory = entryFactory;
|
||||
}
|
||||
|
||||
public void setBufferDebug(boolean bl) {
|
||||
this.buffer.setDebug(bl);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.buffer.close();
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.buffer.getRecordSize();
|
||||
}
|
||||
|
||||
public int available() throws IOException {
|
||||
return (int)(this.entrySize - this.entryOffset);
|
||||
}
|
||||
|
||||
public long skip(long l) throws IOException {
|
||||
byte[] byArray = new byte[8192];
|
||||
long l2 = l;
|
||||
while (l2 > 0L) {
|
||||
int n = this.read(byArray, 0, l2 > (long)byArray.length ? byArray.length : (int)l2);
|
||||
if (n == -1) break;
|
||||
l2 -= (long)n;
|
||||
}
|
||||
return l - l2;
|
||||
}
|
||||
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void mark(int n) {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
public long getEntryPosition() {
|
||||
return this.entryOffset;
|
||||
}
|
||||
|
||||
public long getStreamPosition() {
|
||||
return this.buffer.getBlockSize() * this.buffer.getCurrentBlockNum() + this.buffer.getCurrentRecordNum();
|
||||
}
|
||||
|
||||
public TarEntry getNextEntry() throws IOException {
|
||||
byte[] byArray;
|
||||
if (this.hasHitEOF) {
|
||||
return null;
|
||||
}
|
||||
if (this.currEntry != null) {
|
||||
long l = this.entrySize - this.entryOffset;
|
||||
if (this.debug) {
|
||||
System.err.println("TarInputStream: SKIP currENTRY '" + this.currEntry.getName() + "' SZ " + this.entrySize + " OFF " + this.entryOffset + " skipping " + l + " bytes");
|
||||
}
|
||||
if (l > 0L) {
|
||||
this.skip(l);
|
||||
}
|
||||
this.readBuf = null;
|
||||
}
|
||||
if ((byArray = this.buffer.readRecord()) == null) {
|
||||
if (this.debug) {
|
||||
System.err.println("READ NULL RECORD");
|
||||
}
|
||||
this.hasHitEOF = true;
|
||||
} else if (this.buffer.isEOFRecord(byArray)) {
|
||||
if (this.debug) {
|
||||
System.err.println("READ EOF RECORD");
|
||||
}
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
if (this.hasHitEOF) {
|
||||
this.currEntry = null;
|
||||
} else {
|
||||
try {
|
||||
this.currEntry = this.eFactory == null ? new TarEntry(byArray) : this.eFactory.createEntry(byArray);
|
||||
if (this.debug) {
|
||||
System.err.println("TarInputStream: SET CURRENTRY '" + this.currEntry.getName() + "' size = " + this.currEntry.getSize());
|
||||
}
|
||||
this.entryOffset = 0L;
|
||||
this.entrySize = this.currEntry.getSize();
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
this.entrySize = 0L;
|
||||
this.entryOffset = 0L;
|
||||
this.currEntry = null;
|
||||
throw new InvalidHeaderException("bad header in block " + this.buffer.getCurrentBlockNum() + " record " + this.buffer.getCurrentRecordNum() + ", " + invalidHeaderException.getMessage());
|
||||
}
|
||||
}
|
||||
return this.currEntry;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
int n = this.read(this.oneBuf, 0, 1);
|
||||
if (n == -1) {
|
||||
return n;
|
||||
}
|
||||
return this.oneBuf[0];
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3;
|
||||
int n4 = 0;
|
||||
if (this.entryOffset >= this.entrySize) {
|
||||
return -1;
|
||||
}
|
||||
if ((long)n2 + this.entryOffset > this.entrySize) {
|
||||
n2 = (int)(this.entrySize - this.entryOffset);
|
||||
}
|
||||
if (this.readBuf != null) {
|
||||
int n5 = n2 > this.readBuf.length ? this.readBuf.length : n2;
|
||||
System.arraycopy(this.readBuf, 0, byArray, n, n5);
|
||||
if (n5 >= this.readBuf.length) {
|
||||
this.readBuf = null;
|
||||
} else {
|
||||
n3 = this.readBuf.length - n5;
|
||||
byte[] byArray2 = new byte[n3];
|
||||
System.arraycopy(this.readBuf, n5, byArray2, 0, n3);
|
||||
this.readBuf = byArray2;
|
||||
}
|
||||
n4 += n5;
|
||||
n2 -= n5;
|
||||
n += n5;
|
||||
}
|
||||
while (n2 > 0) {
|
||||
byte[] byArray3 = this.buffer.readRecord();
|
||||
if (byArray3 == null) {
|
||||
throw new IOException("unexpected EOF with " + n2 + " bytes unread");
|
||||
}
|
||||
int n6 = byArray3.length;
|
||||
n3 = n2;
|
||||
if (n6 > n3) {
|
||||
System.arraycopy(byArray3, 0, byArray, n, n3);
|
||||
this.readBuf = new byte[n6 - n3];
|
||||
System.arraycopy(byArray3, n3, this.readBuf, 0, n6 - n3);
|
||||
} else {
|
||||
n3 = n6;
|
||||
System.arraycopy(byArray3, 0, byArray, n, n6);
|
||||
}
|
||||
n4 += n3;
|
||||
n2 -= n3;
|
||||
n += n3;
|
||||
}
|
||||
this.entryOffset += (long)n4;
|
||||
return n4;
|
||||
}
|
||||
|
||||
public void copyEntryContents(OutputStream outputStream) throws IOException {
|
||||
int n;
|
||||
byte[] byArray = new byte[32768];
|
||||
while ((n = this.read(byArray, 0, byArray.length)) != -1) {
|
||||
outputStream.write(byArray, 0, n);
|
||||
}
|
||||
}
|
||||
|
||||
public TarInputStream(InputStream inputStream) {
|
||||
this(inputStream, 10240, 512);
|
||||
}
|
||||
|
||||
public TarInputStream(InputStream inputStream, int n) {
|
||||
this(inputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarInputStream(InputStream inputStream, int n, int n2) {
|
||||
super(inputStream);
|
||||
this.buffer = new TarBuffer(inputStream, n, n2);
|
||||
this.readBuf = null;
|
||||
this.oneBuf = new byte[1];
|
||||
this.debug = false;
|
||||
this.hasHitEOF = false;
|
||||
this.eFactory = null;
|
||||
}
|
||||
|
||||
public static interface EntryFactory {
|
||||
public TarEntry createEntry(String var1);
|
||||
|
||||
public TarEntry createEntry(File var1) throws InvalidHeaderException;
|
||||
|
||||
public TarEntry createEntry(byte[] var1) throws InvalidHeaderException;
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class EntryAdapter
|
||||
implements EntryFactory {
|
||||
public TarEntry createEntry(String string) {
|
||||
return new TarEntry(string);
|
||||
}
|
||||
|
||||
public TarEntry createEntry(File file) throws InvalidHeaderException {
|
||||
return new TarEntry(file);
|
||||
}
|
||||
|
||||
public TarEntry createEntry(byte[] byArray) throws InvalidHeaderException {
|
||||
return new TarEntry(byArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarBuffer;
|
||||
import com.ice.tar.TarEntry;
|
||||
import java.io.FilterOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class TarOutputStream
|
||||
extends FilterOutputStream {
|
||||
protected boolean debug;
|
||||
protected long currSize;
|
||||
protected long currBytes;
|
||||
protected byte[] oneBuf;
|
||||
protected byte[] recordBuf;
|
||||
protected int assemLen;
|
||||
protected byte[] assemBuf;
|
||||
protected TarBuffer buffer;
|
||||
|
||||
public void setDebug(boolean bl) {
|
||||
this.debug = bl;
|
||||
}
|
||||
|
||||
public void setBufferDebug(boolean bl) {
|
||||
this.buffer.setDebug(bl);
|
||||
}
|
||||
|
||||
public void finish() throws IOException {
|
||||
this.writeEOFRecord();
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.finish();
|
||||
this.buffer.close();
|
||||
}
|
||||
|
||||
public int getRecordSize() {
|
||||
return this.buffer.getRecordSize();
|
||||
}
|
||||
|
||||
public void putNextEntry(TarEntry tarEntry) throws IOException {
|
||||
StringBuffer stringBuffer = tarEntry.getHeader().name;
|
||||
if (tarEntry.isUnixTarFormat() && stringBuffer.length() > 100 || !tarEntry.isUnixTarFormat() && stringBuffer.length() > 255) {
|
||||
throw new InvalidHeaderException("file name '" + stringBuffer + "' is too long ( " + stringBuffer.length() + " > " + (tarEntry.isUnixTarFormat() ? 100 : 255) + " bytes )");
|
||||
}
|
||||
tarEntry.writeEntryHeader(this.recordBuf);
|
||||
this.buffer.writeRecord(this.recordBuf);
|
||||
this.currBytes = 0L;
|
||||
this.currSize = tarEntry.isDirectory() ? 0L : tarEntry.getSize();
|
||||
}
|
||||
|
||||
public void closeEntry() throws IOException {
|
||||
if (this.assemLen > 0) {
|
||||
int n = this.assemLen;
|
||||
while (n < this.assemBuf.length) {
|
||||
this.assemBuf[n] = 0;
|
||||
++n;
|
||||
}
|
||||
this.buffer.writeRecord(this.assemBuf);
|
||||
this.currBytes += (long)this.assemLen;
|
||||
this.assemLen = 0;
|
||||
}
|
||||
if (this.currBytes < this.currSize) {
|
||||
throw new IOException("entry closed at '" + this.currBytes + "' before the '" + this.currSize + "' bytes specified in the header were written");
|
||||
}
|
||||
}
|
||||
|
||||
public void write(int n) throws IOException {
|
||||
this.oneBuf[0] = (byte)n;
|
||||
this.write(this.oneBuf, 0, 1);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) throws IOException {
|
||||
this.write(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.currBytes + (long)n2 > this.currSize) {
|
||||
throw new IOException("request to write '" + n2 + "' bytes exceeds size in header of '" + this.currSize + "' bytes");
|
||||
}
|
||||
if (this.assemLen > 0) {
|
||||
if (this.assemLen + n2 >= this.recordBuf.length) {
|
||||
int n3 = this.recordBuf.length - this.assemLen;
|
||||
System.arraycopy(this.assemBuf, 0, this.recordBuf, 0, this.assemLen);
|
||||
System.arraycopy(byArray, n, this.recordBuf, this.assemLen, n3);
|
||||
this.buffer.writeRecord(this.recordBuf);
|
||||
this.currBytes += (long)this.recordBuf.length;
|
||||
n += n3;
|
||||
n2 -= n3;
|
||||
this.assemLen = 0;
|
||||
} else {
|
||||
System.arraycopy(byArray, n, this.assemBuf, this.assemLen, n2);
|
||||
n += n2;
|
||||
this.assemLen += n2;
|
||||
n2 -= n2;
|
||||
}
|
||||
}
|
||||
while (n2 > 0) {
|
||||
if (n2 < this.recordBuf.length) {
|
||||
System.arraycopy(byArray, n, this.assemBuf, this.assemLen, n2);
|
||||
this.assemLen += n2;
|
||||
break;
|
||||
}
|
||||
this.buffer.writeRecord(byArray, n);
|
||||
long l = this.recordBuf.length;
|
||||
this.currBytes += l;
|
||||
n2 = (int)((long)n2 - l);
|
||||
n = (int)((long)n + l);
|
||||
}
|
||||
}
|
||||
|
||||
private final void writeEOFRecord() throws IOException {
|
||||
int n = 0;
|
||||
while (n < this.recordBuf.length) {
|
||||
this.recordBuf[n] = 0;
|
||||
++n;
|
||||
}
|
||||
this.buffer.writeRecord(this.recordBuf);
|
||||
}
|
||||
|
||||
public TarOutputStream(OutputStream outputStream) {
|
||||
this(outputStream, 10240, 512);
|
||||
}
|
||||
|
||||
public TarOutputStream(OutputStream outputStream, int n) {
|
||||
this(outputStream, n, 512);
|
||||
}
|
||||
|
||||
public TarOutputStream(OutputStream outputStream, int n, int n2) {
|
||||
super(outputStream);
|
||||
this.buffer = new TarBuffer(outputStream, n, n2);
|
||||
this.debug = false;
|
||||
this.assemLen = 0;
|
||||
this.assemBuf = new byte[n2];
|
||||
this.recordBuf = new byte[n2];
|
||||
this.oneBuf = new byte[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
public interface TarProgressDisplay {
|
||||
public void showTarProgressMessage(String var1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class TarTransFileTyper {
|
||||
public boolean isAsciiFile(File file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAsciiFile(String string) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.ice.tar;
|
||||
|
||||
import com.ice.tar.InvalidHeaderException;
|
||||
import com.ice.tar.TarArchive;
|
||||
import com.ice.tar.TarEntry;
|
||||
import com.ice.tar.TarProgressDisplay;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class tar
|
||||
implements TarProgressDisplay {
|
||||
private boolean debug = false;
|
||||
private boolean verbose = false;
|
||||
private boolean compressed = false;
|
||||
private boolean listingArchive = false;
|
||||
private boolean writingArchive = true;
|
||||
private boolean unixArchiveFormat = false;
|
||||
private boolean keepOldFiles = false;
|
||||
private boolean asciiTranslate = false;
|
||||
private String archiveName = null;
|
||||
private int blockSize = 10240;
|
||||
private int userId;
|
||||
private String userName;
|
||||
private int groupId;
|
||||
private String groupName;
|
||||
|
||||
public static void main(String[] stringArray) {
|
||||
tar tar2 = new tar();
|
||||
tar2.instanceMain(stringArray);
|
||||
}
|
||||
|
||||
public void instanceMain(String[] stringArray) {
|
||||
Object object;
|
||||
Object object2;
|
||||
TarArchive tarArchive = null;
|
||||
int n = this.processArguments(stringArray);
|
||||
if (this.writingArchive) {
|
||||
object2 = System.out;
|
||||
if (this.archiveName != null && !this.archiveName.equals("-")) {
|
||||
try {
|
||||
object2 = new FileOutputStream(this.archiveName);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
if (object2 != null) {
|
||||
if (this.compressed) {
|
||||
try {
|
||||
object2 = new GZIPOutputStream((OutputStream)object2);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
tarArchive = new TarArchive((OutputStream)object2, this.blockSize);
|
||||
}
|
||||
} else {
|
||||
object2 = System.in;
|
||||
if (this.archiveName != null && !this.archiveName.equals("-")) {
|
||||
try {
|
||||
object2 = new FileInputStream(this.archiveName);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
if (object2 != null) {
|
||||
if (this.compressed) {
|
||||
try {
|
||||
object2 = new GZIPInputStream((InputStream)object2);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
object2 = null;
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
tarArchive = new TarArchive((InputStream)object2, this.blockSize);
|
||||
}
|
||||
}
|
||||
if (tarArchive != null) {
|
||||
tarArchive.setDebug(this.debug);
|
||||
tarArchive.setVerbose(this.verbose);
|
||||
tarArchive.setTarProgressDisplay(this);
|
||||
tarArchive.setKeepOldFiles(this.keepOldFiles);
|
||||
tarArchive.setAsciiTranslation(this.asciiTranslate);
|
||||
tarArchive.setUserInfo(this.userId, this.userName, this.groupId, this.groupName);
|
||||
}
|
||||
if (tarArchive == null) {
|
||||
System.err.println("no processing due to errors");
|
||||
} else if (this.writingArchive) {
|
||||
while (n < stringArray.length) {
|
||||
try {
|
||||
object2 = new File(stringArray[n]);
|
||||
object = new TarEntry((File)object2);
|
||||
if (this.unixArchiveFormat) {
|
||||
((TarEntry)object).setUnixTarFormat();
|
||||
} else {
|
||||
((TarEntry)object).setUSTarFormat();
|
||||
}
|
||||
tarArchive.writeEntry((TarEntry)object, true);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
} else if (this.listingArchive) {
|
||||
try {
|
||||
tarArchive.listContents();
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
invalidHeaderException.printStackTrace(System.err);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
} else {
|
||||
object2 = System.getProperty("user.dir", null);
|
||||
object = new File((String)object2);
|
||||
if (!((File)object).exists()) {
|
||||
if (!((File)object).mkdirs()) {
|
||||
Throwable throwable = new Throwable("ERROR, mkdirs() on '" + ((File)object).getPath() + "' returned false.");
|
||||
throwable.printStackTrace(System.err);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
tarArchive.extractContents((File)object);
|
||||
}
|
||||
catch (InvalidHeaderException invalidHeaderException) {
|
||||
invalidHeaderException.printStackTrace(System.err);
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tarArchive != null) {
|
||||
try {
|
||||
tarArchive.closeArchive();
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
iOException.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final int processArguments(String[] stringArray) {
|
||||
int n = 0;
|
||||
boolean bl = false;
|
||||
while (n < stringArray.length) {
|
||||
String string = stringArray[n];
|
||||
if (!string.startsWith("-")) break;
|
||||
if (string.startsWith("--")) {
|
||||
if (string.equals("--usage")) {
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
} else if (string.equals("--version")) {
|
||||
this.version();
|
||||
System.exit(1);
|
||||
} else {
|
||||
System.err.println("unknown option: " + string);
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
int n2 = 1;
|
||||
while (n2 < string.length()) {
|
||||
char c = string.charAt(n2);
|
||||
if (c == '?') {
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
} else if (c == 'f') {
|
||||
this.archiveName = stringArray[++n];
|
||||
} else if (c == 'z') {
|
||||
this.compressed = true;
|
||||
} else if (c == 'c') {
|
||||
bl = true;
|
||||
this.writingArchive = true;
|
||||
this.listingArchive = false;
|
||||
} else if (c == 'x') {
|
||||
bl = true;
|
||||
this.writingArchive = false;
|
||||
this.listingArchive = false;
|
||||
} else if (c == 't') {
|
||||
bl = true;
|
||||
this.writingArchive = false;
|
||||
this.listingArchive = true;
|
||||
} else if (c == 'k') {
|
||||
this.keepOldFiles = true;
|
||||
} else if (c == 'o') {
|
||||
this.unixArchiveFormat = true;
|
||||
} else if (c == 'b') {
|
||||
try {
|
||||
int n3 = Integer.parseInt(stringArray[++n]);
|
||||
this.blockSize = n3 * 512;
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
numberFormatException.printStackTrace(System.err);
|
||||
}
|
||||
} else if (c == 'u') {
|
||||
this.userName = stringArray[++n];
|
||||
} else if (c == 'U') {
|
||||
String string2 = stringArray[++n];
|
||||
try {
|
||||
this.userId = Integer.parseInt(string2);
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
this.userId = 0;
|
||||
numberFormatException.printStackTrace(System.err);
|
||||
}
|
||||
} else if (c == 'g') {
|
||||
this.groupName = stringArray[++n];
|
||||
} else if (c == 'G') {
|
||||
String string3 = stringArray[++n];
|
||||
try {
|
||||
this.groupId = Integer.parseInt(string3);
|
||||
}
|
||||
catch (NumberFormatException numberFormatException) {
|
||||
this.groupId = 0;
|
||||
numberFormatException.printStackTrace(System.err);
|
||||
}
|
||||
} else if (c == 'v') {
|
||||
this.verbose = true;
|
||||
} else if (c == 'D') {
|
||||
this.debug = true;
|
||||
} else {
|
||||
System.err.println("unknown option: " + c);
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
++n;
|
||||
}
|
||||
if (!bl) {
|
||||
System.err.println("you must specify an operation option (c, x, or t)");
|
||||
this.usage();
|
||||
System.exit(1);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public void showTarProgressMessage(String string) {
|
||||
System.out.println(string);
|
||||
}
|
||||
|
||||
private final void version() {
|
||||
System.err.println("Release 2.4 - $Revision: 3$ $Name: $");
|
||||
}
|
||||
|
||||
private final void usage() {
|
||||
System.err.println("usage: com.ice.tar.tar has three basic modes:");
|
||||
System.err.println(" com.ice.tar -c [options] archive files...");
|
||||
System.err.println(" Create new archive containing files.");
|
||||
System.err.println(" com.ice.tar -t [options] archive");
|
||||
System.err.println(" List contents of tar archive");
|
||||
System.err.println(" com.ice.tar -x [options] archive");
|
||||
System.err.println(" Extract contents of tar archive.");
|
||||
System.err.println("");
|
||||
System.err.println("options:");
|
||||
System.err.println(" -f file, use 'file' as the tar archive");
|
||||
System.err.println(" -v, verbose mode");
|
||||
System.err.println(" -z, use GZIP compression");
|
||||
System.err.println(" -D, debug archive and buffer operation");
|
||||
System.err.println(" -b blks, set blocking size to (blks * 512) bytes");
|
||||
System.err.println(" -o, write a V7 format archive rather than ANSI");
|
||||
System.err.println(" -u name, set user name to 'name'");
|
||||
System.err.println(" -U id, set user id to 'id'");
|
||||
System.err.println(" -g name, set group name to 'name'");
|
||||
System.err.println(" -G id, set group id to 'id'");
|
||||
System.err.println(" -?, print usage information");
|
||||
System.err.println(" --trans, translate 'text/*' files");
|
||||
System.err.println(" --mime file, use this mime types file and translate");
|
||||
System.err.println(" --usage, print usage information");
|
||||
System.err.println(" --version, print version information");
|
||||
System.err.println("");
|
||||
System.err.println("The translation options will translate from local line");
|
||||
System.err.println("endings to UNIX line endings of '\\n' when writing tar");
|
||||
System.err.println("archives, and from UNIX line endings into local line endings");
|
||||
System.err.println("when extracting archives.");
|
||||
System.err.println("");
|
||||
System.err.println("Written by Tim Endres");
|
||||
System.err.println("");
|
||||
System.err.println("This software has been placed into the public domain.");
|
||||
System.err.println("");
|
||||
this.version();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public tar() {
|
||||
String string = System.getProperty("user.name");
|
||||
this.userId = 0;
|
||||
this.userName = string == null ? "" : string;
|
||||
this.groupId = 0;
|
||||
this.groupName = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BajaRuntimeException
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.ICoalesceable
|
||||
* javax.baja.util.IFuture
|
||||
* javax.baja.util.Invocation
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.CoalesceUuidOnlyInvocation;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.ICoalesceable;
|
||||
import javax.baja.util.IFuture;
|
||||
import javax.baja.util.Invocation;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmClassRouteAlarmInvocation
|
||||
extends Invocation
|
||||
implements IFuture {
|
||||
protected Exception exception;
|
||||
protected boolean finished;
|
||||
|
||||
public static AlarmClassRouteAlarmInvocation make(BComponent bComponent, Action action, BAlarmRecord bAlarmRecord, Context context) {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService.getCoalesceAlarms()) {
|
||||
return new AlarmClassRouteAlarmInvocation(bComponent, action, bAlarmRecord, context);
|
||||
}
|
||||
return new CoalesceUuidOnlyInvocation(bComponent, action, bAlarmRecord, context);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
return new AlarmClassRouteAlarmInvocation(bComponent, action, bAlarmRecord, context);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof AlarmClassRouteAlarmInvocation) {
|
||||
AlarmClassRouteAlarmInvocation alarmClassRouteAlarmInvocation = (AlarmClassRouteAlarmInvocation)((Object)object);
|
||||
if (this.argument != null) {
|
||||
boolean bl = false;
|
||||
if (this.instance == alarmClassRouteAlarmInvocation.instance && this.action == alarmClassRouteAlarmInvocation.action && ((BAlarmRecord)this.argument).getUuid().equals((Object)((BAlarmRecord)alarmClassRouteAlarmInvocation.argument).getUuid())) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.instance == alarmClassRouteAlarmInvocation.instance && this.action == alarmClassRouteAlarmInvocation.action) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICoalesceable coalesce(ICoalesceable iCoalesceable) {
|
||||
this.finished = true;
|
||||
return iCoalesceable;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void run() throws BajaRuntimeException {
|
||||
try {
|
||||
try {
|
||||
if (this.action != BAlarmClass.routeAlarm) {
|
||||
super.run();
|
||||
Object var2_1 = null;
|
||||
this.finished = true;
|
||||
return;
|
||||
}
|
||||
((BAlarmClass)this.instance).doRouteAlarm((BAlarmRecord)this.argument);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof BajaRuntimeException) {
|
||||
this.exception = (Exception)((BajaRuntimeException)exception).getCause();
|
||||
throw (BajaRuntimeException)exception;
|
||||
}
|
||||
this.exception = exception;
|
||||
throw new BajaRuntimeException((Throwable)exception);
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var2_2 = null;
|
||||
this.finished = true;
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var2_3 = null;
|
||||
this.finished = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return this.finished;
|
||||
}
|
||||
|
||||
public boolean success() throws Exception {
|
||||
if (!this.finished) {
|
||||
throw new Exception("Invocation not finished");
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.exception == null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.exception = null;
|
||||
this.finished = false;
|
||||
}
|
||||
|
||||
public AlarmClassRouteAlarmInvocation(BAlarmClass bAlarmClass, BAlarmRecord bAlarmRecord, Context context) {
|
||||
this(bAlarmClass, BAlarmClass.routeAlarm, bAlarmRecord, context);
|
||||
}
|
||||
|
||||
public AlarmClassRouteAlarmInvocation(BComponent bComponent, Action action, BAlarmRecord bAlarmRecord, Context context) {
|
||||
super(bComponent, action, (BValue)bAlarmRecord, context);
|
||||
this.this();
|
||||
if (bAlarmRecord != null) {
|
||||
this.hashCode ^= bAlarmRecord.getUuid().hashCode();
|
||||
}
|
||||
this.finished = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFacets
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.sys.BFacets;
|
||||
|
||||
public class AlarmColumnSpec {
|
||||
public final String name;
|
||||
public final String displayName;
|
||||
public final BFacets facets;
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.writeUTF(this.name);
|
||||
dataOutput.writeUTF(this.displayName);
|
||||
if (this.facets.isNull()) {
|
||||
dataOutput.writeBoolean(false);
|
||||
} else {
|
||||
dataOutput.writeBoolean(true);
|
||||
dataOutput.writeUTF(this.facets.encodeToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static AlarmColumnSpec read(DataInput dataInput) throws IOException {
|
||||
String string = dataInput.readUTF();
|
||||
String string2 = dataInput.readUTF();
|
||||
boolean bl = dataInput.readBoolean();
|
||||
BFacets bFacets = null;
|
||||
if (bl) {
|
||||
bFacets = (BFacets)BFacets.DEFAULT.decodeFromString(dataInput.readUTF());
|
||||
}
|
||||
return new AlarmColumnSpec(string, string2, bFacets);
|
||||
}
|
||||
|
||||
public AlarmColumnSpec(String string, String string2, BFacets bFacets) {
|
||||
this.name = string;
|
||||
this.displayName = string2;
|
||||
this.facets = bFacets == null ? BFacets.NULL : bFacets;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmInput {
|
||||
private DataInput in;
|
||||
private BAlarmRecord rec;
|
||||
private boolean unique;
|
||||
|
||||
public void setUniqueRecords(boolean bl) {
|
||||
this.unique = bl;
|
||||
}
|
||||
|
||||
public BAlarmRecord read() throws IOException {
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
boolean bl = this.in.readBoolean();
|
||||
if (!bl) {
|
||||
return null;
|
||||
}
|
||||
if (this.unique) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
} else {
|
||||
if (this.rec == null) {
|
||||
this.rec = new BAlarmRecord();
|
||||
}
|
||||
bAlarmRecord = this.rec;
|
||||
}
|
||||
try {
|
||||
bAlarmRecord.read(this.in);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
System.out.println("? end of input ?");
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (this.in instanceof InputStream) {
|
||||
try {
|
||||
((InputStream)((Object)this.in)).close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.unique = true;
|
||||
}
|
||||
|
||||
public AlarmInput(DataInput dataInput) throws IOException {
|
||||
this.this();
|
||||
this.in = dataInput;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmInput;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmInputCursor
|
||||
implements Cursor {
|
||||
private Context cx;
|
||||
private AlarmInput in;
|
||||
private boolean init;
|
||||
private BAlarmRecord rec;
|
||||
private boolean closeOnComplete;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public void setCloseOnComplete(boolean bl) {
|
||||
this.closeOnComplete = bl;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return this.cx;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.init) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return this.rec;
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
this.init = false;
|
||||
try {
|
||||
this.rec = this.in.read();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
if (this.closeOnComplete && this.rec == null) {
|
||||
this.in.close();
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.rec != null) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
if (this.closeOnComplete) {
|
||||
this.in.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = AlarmInputCursor.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
if (this.closeOnComplete) {
|
||||
this.in.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.init = true;
|
||||
this.closeOnComplete = true;
|
||||
}
|
||||
|
||||
public AlarmInputCursor(AlarmInput alarmInput, Context context) {
|
||||
this.this();
|
||||
this.in = alarmInput;
|
||||
this.cx = context;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BITable
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BITable;
|
||||
|
||||
public class AlarmOutput {
|
||||
private DataOutputStream out;
|
||||
|
||||
public void write(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.out.writeBoolean(true);
|
||||
bAlarmRecord.write(this.out);
|
||||
}
|
||||
|
||||
public void flush() throws IOException {
|
||||
this.out.flush();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
this.out.writeBoolean(false);
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
try {
|
||||
this.out.close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
|
||||
public AlarmOutput(BITable bITable, DataOutputStream dataOutputStream) {
|
||||
this.out = dataOutputStream;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.TableCursor
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.TableCursor;
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
public class AlarmTableCursor
|
||||
implements TableCursor {
|
||||
private BITable table;
|
||||
private Cursor inner;
|
||||
private IFilter filter;
|
||||
private Context context;
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.filter != null) ** GOTO lbl6
|
||||
return this.inner.next();
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
var1_1 = this.inner.get();
|
||||
if (!this.filter.accept((Object)var1_1)) continue;
|
||||
return true;
|
||||
lbl6:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.next())
|
||||
}
|
||||
lbl7:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean next(Class var1_1) {
|
||||
if (this.filter != null) ** GOTO lbl6
|
||||
return this.inner.next(var1_1);
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
var2_2 = this.inner.get();
|
||||
if (!this.filter.accept((Object)var2_2)) continue;
|
||||
return true;
|
||||
lbl6:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.next((Class)var1_1))
|
||||
}
|
||||
lbl7:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean nextComponent() {
|
||||
if (this.filter != null) ** GOTO lbl6
|
||||
return this.inner.nextComponent();
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
var1_1 = this.inner.get();
|
||||
if (!this.filter.accept((Object)var1_1)) continue;
|
||||
return true;
|
||||
lbl6:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.nextComponent())
|
||||
}
|
||||
lbl7:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public BITable getTable() {
|
||||
return this.table;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return this.inner.getContext();
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
return this.inner.get();
|
||||
}
|
||||
|
||||
public BObject get(Column column) {
|
||||
return ((BqlColumn)column).get(this.inner.get());
|
||||
}
|
||||
|
||||
public String getString(Column column) {
|
||||
return ((BqlColumn)column).getString(this.inner.get());
|
||||
}
|
||||
|
||||
public float getFloat(Column column) {
|
||||
return ((BqlColumn)column).getFloat(this.inner.get());
|
||||
}
|
||||
|
||||
public double getDouble(Column column) {
|
||||
return ((BqlColumn)column).getDouble(this.inner.get());
|
||||
}
|
||||
|
||||
public int getInt(Column column) {
|
||||
return ((BqlColumn)column).getInt(this.inner.get());
|
||||
}
|
||||
|
||||
public long getLong(Column column) {
|
||||
return ((BqlColumn)column).getLong(this.inner.get());
|
||||
}
|
||||
|
||||
public boolean getBoolean(Column column) {
|
||||
return ((BqlColumn)column).getBoolean(this.inner.get());
|
||||
}
|
||||
|
||||
public int getFlags(Column column) {
|
||||
return ((BqlColumn)column).getFlags(this.inner.get());
|
||||
}
|
||||
|
||||
public BFacets getFacets(Column column) {
|
||||
return ((BqlColumn)column).getFacets(this.inner.get());
|
||||
}
|
||||
|
||||
public AlarmTableCursor(BITable bITable, Cursor cursor) {
|
||||
this.table = bITable;
|
||||
this.inner = cursor;
|
||||
}
|
||||
|
||||
public AlarmTableCursor(BITable bITable, Cursor cursor, IFilter iFilter) {
|
||||
this.table = bITable;
|
||||
this.inner = cursor;
|
||||
this.filter = iFilter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.nre.util.SortUtil
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.util.BObjectArrayCursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmSource;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.nre.util.SortUtil;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.util.BObjectArrayCursor;
|
||||
|
||||
public class AlarmsToSourcesCursor
|
||||
implements Cursor {
|
||||
private Cursor alarms;
|
||||
private Cursor sources;
|
||||
|
||||
public BObject get() {
|
||||
return this.sources.get();
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return this.alarms.getContext();
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
if (this.sources == null) {
|
||||
this.sources = this.load();
|
||||
}
|
||||
return this.sources.next();
|
||||
}
|
||||
|
||||
private final Cursor load() {
|
||||
BObject[] bObjectArray;
|
||||
HashMap<BOrdList, BAlarmSource> hashMap = new HashMap<BOrdList, BAlarmSource>();
|
||||
while (this.alarms.next()) {
|
||||
bObjectArray = (BObject[])this.alarms.get();
|
||||
BOrdList bOrdList = bObjectArray.getSource();
|
||||
BAlarmSource bAlarmSource = (BAlarmSource)((Object)hashMap.get(bOrdList));
|
||||
if (bAlarmSource == null) {
|
||||
bAlarmSource = new BAlarmSource(bOrdList, (BAlarmRecord)bObjectArray.newCopy(true));
|
||||
hashMap.put(bOrdList, bAlarmSource);
|
||||
continue;
|
||||
}
|
||||
if (!bObjectArray.getTimestamp().isAfter(bAlarmSource.getCurrentAlarm().getTimestamp())) continue;
|
||||
bAlarmSource.setCurrentAlarm((BAlarmRecord)bObjectArray.newCopy(true));
|
||||
}
|
||||
bObjectArray = hashMap.values().toArray(new BAlarmSource[hashMap.size()]);
|
||||
SortUtil.sort((Object[])bObjectArray, (Object[])bObjectArray, (Comparator)new BAlarmSource.SourceComparator());
|
||||
return new BObjectArrayCursor(bObjectArray, this.alarms.getContext());
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
while (this.next()) {
|
||||
BObject bObject = this.get();
|
||||
if (!clazz.isInstance(bObject)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
while (this.next()) {
|
||||
BObject bObject = this.get();
|
||||
if (!bObject.isComponent()) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public AlarmsToSourcesCursor(Cursor cursor) {
|
||||
this.alarms = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* com.tridium.fox.message.FoxTuple
|
||||
* com.tridium.fox.session.FoxRequest
|
||||
* com.tridium.fox.session.FoxResponse
|
||||
* com.tridium.fox.session.InvalidCommandException
|
||||
* com.tridium.fox.sys.BFoxChannel
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.util.IFuture
|
||||
* javax.baja.util.Invocation
|
||||
* javax.baja.util.Queue
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.BConsoleRecipient;
|
||||
import com.tridium.alarm.fox.FoxAlarmCodec;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import com.tridium.fox.message.FoxTuple;
|
||||
import com.tridium.fox.session.FoxRequest;
|
||||
import com.tridium.fox.session.FoxResponse;
|
||||
import com.tridium.fox.session.InvalidCommandException;
|
||||
import com.tridium.fox.sys.BFoxChannel;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.util.IFuture;
|
||||
import javax.baja.util.Invocation;
|
||||
import javax.baja.util.Queue;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmConsoleChannel
|
||||
extends BFoxChannel {
|
||||
public static final Action routeAlarmAcks = BAlarmConsoleChannel.newAction((int)4, null);
|
||||
public static final Type TYPE;
|
||||
public static final Object channelMutex;
|
||||
Array newList;
|
||||
Array ackList;
|
||||
Worker worker;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
static /* synthetic */ Class class$com$tridium$fox$message$FoxMessage;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
static /* synthetic */ Class class$java$lang$String;
|
||||
|
||||
public void routeAlarmAcks() {
|
||||
this.invoke(routeAlarmAcks, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void startWorker() throws Exception {
|
||||
try {
|
||||
if (this.getConnection() != null && this.getConnection().getParentStation() == null && this.worker == null) {
|
||||
this.worker = new Worker();
|
||||
this.worker.start();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
|
||||
public void stopWorker() throws Exception {
|
||||
if (this.worker != null) {
|
||||
this.worker.kill();
|
||||
}
|
||||
this.worker = null;
|
||||
}
|
||||
|
||||
public void stopped() throws Exception {
|
||||
this.stopWorker();
|
||||
}
|
||||
|
||||
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
||||
String string = foxRequest.command;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("AlarmConsoleChannel: command = " + string);
|
||||
}
|
||||
if (string == "ack") {
|
||||
return this.ackAlarms(foxRequest);
|
||||
}
|
||||
if (string == "updateAlarm") {
|
||||
return this.updateAlarm(foxRequest);
|
||||
}
|
||||
if (string == "getInitialAlarmQuery") {
|
||||
return this.getInitialAlarmQuery(foxRequest);
|
||||
}
|
||||
if (string == "unregister") {
|
||||
return this.unregister(foxRequest);
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public void newAlarm(BConsoleRecipient bConsoleRecipient, BAlarmRecord bAlarmRecord) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorRead);
|
||||
FoxMessage foxMessage = new FoxMessage("alarmRec");
|
||||
foxMessage.add("alarm", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
String string = bConsoleRecipient.getOrdInSession().encodeToString();
|
||||
foxMessage.add("ord", string);
|
||||
this.newList.add((Object)foxMessage);
|
||||
}
|
||||
|
||||
private final FoxResponse ackAlarms(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("received: ack");
|
||||
}
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
try {
|
||||
bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
return null;
|
||||
}
|
||||
FoxTuple[] foxTupleArray = foxRequest.list("alarm");
|
||||
Class clazz = class$java$lang$String;
|
||||
if (clazz == null) {
|
||||
clazz = class$java$lang$String = BAlarmConsoleChannel.class("[Ljava.lang.String;", false);
|
||||
}
|
||||
Array array = new Array(clazz);
|
||||
int n = 0;
|
||||
while (n < foxTupleArray.length) {
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
try {
|
||||
bAlarmRecord = FoxAlarmCodec.decodeAlarm((FoxMessage)foxTupleArray[n]);
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
this.ackList.add((Object)bAlarmRecord);
|
||||
}
|
||||
catch (PermissionException permissionException) {
|
||||
bAlarmRecord.setAckState(BAckState.unacked);
|
||||
FoxMessage foxMessage = new FoxMessage("alarmRec");
|
||||
foxMessage.add("alarm", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
foxMessage.add("ord", foxRequest.getString("ord"));
|
||||
this.newList.add((Object)foxMessage);
|
||||
if (!array.contains((Object)bAlarmRecord.getAlarmClass())) {
|
||||
array.add((Object)bAlarmRecord.getAlarmClass());
|
||||
this.error(foxRequest.getString("ord"), "Cannot ack alarms from Alarm Class: " + bAlarmRecord.getAlarmClass(), (Throwable)permissionException);
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
++n;
|
||||
}
|
||||
this.routeAlarmAcks();
|
||||
return null;
|
||||
}
|
||||
|
||||
public IFuture post(Action action, BValue bValue, Context context) {
|
||||
if (action == routeAlarmAcks) {
|
||||
Queue queue = (Queue)((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).fw(601);
|
||||
queue.enqueue((Object)new Invocation((BComponent)this, action, bValue, context));
|
||||
return null;
|
||||
}
|
||||
return super.post(action, bValue, context);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Unable to fully structure code
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void doRouteAlarmAcks() {
|
||||
var1_1 = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
var2_2 = new BAlarmRecord[]{};
|
||||
var3_3 = this.ackList;
|
||||
synchronized (var3_3) {
|
||||
var2_2 = (BAlarmRecord[])this.ackList.trim();
|
||||
this.ackList.clear();
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 2] lbl8 : MonitorExitStatement: MONITOREXIT : var3_3
|
||||
var5_4 = 0;
|
||||
if (true) ** GOTO lbl34
|
||||
}
|
||||
do {
|
||||
var6_5 = var2_2[var5_4];
|
||||
try {
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("BAlarmChannel: ack -> routeAlarm: " + var6_5.getTimestamp() + ' ');
|
||||
}
|
||||
if ((var7_6 = var1_1.getAlarmDb().getRecord(var6_5.getUuid())) == null || var7_6.getAckState() != BAckState.acked) {
|
||||
var6_5.setLastUpdate(BAbsTime.now());
|
||||
var8_8 = var6_5.getAlarmData();
|
||||
if (var7_6 != null) {
|
||||
var8_8 = BFacets.make((BFacets)var6_5.getAlarmData(), (BFacets)var7_6.getAlarmData());
|
||||
}
|
||||
if ((var9_9 = var6_5.getAlarmData().gets("notes", null)) != null) {
|
||||
var8_8 = BFacets.make((BFacets)var8_8, (BFacets)BFacets.make((String)"notes", (String)var9_9));
|
||||
}
|
||||
var6_5.setAlarmData(var8_8);
|
||||
if (var7_6 != null && var6_5.getNormalTime().isBefore(var7_6.getNormalTime())) {
|
||||
var6_5.setNormalTime(var7_6.getNormalTime());
|
||||
}
|
||||
var1_1.getAlarmDb().update(var6_5);
|
||||
}
|
||||
var1_1.doAckAlarm(var6_5);
|
||||
}
|
||||
catch (Exception var7_7) {
|
||||
var7_7.printStackTrace();
|
||||
}
|
||||
++var5_4;
|
||||
lbl34:
|
||||
// 2 sources
|
||||
|
||||
} while (var5_4 < var2_2.length);
|
||||
}
|
||||
|
||||
private final FoxResponse getInitialAlarmQuery(FoxRequest foxRequest) throws Exception {
|
||||
BConsoleRecipient bConsoleRecipient;
|
||||
Object object;
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
try {
|
||||
object = (BOrd)BOrd.DEFAULT.decodeFromString(foxRequest.getString("ord"));
|
||||
bConsoleRecipient = (BConsoleRecipient)object.resolve().get();
|
||||
bConsoleRecipient.registerAlarmChannel(this);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
foxResponse.add("error", exception.toString());
|
||||
return foxResponse;
|
||||
}
|
||||
object = bConsoleRecipient.getInitialAlarmQuery(this.getSessionContext().getUser());
|
||||
foxResponse.add("query", ((String)object).toString());
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public void error(BConsoleRecipient bConsoleRecipient, String string, Throwable throwable) throws Exception {
|
||||
String string2 = bConsoleRecipient.getOrdInSession().encodeToString();
|
||||
this.error(string2, string, throwable);
|
||||
}
|
||||
|
||||
private final void error(String string, String string2, Throwable throwable) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("error");
|
||||
foxRequest.add("msg", string2);
|
||||
foxRequest.add("error", throwable.toString());
|
||||
foxRequest.add("ord", string);
|
||||
this.sendAsync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse unregister(FoxRequest foxRequest) throws Exception {
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
try {
|
||||
BOrd bOrd = (BOrd)BOrd.DEFAULT.decodeFromString(foxRequest.getString("ord"));
|
||||
BConsoleRecipient bConsoleRecipient = (BConsoleRecipient)bOrd.resolve().get();
|
||||
bConsoleRecipient.unregisterAlarmChannel(this);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
foxResponse.add("error", exception.toString());
|
||||
}
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
private final FoxResponse updateAlarm(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService;
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("received: updateAlarm");
|
||||
}
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
try {
|
||||
bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
foxResponse.add("error", "Could not find AlarmService");
|
||||
return foxResponse;
|
||||
}
|
||||
String string = "";
|
||||
try {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(foxRequest.getMessage("alarm"));
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
if (this.isTraceOn()) {
|
||||
this.trace("BAlarmChannel: ack -> updateAlarm: " + bAlarmRecord.getTimestamp() + ' ' + (Object)((Object)bAlarmRecord.getSourceState()) + ' ' + bAlarmRecord.getAlarmClass());
|
||||
}
|
||||
bAlarmRecord.setLastUpdate(BAbsTime.now());
|
||||
bAlarmService.routeAlarm(bAlarmRecord);
|
||||
bAlarmService.doRouteToSource((BAlarmRecord)bAlarmRecord.newCopy());
|
||||
}
|
||||
catch (PermissionException permissionException) {
|
||||
foxResponse.add("error", "Invalid Permissions: " + (Object)((Object)permissionException));
|
||||
this.error(foxRequest.getString("ord"), "Cannot update alarms from Alarm Class: " + string, (Throwable)permissionException);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
foxResponse.add("error", "Could Not Route Alarm Update Request");
|
||||
}
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmConsoleChannel() {
|
||||
this("alarmui");
|
||||
}
|
||||
|
||||
protected BAlarmConsoleChannel(String string) {
|
||||
super(string);
|
||||
Class clazz = class$com$tridium$fox$message$FoxMessage;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$fox$message$FoxMessage = BAlarmConsoleChannel.class("[Lcom.tridium.fox.message.FoxMessage;", false);
|
||||
}
|
||||
this.newList = new Array(clazz);
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BAlarmConsoleChannel.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
this.ackList = new Array(clazz2);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmConsoleChannel = BAlarmConsoleChannel.class("[Lcom.tridium.alarm.BAlarmConsoleChannel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
channelMutex = new Object();
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Worker
|
||||
implements Runnable {
|
||||
public static final int WORKER_SLEEP = 1000;
|
||||
private boolean isAlive;
|
||||
private Thread thread;
|
||||
|
||||
public void start() {
|
||||
this.isAlive = true;
|
||||
this.thread = new Thread(this, "AlarmConsoleChannel:Worker");
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
public void kill() {
|
||||
this.isAlive = false;
|
||||
if (this.thread != null) {
|
||||
this.thread.interrupt();
|
||||
}
|
||||
this.thread = null;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (this.isAlive) {
|
||||
try {
|
||||
int n;
|
||||
Thread.sleep(1000L);
|
||||
FoxMessage[] foxMessageArray = this.getNewAlarms();
|
||||
int n2 = 100;
|
||||
int n3 = 0;
|
||||
int n4 = n = n2 < foxMessageArray.length ? n2 : foxMessageArray.length;
|
||||
if (foxMessageArray.length <= 0) continue;
|
||||
while (n3 < foxMessageArray.length) {
|
||||
FoxRequest foxRequest = BAlarmConsoleChannel.this.makeRequest("new");
|
||||
int n5 = n3;
|
||||
while (n5 < n) {
|
||||
foxRequest.add("alarmRec", foxMessageArray[n5]);
|
||||
++n5;
|
||||
}
|
||||
BAlarmConsoleChannel.this.sendAsync(foxRequest);
|
||||
n3 = n;
|
||||
int n6 = n = (n += n2) < foxMessageArray.length ? n : foxMessageArray.length;
|
||||
}
|
||||
}
|
||||
catch (InterruptedException interruptedException) {
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final synchronized FoxMessage[] getNewAlarms() {
|
||||
FoxMessage[] foxMessageArray = new FoxMessage[]{};
|
||||
Array array = BAlarmConsoleChannel.this.newList;
|
||||
synchronized (array) {
|
||||
foxMessageArray = (FoxMessage[])BAlarmConsoleChannel.this.newList.trim();
|
||||
BAlarmConsoleChannel.this.newList.clear();
|
||||
return foxMessageArray;
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.isAlive = true;
|
||||
}
|
||||
|
||||
Worker() {
|
||||
this.this();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.job.BJob
|
||||
* javax.baja.job.BJobState
|
||||
* javax.baja.job.JobCancelException
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BVector
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.alarm.ext.BAlarmSourceExt;
|
||||
import javax.baja.job.BJob;
|
||||
import javax.baja.job.BJobState;
|
||||
import javax.baja.job.JobCancelException;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BVector;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmExtStatusJob
|
||||
extends BJob {
|
||||
public static final Type TYPE;
|
||||
private static final int BATCH_SIZE = 20;
|
||||
BAlarmService alarmService;
|
||||
BVector extOrds;
|
||||
BAlarmTransitionBits bits;
|
||||
boolean enableExt;
|
||||
boolean canceled;
|
||||
JobThread thread;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmExtStatusJob;
|
||||
static /* synthetic */ Class class$javax$baja$naming$BOrd;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void doRun(Context context) {
|
||||
this.thread = new JobThread(this.toPathString(), context);
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public void run(Context var1_1) throws Exception {
|
||||
if (this.alarmService == null) {
|
||||
throw new IllegalStateException("Must submit thru AlarmService.enable/disableExtensions()");
|
||||
}
|
||||
if (this.canceled) {
|
||||
throw new JobCancelException();
|
||||
}
|
||||
var2_2 = true;
|
||||
var3_3 = this.enableExt != false ? "Enabling" : "Disabling";
|
||||
this.log().start(var3_3 + " Selected Alarm Extensions");
|
||||
var4_4 = 0;
|
||||
var5_5 = this.extOrds.getSlotCount();
|
||||
if (var5_5 <= 0) {
|
||||
var5_5 = 1;
|
||||
}
|
||||
var6_6 = this.extOrds.getProperties();
|
||||
if (true) ** GOTO lbl28
|
||||
do {
|
||||
if (var4_4 % 20 == 0) {
|
||||
this.progress((int)((float)var4_4 / (float)var5_5 * 100.0f));
|
||||
}
|
||||
++var4_4;
|
||||
var7_7 = (BOrd)var6_6.get();
|
||||
var8_8 = null;
|
||||
try {
|
||||
var8_8 = (BAlarmSourceExt)var7_7.resolve((BObject)this.alarmService).get();
|
||||
var8_8.setAlarmEnable(BAlarmTransitionBits.make(var8_8.getAlarmEnable(), this.bits, this.enableExt));
|
||||
}
|
||||
catch (Exception var9_9) {
|
||||
this.log().failed(" Encountered Problem " + var3_3 + ' ' + (var8_8 != null ? var8_8.getName() : "an unknown alarm extension. "), (Throwable)var9_9);
|
||||
var2_2 = false;
|
||||
}
|
||||
if (this.canceled) break;
|
||||
lbl28:
|
||||
// 2 sources
|
||||
|
||||
if ((v0 = BAlarmExtStatusJob.class$javax$baja$naming$BOrd) != null) continue;
|
||||
v0 = BAlarmExtStatusJob.class("[Ljavax.baja.naming.BOrd;", false);
|
||||
} while (var6_6.next(v0));
|
||||
if (this.canceled) {
|
||||
throw new JobCancelException();
|
||||
}
|
||||
if (var2_2) {
|
||||
this.log().success(var3_3 + " Selected Alarm Extensions Complete");
|
||||
} else {
|
||||
this.log().failed("Encountered Problems " + var3_3 + " Selected Alarm Extensions");
|
||||
}
|
||||
}
|
||||
|
||||
public void doCancel(Context context) {
|
||||
this.canceled = true;
|
||||
if (this.getJobState().isRunning()) {
|
||||
this.setJobState(BJobState.canceling);
|
||||
if (this.thread != null) {
|
||||
this.thread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.canceled = false;
|
||||
}
|
||||
|
||||
public BAlarmExtStatusJob(BAlarmService bAlarmService, BVector bVector, BAlarmTransitionBits bAlarmTransitionBits, boolean bl) {
|
||||
this.this();
|
||||
this.alarmService = bAlarmService;
|
||||
this.extOrds = bVector;
|
||||
this.enableExt = bl;
|
||||
this.bits = bAlarmTransitionBits;
|
||||
}
|
||||
|
||||
public BAlarmExtStatusJob() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmExtStatusJob;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmExtStatusJob = BAlarmExtStatusJob.class("[Lcom.tridium.alarm.BAlarmExtStatusJob;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
class JobThread
|
||||
extends Thread {
|
||||
Context cx;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
BAlarmExtStatusJob.this.run(this.cx);
|
||||
BAlarmExtStatusJob.this.success();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
BAlarmExtStatusJob.this.failed(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
JobThread(String string, Context context) {
|
||||
super(string);
|
||||
this.cx = context;
|
||||
this.setPriority(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* com.tridium.bql.collection.BqlColumnList
|
||||
* com.tridium.bql.collection.PropertyColumn
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BIList
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmColumnSpec;
|
||||
import com.tridium.alarm.AlarmInput;
|
||||
import com.tridium.alarm.AlarmInputCursor;
|
||||
import com.tridium.alarm.AlarmTableCursor;
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import com.tridium.bql.collection.BqlColumnList;
|
||||
import com.tridium.bql.collection.PropertyColumn;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BIList;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmInputTable
|
||||
extends BObject
|
||||
implements BITable {
|
||||
public static final Type TYPE;
|
||||
private AlarmColumnSpec[] projection;
|
||||
private ColumnList columns;
|
||||
private AlarmInput in;
|
||||
private ArrayList recs;
|
||||
private boolean gotCursor;
|
||||
private BFacets tableFacets;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmInputTable;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Cursor cursor() {
|
||||
Object object = null;
|
||||
if (this.gotCursor && this.recs == null) {
|
||||
throw new IllegalStateException("Cursor has already been used.");
|
||||
}
|
||||
if (!this.gotCursor) {
|
||||
this.gotCursor = true;
|
||||
object = new AlarmInputCursor(this.in, null);
|
||||
} else {
|
||||
object = new RecCursor(this.recs, null);
|
||||
}
|
||||
return new AlarmTableCursor(this, (Cursor)object);
|
||||
}
|
||||
|
||||
public BIList toList() {
|
||||
this.load();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BITable toTable() {
|
||||
this.load();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
this.load();
|
||||
return this.recs.size();
|
||||
}
|
||||
|
||||
public BObject[] list() {
|
||||
this.load();
|
||||
return this.recs.toArray(new BObject[this.recs.size()]);
|
||||
}
|
||||
|
||||
public BObject[] list(BObject[] bObjectArray) {
|
||||
this.load();
|
||||
return this.recs.toArray(bObjectArray);
|
||||
}
|
||||
|
||||
public BObject get(int n) {
|
||||
return (BObject)this.recs.get(n);
|
||||
}
|
||||
|
||||
public ColumnList getColumns() {
|
||||
if (this.columns == null) {
|
||||
if (this.projection != null) {
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[this.projection.length];
|
||||
int n = 0;
|
||||
while (n < bqlColumnArray.length) {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
bqlColumnArray[n] = new PropertyColumn(bAlarmRecord.getProperty(this.projection[n].name));
|
||||
++n;
|
||||
}
|
||||
return new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
Property[] propertyArray = bAlarmRecord.getPropertiesArray();
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[propertyArray.length];
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
Property property = propertyArray[n];
|
||||
Object var6_9 = null;
|
||||
bqlColumnArray[n] = new PropertyColumn(propertyArray[n]);
|
||||
++n;
|
||||
}
|
||||
this.columns = new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
return this.columns;
|
||||
}
|
||||
|
||||
public BObject get(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).get((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public String getString(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getString((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public float getFloat(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFloat((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public double getDouble(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getDouble((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getInt(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getInt((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public long getLong(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getLong((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public boolean getBoolean(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getBoolean((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getFlags(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFlags((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getFacets(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFacets((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getTableFacets() {
|
||||
return this.tableFacets;
|
||||
}
|
||||
|
||||
private final void load() {
|
||||
if (this.recs != null) {
|
||||
return;
|
||||
}
|
||||
this.recs = new ArrayList(1000);
|
||||
Cursor cursor = this.cursor();
|
||||
while (cursor.next()) {
|
||||
this.recs.add(cursor.get());
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.gotCursor = false;
|
||||
this.tableFacets = BFacets.NULL;
|
||||
}
|
||||
|
||||
public BAlarmInputTable(AlarmColumnSpec[] alarmColumnSpecArray, AlarmInput alarmInput) {
|
||||
this.this();
|
||||
this.projection = alarmColumnSpecArray;
|
||||
this.in = alarmInput;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmInputTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmInputTable = BAlarmInputTable.class("[Lcom.tridium.alarm.BAlarmInputTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class RecCursor
|
||||
implements Cursor {
|
||||
ArrayList recs;
|
||||
Context cx;
|
||||
int index;
|
||||
|
||||
public Context getContext() {
|
||||
return this.cx;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.index == -1) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return (BObject)this.recs.get(this.index);
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
if (this.index == this.recs.size()) {
|
||||
return false;
|
||||
}
|
||||
++this.index;
|
||||
boolean bl = false;
|
||||
if (this.index != this.recs.size()) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.index = this.recs.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BAlarmInputTable.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
this.index = this.recs.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
public RecCursor(ArrayList arrayList, Context context) {
|
||||
this.recs = arrayList;
|
||||
this.cx = context;
|
||||
this.index = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.util.BDynamicTimeRange
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.user.BUserService
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmsToSourcesCursor;
|
||||
import com.tridium.alarm.BAlarmConsoleChannel;
|
||||
import com.tridium.bql.util.BDynamicTimeRange;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.user.BUserService;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BConsoleRecipient
|
||||
extends BAlarmRecipient {
|
||||
public static final Property transitions = BConsoleRecipient.newProperty((int)0, (BValue)BAlarmTransitionBits.ALL, (BFacets)BFacets.make((String[])new String[]{"showNormal"}, (BIDataValue[])new BBoolean[]{BBoolean.FALSE}));
|
||||
public static final Property routeAcks = BConsoleRecipient.newProperty((int)1, (boolean)true, null);
|
||||
public static final Property defaultTimeRange = BConsoleRecipient.newProperty((int)0, (BValue)BDynamicTimeRange.DEFAULT, null);
|
||||
public static final Type TYPE;
|
||||
public static final Log logger;
|
||||
private static final BIcon icon;
|
||||
Array channels;
|
||||
private Map channelUsageCounts;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BConsoleRecipient;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
static /* synthetic */ Class class$javax$baja$user$BUser;
|
||||
|
||||
public BAlarmTransitionBits getTransitions() {
|
||||
return (BAlarmTransitionBits)this.get(transitions);
|
||||
}
|
||||
|
||||
public void setTransitions(BAlarmTransitionBits bAlarmTransitionBits) {
|
||||
this.set(transitions, (BValue)bAlarmTransitionBits, null);
|
||||
}
|
||||
|
||||
public boolean getRouteAcks() {
|
||||
return this.getBoolean(routeAcks);
|
||||
}
|
||||
|
||||
public void setRouteAcks(boolean bl) {
|
||||
this.setBoolean(routeAcks, bl, null);
|
||||
}
|
||||
|
||||
public BDynamicTimeRange getDefaultTimeRange() {
|
||||
return (BDynamicTimeRange)this.get(defaultTimeRange);
|
||||
}
|
||||
|
||||
public void setDefaultTimeRange(BDynamicTimeRange bDynamicTimeRange) {
|
||||
this.set(defaultTimeRange, (BValue)bDynamicTimeRange, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void handleAlarm(BAlarmRecord bAlarmRecord) {
|
||||
logger.trace("BConsoleRecipient.handleAlarm: " + (Object)((Object)bAlarmRecord.getSourceState()));
|
||||
int n = 0;
|
||||
while (n < this.channels.size()) {
|
||||
try {
|
||||
BAlarmConsoleChannel bAlarmConsoleChannel = (BAlarmConsoleChannel)((Object)this.channels.get(n));
|
||||
bAlarmConsoleChannel.newAlarm(this, bAlarmRecord);
|
||||
}
|
||||
catch (PermissionException permissionException) {
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void registerAlarmChannel(BAlarmConsoleChannel bAlarmConsoleChannel) {
|
||||
block6: {
|
||||
Map map = this.channelUsageCounts;
|
||||
synchronized (map) {
|
||||
Integer n;
|
||||
block5: {
|
||||
n = (Integer)this.channelUsageCounts.get((Object)bAlarmConsoleChannel);
|
||||
if (n != null) break block5;
|
||||
this.channelUsageCounts.put(bAlarmConsoleChannel, new Integer(1));
|
||||
break block6;
|
||||
}
|
||||
n = new Integer(n + 1);
|
||||
this.channelUsageCounts.put(bAlarmConsoleChannel, n);
|
||||
}
|
||||
}
|
||||
if (this.channels.contains((Object)bAlarmConsoleChannel)) return;
|
||||
this.channels.add((Object)bAlarmConsoleChannel);
|
||||
try {
|
||||
bAlarmConsoleChannel.startWorker();
|
||||
return;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void unregisterAlarmChannel(BAlarmConsoleChannel bAlarmConsoleChannel) {
|
||||
try {
|
||||
Map map = this.channelUsageCounts;
|
||||
synchronized (map) {
|
||||
block6: {
|
||||
Integer n;
|
||||
block5: {
|
||||
n = (Integer)this.channelUsageCounts.get((Object)bAlarmConsoleChannel);
|
||||
if (n == null) return;
|
||||
if ((n = new Integer(n - 1)) != 0) break block5;
|
||||
this.channelUsageCounts.remove((Object)bAlarmConsoleChannel);
|
||||
this.channels.remove((Object)bAlarmConsoleChannel);
|
||||
bAlarmConsoleChannel.stopWorker();
|
||||
break block6;
|
||||
}
|
||||
this.channelUsageCounts.put(bAlarmConsoleChannel, n);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarmSources(Context context) {
|
||||
return new AlarmsToSourcesCursor(this.getOpenAlarms(context));
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms(Context context) {
|
||||
String string = this.getInitialAlarmQuery(context);
|
||||
return ((BICollection)BOrd.make((String)string).resolve((BObject)this).get()).cursor();
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(Context context) {
|
||||
BUserService bUserService;
|
||||
BUser bUser = null;
|
||||
if (context != null) {
|
||||
bUser = context.getUser();
|
||||
}
|
||||
if (bUser == null && !(bUser = (bUserService = (BUserService)Sys.getService((Type)BUserService.TYPE)).getAdmin()).getEnabled()) {
|
||||
Class clazz = class$javax$baja$user$BUser;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$user$BUser = BConsoleRecipient.class("[Ljavax.baja.user.BUser;", false);
|
||||
}
|
||||
BUser[] bUserArray = (BUser[])bUserService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bUserArray.length) {
|
||||
if (bUserArray[n].getEnabled() && bUserArray[n].getPermissions().isSuperUser()) {
|
||||
bUser = bUserArray[n];
|
||||
break;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return this.getInitialAlarmQuery(bUser);
|
||||
}
|
||||
|
||||
public String getInitialAlarmQuery(BUser bUser) {
|
||||
String string;
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
String[] stringArray = this.getSubscribedAlarmClasses();
|
||||
StringBuffer stringBuffer = new StringBuffer("alarm:|bql:select * from openAlarms");
|
||||
int n = 0;
|
||||
StringBuffer stringBuffer2 = new StringBuffer();
|
||||
int n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
} else {
|
||||
stringBuffer2.append("(");
|
||||
}
|
||||
++n;
|
||||
stringBuffer2.append("alarmClass = '" + SlotPath.escape((String)string) + '\'');
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(")");
|
||||
}
|
||||
stringArray = this.getSubscribedEscalatedAlarmClasses(1);
|
||||
n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
}
|
||||
stringBuffer2.append("(alarmClass = '" + SlotPath.escape((String)string) + "' and (alarmData." + BAlarmClass.ESCALATED + " != null and alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_3 + "' or alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_2 + "' or alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_1 + "'))");
|
||||
++n;
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
stringArray = this.getSubscribedEscalatedAlarmClasses(2);
|
||||
n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
}
|
||||
stringBuffer2.append("(alarmClass = '" + SlotPath.escape((String)string) + "' and (alarmData." + BAlarmClass.ESCALATED + " != null and alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_3 + "' or alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_2 + "'))");
|
||||
++n;
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
stringArray = this.getSubscribedEscalatedAlarmClasses(3);
|
||||
n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
try {
|
||||
string = stringArray[n2];
|
||||
bUser.check((BIProtected)bAlarmService.lookupAlarmClass(string), BPermissions.operatorRead);
|
||||
if (n > 0) {
|
||||
stringBuffer2.append(" or ");
|
||||
}
|
||||
stringBuffer2.append("(alarmClass = '" + SlotPath.escape((String)string) + "' and alarmData." + BAlarmClass.ESCALATED + " != null and alarmData." + BAlarmClass.ESCALATED + " = '" + BAlarmClass.LEVEL_3 + "')");
|
||||
++n;
|
||||
}
|
||||
catch (PermissionException permissionException) {}
|
||||
++n2;
|
||||
}
|
||||
if (stringBuffer2.length() > 0) {
|
||||
stringBuffer.append(" where (");
|
||||
stringBuffer.append(stringBuffer2.toString() + ')');
|
||||
} else {
|
||||
stringBuffer.append(" where alarmClass = 'null'");
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
Class clazz = class$com$tridium$alarm$BAlarmConsoleChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BAlarmConsoleChannel = BConsoleRecipient.class("[Lcom.tridium.alarm.BAlarmConsoleChannel;", false);
|
||||
}
|
||||
this.channels = new Array(clazz);
|
||||
this.channelUsageCounts = new HashMap();
|
||||
}
|
||||
|
||||
public BConsoleRecipient() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BConsoleRecipient;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BConsoleRecipient = BConsoleRecipient.class("[Lcom.tridium.alarm.BConsoleRecipient;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
logger = Log.getLog((String)"alarm");
|
||||
icon = BIcon.make((BIcon)BIcon.std((String)"computer.png"), (BIcon)BIcon.std((String)"badges/alarm.png"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BIAlarmSource;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIUpdatableAlarmSource
|
||||
extends BIAlarmSource {
|
||||
public static final Type TYPE;
|
||||
|
||||
public void updateAlarm(BAlarmRecord var1);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$com$tridium$alarm$BIUpdatableAlarmSource;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$com$tridium$alarm$BIUpdatableAlarmSource = 1.class("[Lcom.tridium.alarm.BIUpdatableAlarmSource;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.units.BDimension
|
||||
* javax.baja.units.BUnit
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.db.memory.BMemoryAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.units.BDimension;
|
||||
import javax.baja.units.BUnit;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BMemoryAlarmService
|
||||
extends BAlarmService {
|
||||
public static final Property capacity = BMemoryAlarmService.newProperty((int)0, (int)500, (BFacets)BFacets.makeInt((BUnit)BUnit.make((String)"records", (BDimension)BDimension.DEFAULT), (int)1, (int)5000));
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BMemoryAlarmService;
|
||||
|
||||
public int getCapacity() {
|
||||
return this.getInt(capacity);
|
||||
}
|
||||
|
||||
public void setCapacity(int n) {
|
||||
this.setInt(capacity, n, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected BAlarmDatabase createAlarmDb() {
|
||||
return new BMemoryAlarmDatabase();
|
||||
}
|
||||
|
||||
public void changed(Property property, Context context) {
|
||||
if (property.equals((Object)capacity)) {
|
||||
BAlarmDatabase bAlarmDatabase = this.getAlarmDb();
|
||||
if (bAlarmDatabase != null && bAlarmDatabase instanceof BMemoryAlarmDatabase) {
|
||||
try {
|
||||
((BMemoryAlarmDatabase)bAlarmDatabase).setCapacity(this.getCapacity());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
logger.error("Cannot change database capacity to " + this.getCapacity() + '.', (Throwable)exception);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.changed(property, context);
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BMemoryAlarmService;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BMemoryAlarmService = BMemoryAlarmService.class("[Lcom.tridium.alarm.BMemoryAlarmService;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.NiagaraNetwork
|
||||
* com.tridium.fox.sys.NiagaraStation
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BIcon
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.Lexicon
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.fox.sys.NiagaraNetwork;
|
||||
import com.tridium.fox.sys.NiagaraStation;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmTransitionBits;
|
||||
import javax.baja.alarm.BIRemoteAlarmRecipient;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BStationRecipient
|
||||
extends BAlarmRecipient {
|
||||
public static final Property transitions = BStationRecipient.newProperty((int)0, (BValue)BAlarmTransitionBits.ALL, (BFacets)BFacets.make((String[])new String[]{"showNormal"}, (BIDataValue[])new BBoolean[]{BBoolean.FALSE}));
|
||||
public static final Property routeAcks = BStationRecipient.newProperty((int)1, (boolean)true, null);
|
||||
public static final Property remoteStation = BStationRecipient.newProperty((int)0, (String)"", (BFacets)BFacets.make((String)"fieldEditor", (BIDataValue)BString.make((String)"alarm:RemoteStationFE")));
|
||||
public static final Type TYPE;
|
||||
public static final Lexicon lex;
|
||||
private static final BIcon icon;
|
||||
private static final Log log;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BStationRecipient;
|
||||
|
||||
public BAlarmTransitionBits getTransitions() {
|
||||
return (BAlarmTransitionBits)this.get(transitions);
|
||||
}
|
||||
|
||||
public void setTransitions(BAlarmTransitionBits bAlarmTransitionBits) {
|
||||
this.set(transitions, (BValue)bAlarmTransitionBits, null);
|
||||
}
|
||||
|
||||
public boolean getRouteAcks() {
|
||||
return this.getBoolean(routeAcks);
|
||||
}
|
||||
|
||||
public void setRouteAcks(boolean bl) {
|
||||
this.setBoolean(routeAcks, bl, null);
|
||||
}
|
||||
|
||||
public String getRemoteStation() {
|
||||
return this.getString(remoteStation);
|
||||
}
|
||||
|
||||
public void setRemoteStation(String string) {
|
||||
this.setString(remoteStation, string, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void handleAlarm(BAlarmRecord bAlarmRecord) {
|
||||
try {
|
||||
BIRemoteAlarmRecipient bIRemoteAlarmRecipient = this.getAlarmDeviceExt();
|
||||
if (bIRemoteAlarmRecipient == null) {
|
||||
return;
|
||||
}
|
||||
bIRemoteAlarmRecipient.routeAlarm(bAlarmRecord);
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
}
|
||||
|
||||
private final NiagaraStation getStation() throws Exception {
|
||||
Type type = Sys.getType((String)"niagaraDriver:NiagaraNetwork");
|
||||
NiagaraNetwork niagaraNetwork = (NiagaraNetwork)Sys.getService((Type)type);
|
||||
BComponent bComponent = (BComponent)niagaraNetwork.getStation(this.getRemoteStation());
|
||||
if (bComponent == null) {
|
||||
log.error(this.getName() + ": Station '" + this.getRemoteStation() + "' not Configured in the Database");
|
||||
throw new Exception("Station '" + this.getRemoteStation() + "' not Configured in the Database");
|
||||
}
|
||||
return (NiagaraStation)bComponent;
|
||||
}
|
||||
|
||||
private final BIRemoteAlarmRecipient getAlarmDeviceExt() throws Exception {
|
||||
BComponent bComponent = (BComponent)this.getStation();
|
||||
if (!((BBoolean)bComponent.get("enabled")).getBoolean()) {
|
||||
return null;
|
||||
}
|
||||
return (BIRemoteAlarmRecipient)bComponent.get("alarms");
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BStationRecipient;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BStationRecipient = BStationRecipient.class("[Lcom.tridium.alarm.BStationRecipient;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
lex = Lexicon.make((String)"baja");
|
||||
icon = BIcon.make((BIcon)BIcon.std((String)"device.png"), (BIcon)BIcon.std((String)"badges/alarm.png"));
|
||||
log = Log.getLog((String)"alarm");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BFormat
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.BTextOp;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BFormat;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BTextCustomizer
|
||||
extends BComponent {
|
||||
public static final Property op = BTextCustomizer.newProperty((int)0, (BValue)BTextOp.useExisting, null);
|
||||
public static final Property text = BTextCustomizer.newProperty((int)0, (BValue)BFormat.make((String)""), null);
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BTextCustomizer;
|
||||
|
||||
public BTextOp getOp() {
|
||||
return (BTextOp)this.get(op);
|
||||
}
|
||||
|
||||
public void setOp(BTextOp bTextOp) {
|
||||
this.set(op, (BValue)bTextOp, null);
|
||||
}
|
||||
|
||||
public BFormat getText() {
|
||||
return (BFormat)this.get(text);
|
||||
}
|
||||
|
||||
public void setText(BFormat bFormat) {
|
||||
this.set(text, (BValue)bFormat, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public String customize(String string) {
|
||||
switch (this.getOp().getOrdinal()) {
|
||||
case 1: {
|
||||
return this.getText().format((Object)this) + string;
|
||||
}
|
||||
case 2: {
|
||||
return string + this.getText().format((Object)this);
|
||||
}
|
||||
case 3: {
|
||||
return this.getText().format((Object)this);
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BTextCustomizer() {
|
||||
}
|
||||
|
||||
public BTextCustomizer(BTextOp bTextOp, BFormat bFormat) {
|
||||
this.setOp(bTextOp);
|
||||
this.setText(bFormat);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BTextCustomizer;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BTextCustomizer = BTextCustomizer.class("[Lcom.tridium.alarm.BTextCustomizer;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BFrozenEnum
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.sys.BFrozenEnum;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BTextOp
|
||||
extends BFrozenEnum {
|
||||
public static final int USE_EXISTING = 0;
|
||||
public static final int PREPEND = 1;
|
||||
public static final int APPEND = 2;
|
||||
public static final int REPLACE = 3;
|
||||
public static final BTextOp useExisting = new BTextOp(0);
|
||||
public static final BTextOp prepend = new BTextOp(1);
|
||||
public static final BTextOp append = new BTextOp(2);
|
||||
public static final BTextOp replace = new BTextOp(3);
|
||||
public static final Type TYPE;
|
||||
public static final BTextOp DEFAULT;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$BTextOp;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static final BTextOp make(int n) {
|
||||
return (BTextOp)useExisting.getRange().get(n, false);
|
||||
}
|
||||
|
||||
public static final BTextOp make(String string) {
|
||||
return (BTextOp)useExisting.getRange().get(string);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private BTextOp(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$BTextOp;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$BTextOp = BTextOp.class("[Lcom.tridium.alarm.BTextOp;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
DEFAULT = useExisting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import com.tridium.alarm.AlarmClassRouteAlarmInvocation;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
class CoalesceUuidOnlyInvocation
|
||||
extends AlarmClassRouteAlarmInvocation {
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof CoalesceUuidOnlyInvocation) {
|
||||
CoalesceUuidOnlyInvocation coalesceUuidOnlyInvocation = (CoalesceUuidOnlyInvocation)((Object)object);
|
||||
if (this.argument != null) {
|
||||
boolean bl = false;
|
||||
if (this.instance == coalesceUuidOnlyInvocation.instance && this.action == coalesceUuidOnlyInvocation.action && ((BAlarmRecord)this.argument).getUuid().equals((Object)((BAlarmRecord)coalesceUuidOnlyInvocation.argument).getUuid()) && ((BAlarmRecord)this.argument).getSourceState().equals((Object)((BAlarmRecord)coalesceUuidOnlyInvocation.argument).getSourceState())) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.instance == coalesceUuidOnlyInvocation.instance && this.action == coalesceUuidOnlyInvocation.action) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CoalesceUuidOnlyInvocation(BComponent bComponent, Action action, BAlarmRecord bAlarmRecord, Context context) {
|
||||
super(bComponent, action, bAlarmRecord, context);
|
||||
if (bAlarmRecord != null) {
|
||||
this.hashCode ^= bAlarmRecord.getSourceState().hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
*/
|
||||
package com.tridium.alarm;
|
||||
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
|
||||
public class FilterCursor
|
||||
implements Cursor {
|
||||
private IFilter filter;
|
||||
private Cursor inner;
|
||||
|
||||
public Context getContext() {
|
||||
return this.inner.getContext();
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
return this.inner.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.filter != null) ** GOTO lbl5
|
||||
return this.inner.next();
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
if (!this.filter.accept((Object)this.inner.get())) continue;
|
||||
return true;
|
||||
lbl5:
|
||||
// 2 sources
|
||||
|
||||
** while (this.inner.next())
|
||||
}
|
||||
lbl6:
|
||||
// 1 sources
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
return this.inner.next(clazz);
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
return this.inner.nextComponent();
|
||||
}
|
||||
|
||||
public FilterCursor(IFilter iFilter, Cursor cursor) {
|
||||
this.filter = iFilter;
|
||||
this.inner = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.status.BIStatus
|
||||
* javax.baja.status.BStatus
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Clock$Ticket
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Topic
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
* javax.baja.util.IFuture
|
||||
* javax.baja.util.Invocation
|
||||
* javax.baja.util.Queue
|
||||
* javax.baja.util.Worker
|
||||
* javax.baja.util.Worker$ITodo
|
||||
*/
|
||||
package com.tridium.alarm.ack;
|
||||
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.status.BIStatus;
|
||||
import javax.baja.status.BStatus;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Topic;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
import javax.baja.util.IFuture;
|
||||
import javax.baja.util.Invocation;
|
||||
import javax.baja.util.Queue;
|
||||
import javax.baja.util.Worker;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAlarmAcknowledger
|
||||
extends BComponent
|
||||
implements BIStatus {
|
||||
public static final Property status = BAlarmAcknowledger.newProperty((int)2051, (BValue)BStatus.ok, null);
|
||||
public static final Property enabled = BAlarmAcknowledger.newProperty((int)0, (boolean)true, null);
|
||||
public static final Property ackAlarmsFromSameSource = BAlarmAcknowledger.newProperty((int)0, (boolean)true, null);
|
||||
public static final Property lastAlarmAcked = BAlarmAcknowledger.newProperty((int)2115, (String)"", null);
|
||||
public static final Property lastAlarmAckedTime = BAlarmAcknowledger.newProperty((int)2115, (BValue)BAbsTime.NULL, null);
|
||||
public static final Property lastAlarmAckedFailureTime = BAlarmAcknowledger.newProperty((int)2115, (BValue)BAbsTime.NULL, null);
|
||||
public static final Property lastAlarmAckedFailureCause = BAlarmAcknowledger.newProperty((int)2115, (String)"", null);
|
||||
public static final Property totalAlarmsAckedToday = BAlarmAcknowledger.newProperty((int)2115, (int)0, null);
|
||||
public static final Property totalAlarmAckedFailures = BAlarmAcknowledger.newProperty((int)2115, (int)0, null);
|
||||
public static final Property totalMessagesReceivedToday = BAlarmAcknowledger.newProperty((int)2115, (int)0, null);
|
||||
public static final Action resetTotals = BAlarmAcknowledger.newAction((int)20, null);
|
||||
public static final Topic alarmAcked = BAlarmAcknowledger.newTopic((int)0, null);
|
||||
public static final Type TYPE;
|
||||
protected static final String UUID_TEXT = "UUID:";
|
||||
protected static final int UUID_LENGTH = 36;
|
||||
protected static final Log log;
|
||||
private static Worker worker;
|
||||
private static final Object compRefCountMonitor;
|
||||
private static int compRefCount;
|
||||
private Clock.Ticket resetTicket;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$ack$BAlarmAcknowledger;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public BStatus getStatus() {
|
||||
return (BStatus)this.get(status);
|
||||
}
|
||||
|
||||
public void setStatus(BStatus bStatus) {
|
||||
this.set(status, (BValue)bStatus, null);
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return this.getBoolean(enabled);
|
||||
}
|
||||
|
||||
public void setEnabled(boolean bl) {
|
||||
this.setBoolean(enabled, bl, null);
|
||||
}
|
||||
|
||||
public boolean getAckAlarmsFromSameSource() {
|
||||
return this.getBoolean(ackAlarmsFromSameSource);
|
||||
}
|
||||
|
||||
public void setAckAlarmsFromSameSource(boolean bl) {
|
||||
this.setBoolean(ackAlarmsFromSameSource, bl, null);
|
||||
}
|
||||
|
||||
public String getLastAlarmAcked() {
|
||||
return this.getString(lastAlarmAcked);
|
||||
}
|
||||
|
||||
public void setLastAlarmAcked(String string) {
|
||||
this.setString(lastAlarmAcked, string, null);
|
||||
}
|
||||
|
||||
public BAbsTime getLastAlarmAckedTime() {
|
||||
return (BAbsTime)this.get(lastAlarmAckedTime);
|
||||
}
|
||||
|
||||
public void setLastAlarmAckedTime(BAbsTime bAbsTime) {
|
||||
this.set(lastAlarmAckedTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public BAbsTime getLastAlarmAckedFailureTime() {
|
||||
return (BAbsTime)this.get(lastAlarmAckedFailureTime);
|
||||
}
|
||||
|
||||
public void setLastAlarmAckedFailureTime(BAbsTime bAbsTime) {
|
||||
this.set(lastAlarmAckedFailureTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public String getLastAlarmAckedFailureCause() {
|
||||
return this.getString(lastAlarmAckedFailureCause);
|
||||
}
|
||||
|
||||
public void setLastAlarmAckedFailureCause(String string) {
|
||||
this.setString(lastAlarmAckedFailureCause, string, null);
|
||||
}
|
||||
|
||||
public int getTotalAlarmsAckedToday() {
|
||||
return this.getInt(totalAlarmsAckedToday);
|
||||
}
|
||||
|
||||
public void setTotalAlarmsAckedToday(int n) {
|
||||
this.setInt(totalAlarmsAckedToday, n, null);
|
||||
}
|
||||
|
||||
public int getTotalAlarmAckedFailures() {
|
||||
return this.getInt(totalAlarmAckedFailures);
|
||||
}
|
||||
|
||||
public void setTotalAlarmAckedFailures(int n) {
|
||||
this.setInt(totalAlarmAckedFailures, n, null);
|
||||
}
|
||||
|
||||
public int getTotalMessagesReceivedToday() {
|
||||
return this.getInt(totalMessagesReceivedToday);
|
||||
}
|
||||
|
||||
public void setTotalMessagesReceivedToday(int n) {
|
||||
this.setInt(totalMessagesReceivedToday, n, null);
|
||||
}
|
||||
|
||||
public void resetTotals() {
|
||||
this.invoke(resetTotals, null, null);
|
||||
}
|
||||
|
||||
public void fireAlarmAcked(BAlarmRecord bAlarmRecord) {
|
||||
this.fire(alarmAcked, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 11: {
|
||||
this.fwStarted();
|
||||
break;
|
||||
}
|
||||
case 12: {
|
||||
this.fwStopped();
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
this.fwChanged((Property)object);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void fwStarted() {
|
||||
block4: {
|
||||
this.setStatus(this.getEnabled() ? BStatus.ok : BStatus.disabled);
|
||||
Object object = compRefCountMonitor;
|
||||
synchronized (object) {
|
||||
int n = ++compRefCount;
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl6 : MonitorExitStatement: MONITOREXIT : var2_1
|
||||
if (n != 1) break block4;
|
||||
}
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Starting Alarm Acknowledger Worker");
|
||||
}
|
||||
worker = new Worker((Worker.ITodo)new Queue(512));
|
||||
worker.start("alarmAcknowledger");
|
||||
}
|
||||
this.startMidnightReset();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void fwStopped() {
|
||||
block5: {
|
||||
if (this.resetTicket != null) {
|
||||
this.resetTicket.cancel();
|
||||
this.resetTicket = null;
|
||||
}
|
||||
Object object = compRefCountMonitor;
|
||||
synchronized (object) {
|
||||
int n = --compRefCount;
|
||||
// MONITOREXIT @DISABLED, blocks:[0, 1] lbl8 : MonitorExitStatement: MONITOREXIT : var2_1
|
||||
if (n > 0) break block5;
|
||||
}
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Stopping Alarm Acknowledger Worker");
|
||||
}
|
||||
worker.stop();
|
||||
worker = null;
|
||||
}
|
||||
}
|
||||
|
||||
private final void fwChanged(Property property) {
|
||||
if (this.isRunning() && property == enabled) {
|
||||
this.setStatus(this.getEnabled() ? BStatus.ok : BStatus.disabled);
|
||||
}
|
||||
}
|
||||
|
||||
public IFuture post(Action action, BValue bValue, Context context) {
|
||||
if (action == resetTotals) {
|
||||
this.post((Runnable)new Invocation((BComponent)this, action, bValue, context));
|
||||
return null;
|
||||
}
|
||||
return super.post(action, bValue, context);
|
||||
}
|
||||
|
||||
private final void incTotalAlarmsAckedToday() {
|
||||
int n = this.getTotalAlarmsAckedToday();
|
||||
if (++n >= Integer.MAX_VALUE) {
|
||||
n = 0;
|
||||
}
|
||||
this.setTotalAlarmsAckedToday(n);
|
||||
}
|
||||
|
||||
protected final void incTotalAlarmAckedFailures() {
|
||||
int n = this.getTotalAlarmAckedFailures();
|
||||
if (++n >= Integer.MAX_VALUE) {
|
||||
n = 0;
|
||||
}
|
||||
this.setTotalAlarmAckedFailures(n);
|
||||
}
|
||||
|
||||
protected final void incTotalMessagesReceivedToday() {
|
||||
int n = this.getTotalMessagesReceivedToday();
|
||||
if (++n >= Integer.MAX_VALUE) {
|
||||
n = 0;
|
||||
}
|
||||
this.setTotalMessagesReceivedToday(n);
|
||||
}
|
||||
|
||||
public final void doResetTotals() {
|
||||
this.setTotalAlarmsAckedToday(0);
|
||||
this.setTotalAlarmAckedFailures(0);
|
||||
this.setTotalMessagesReceivedToday(0);
|
||||
this.startMidnightReset();
|
||||
}
|
||||
|
||||
protected final void doFail(String string) {
|
||||
this.setLastAlarmAckedFailureCause(string);
|
||||
this.setLastAlarmAckedFailureTime(BAbsTime.now());
|
||||
this.incTotalAlarmAckedFailures();
|
||||
}
|
||||
|
||||
protected final void ackAlarm(BUuid bUuid, String string) {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmRecord bAlarmRecord = (BAlarmRecord)bAlarmService.getAlarmDb().getRecord(bUuid).newCopy(true);
|
||||
if (bAlarmRecord == null) {
|
||||
this.doFail("Could not find alarm record to ack (" + this.getType() + ')');
|
||||
return;
|
||||
}
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmRecord.ackAlarm(string);
|
||||
bAlarmRecord.setAckState(BAckState.ackPending);
|
||||
bAlarmService.getAlarmDb().update(bAlarmRecord);
|
||||
this.setLastAlarmAcked(bAlarmRecord.getUuid().encodeToString());
|
||||
bAlarmService.ackAlarm(bAlarmRecord);
|
||||
this.fireAlarmAcked(bAlarmRecord);
|
||||
this.incTotalAlarmsAckedToday();
|
||||
this.setLastAlarmAckedTime(BAbsTime.now());
|
||||
if (log.isTraceOn()) {
|
||||
log.trace(this.getType() + " acknowledged " + bAlarmRecord.getUuid());
|
||||
}
|
||||
} else if (log.isTraceOn()) {
|
||||
log.trace(this.getType() + " already acknowledged " + bAlarmRecord.getUuid());
|
||||
}
|
||||
if (this.getAckAlarmsFromSameSource()) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("alarm:|bql:select from openAlarms where ackState != 'acked' and source='");
|
||||
stringBuffer.append(SlotPath.escape((String)bAlarmRecord.getSource().encodeToString()));
|
||||
stringBuffer.append("'");
|
||||
BITable bITable = (BITable)BOrd.make((String)stringBuffer.toString()).get((BObject)this);
|
||||
Cursor cursor = bITable.cursor();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmRecord = BAlarmAcknowledger.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
Array array = new Array(clazz);
|
||||
while (cursor.next()) {
|
||||
array.add((Object)cursor.get().asValue().newCopy(true));
|
||||
}
|
||||
boolean bl = false;
|
||||
BAlarmRecord[] bAlarmRecordArray = (BAlarmRecord[])array.trim();
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
BAlarmRecord bAlarmRecord2 = (BAlarmRecord)bAlarmRecordArray[n].newCopy(true);
|
||||
bAlarmRecord2.ackAlarm(string);
|
||||
bAlarmRecord2.setAckState(BAckState.ackPending);
|
||||
bAlarmService.getAlarmDb().update(bAlarmRecord2);
|
||||
bAlarmService.ackAlarm(bAlarmRecord2);
|
||||
this.fireAlarmAcked(bAlarmRecord2);
|
||||
this.setLastAlarmAcked(bAlarmRecordArray[n].getUuid().encodeToString());
|
||||
this.incTotalAlarmsAckedToday();
|
||||
bl = true;
|
||||
if (log.isTraceOn()) {
|
||||
log.trace(this.getType() + " also acknowledged " + bAlarmRecordArray[n].getUuid());
|
||||
}
|
||||
++n;
|
||||
}
|
||||
if (bl) {
|
||||
this.setLastAlarmAckedTime(BAbsTime.now());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
String string2 = "Failure to acknowledge alarm (" + this.getType() + ')';
|
||||
log.error(string2, (Throwable)exception);
|
||||
this.doFail(string2);
|
||||
}
|
||||
}
|
||||
|
||||
protected final void post(Runnable runnable) {
|
||||
((Queue)worker.getTodo()).enqueue((Object)runnable);
|
||||
}
|
||||
|
||||
private final void startMidnightReset() {
|
||||
if (this.resetTicket != null) {
|
||||
this.resetTicket.cancel();
|
||||
}
|
||||
BAbsTime bAbsTime = BAbsTime.now();
|
||||
BAbsTime bAbsTime2 = bAbsTime.nextDay();
|
||||
BAbsTime bAbsTime3 = bAbsTime2.timeOfDay(0, 0, 0, 0);
|
||||
this.resetTicket = Clock.schedule((BComponent)this, (BAbsTime)bAbsTime3, (Action)resetTotals, null);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.resetTicket = null;
|
||||
}
|
||||
|
||||
public BAlarmAcknowledger() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$ack$BAlarmAcknowledger;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$ack$BAlarmAcknowledger = BAlarmAcknowledger.class("[Lcom.tridium.alarm.ack.BAlarmAcknowledger;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
log = Log.getLog((String)"alarm.acknowledger");
|
||||
worker = null;
|
||||
compRefCountMonitor = new Object();
|
||||
compRefCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.OrdQuery
|
||||
* javax.baja.naming.OrdQueryList
|
||||
* javax.baja.naming.SyntaxException
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.baja.naming.OrdQuery;
|
||||
import javax.baja.naming.OrdQueryList;
|
||||
import javax.baja.naming.SyntaxException;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public class AlarmQuery
|
||||
implements OrdQuery {
|
||||
private String query;
|
||||
private HashMap paramMap;
|
||||
|
||||
public boolean isHost() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSession() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void normalize(OrdQueryList ordQueryList, int n) {
|
||||
ordQueryList.shiftToSession(n);
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return "alarm";
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return this.query;
|
||||
}
|
||||
|
||||
public boolean isDbQuery() {
|
||||
this.parse();
|
||||
boolean bl = false;
|
||||
if (this.paramMap.size() == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public BUuid getUuid() {
|
||||
String string = (String)this.paramMap.get("uuid");
|
||||
if (string != null) {
|
||||
return BUuid.make((String)string);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getQueryParameter(String string, String string2) {
|
||||
this.parse();
|
||||
String string3 = (String)this.paramMap.get(string);
|
||||
if (string3 == null) {
|
||||
return string2;
|
||||
}
|
||||
return string3;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "alarm:" + this.query;
|
||||
}
|
||||
|
||||
public void parse() {
|
||||
if (this.paramMap != null) {
|
||||
return;
|
||||
}
|
||||
this.paramMap = new HashMap();
|
||||
if (this.query == null || this.query.length() == 0) {
|
||||
return;
|
||||
}
|
||||
int n = 0;
|
||||
int n2 = this.query.indexOf(61);
|
||||
while (n2 != -1) {
|
||||
String string = null;
|
||||
String string2 = null;
|
||||
int n3 = this.query.indexOf(59, n2);
|
||||
string = this.query.substring(n, n2);
|
||||
string2 = n3 == -1 ? this.query.substring(n2 + 1) : this.query.substring(n2 + 1, n3);
|
||||
this.paramMap.put(string, string2);
|
||||
if (n3 == -1) break;
|
||||
n = n3 + 1;
|
||||
n2 = this.query.indexOf(61, n);
|
||||
if (n2 != -1 || n == this.query.length()) continue;
|
||||
throw new SyntaxException("Expecting =");
|
||||
}
|
||||
}
|
||||
|
||||
public AlarmQuery(String string) {
|
||||
this.query = string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.util.Exprs
|
||||
* javax.baja.query.util.Predicates
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSimple
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.util.Exprs;
|
||||
import javax.baja.query.util.Predicates;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAckPendingAlarmTable
|
||||
extends BAlarmTable
|
||||
implements Queryable {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAckPendingAlarmTable;
|
||||
|
||||
public Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().getAckPendingAlarms();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BAckPendingAlarmTable(this.getAlarmDb(), iFilter);
|
||||
}
|
||||
|
||||
public BObject bqlQuery(OrdTarget ordTarget, BqlQuery bqlQuery) {
|
||||
BExpression bExpression = Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.ackPending);
|
||||
BSelect bSelect = ((SelectQuery)bqlQuery).getSelect();
|
||||
if (bSelect.hasPredicate()) {
|
||||
bSelect.where(Exprs.builder((BExpression)bSelect.getPredicate().getPredicateExpr()).and(bExpression).getExpression());
|
||||
} else {
|
||||
bSelect.where(bExpression);
|
||||
}
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), (BqlQuery)new SelectQuery(bSelect));
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BAckPendingAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
super(bAlarmDatabase);
|
||||
}
|
||||
|
||||
public BAckPendingAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAckPendingAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAckPendingAlarmTable = BAckPendingAlarmTable.class("[Lcom.tridium.alarm.db.BAckPendingAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmDbQueryResult
|
||||
extends BAlarmTable {
|
||||
public static final Type TYPE;
|
||||
private BqlQuery query;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAlarmDbQueryResult;
|
||||
|
||||
protected Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().doBqlQuery(this.query);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), this.query, iFilter);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmDbQueryResult(BAlarmDatabase bAlarmDatabase, BqlQuery bqlQuery) {
|
||||
super(bAlarmDatabase);
|
||||
this.query = bqlQuery;
|
||||
}
|
||||
|
||||
public BAlarmDbQueryResult(BAlarmDatabase bAlarmDatabase, BqlQuery bqlQuery, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
this.query = bqlQuery;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAlarmDbQueryResult;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAlarmDbQueryResult = BAlarmDbQueryResult.class("[Lcom.tridium.alarm.db.BAlarmDbQueryResult;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.collection.BqlColumn
|
||||
* com.tridium.bql.collection.BqlColumnList
|
||||
* com.tridium.bql.collection.PropertyColumn
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BIList
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.AlarmTableCursor;
|
||||
import com.tridium.bql.collection.BqlColumn;
|
||||
import com.tridium.bql.collection.BqlColumnList;
|
||||
import com.tridium.bql.collection.PropertyColumn;
|
||||
import java.util.ArrayList;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BIList;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BAlarmTable
|
||||
extends BObject
|
||||
implements BITable {
|
||||
public static final Type TYPE;
|
||||
private BAlarmDatabase db;
|
||||
private IFilter filter;
|
||||
private Context context;
|
||||
private BqlColumnList columns;
|
||||
private ArrayList recs;
|
||||
private BFacets tableFacets;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BAlarmTable;
|
||||
|
||||
public BAlarmDatabase getAlarmDb() {
|
||||
return this.db;
|
||||
}
|
||||
|
||||
public Cursor cursor() {
|
||||
return new AlarmTableCursor(this, this.inner(), (javax.baja.nre.util.IFilter)this.filter);
|
||||
}
|
||||
|
||||
protected abstract Cursor inner();
|
||||
|
||||
public BIList toList() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BITable toTable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract BICollection filter(IFilter var1);
|
||||
|
||||
public int size() {
|
||||
this.load();
|
||||
return this.recs.size();
|
||||
}
|
||||
|
||||
public BObject get(int n) {
|
||||
return (BObject)this.recs.get(n);
|
||||
}
|
||||
|
||||
public BObject[] list() {
|
||||
this.load();
|
||||
return this.recs.toArray(new BObject[this.recs.size()]);
|
||||
}
|
||||
|
||||
public BObject[] list(BObject[] bObjectArray) {
|
||||
this.load();
|
||||
return this.recs.toArray(bObjectArray);
|
||||
}
|
||||
|
||||
public ColumnList getColumns() {
|
||||
if (this.columns == null) {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
Property[] propertyArray = bAlarmRecord.getPropertiesArray();
|
||||
BqlColumn[] bqlColumnArray = new BqlColumn[propertyArray.length];
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
Property property = propertyArray[n];
|
||||
Object var6_6 = null;
|
||||
bqlColumnArray[n] = new PropertyColumn(propertyArray[n]);
|
||||
++n;
|
||||
}
|
||||
this.columns = new BqlColumnList((Column[])bqlColumnArray);
|
||||
}
|
||||
return this.columns;
|
||||
}
|
||||
|
||||
public BObject get(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).get((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public String getString(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getString((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public float getFloat(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFloat((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public double getDouble(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getDouble((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getInt(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getInt((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public long getLong(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getLong((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public boolean getBoolean(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getBoolean((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public int getFlags(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFlags((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getFacets(int n, Column column) {
|
||||
this.load();
|
||||
return ((BqlColumn)column).getFacets((BObject)((BAlarmRecord)((Object)this.recs.get(n))));
|
||||
}
|
||||
|
||||
public BFacets getTableFacets() {
|
||||
return this.tableFacets;
|
||||
}
|
||||
|
||||
private final void load() {
|
||||
if (this.recs != null) {
|
||||
return;
|
||||
}
|
||||
this.recs = new ArrayList(1000);
|
||||
Cursor cursor = this.cursor();
|
||||
while (cursor.next()) {
|
||||
this.recs.add((BAlarmRecord)((BAlarmRecord)cursor.get()).newCopy());
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
this(bAlarmDatabase, null);
|
||||
}
|
||||
|
||||
public BAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
this.db = bAlarmDatabase;
|
||||
this.filter = iFilter;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BAlarmTable = BAlarmTable.class("[Lcom.tridium.alarm.db.BAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.sys.BInterface
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIAlarmResolver
|
||||
extends BInterface {
|
||||
public static final Type TYPE;
|
||||
|
||||
public OrdTarget resolve(BISession var1, OrdTarget var2, AlarmQuery var3);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$com$tridium$alarm$db$BIAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$com$tridium$alarm$db$BIAlarmResolver = 1.class("[Lcom.tridium.alarm.db.BIAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.agent.BIAgent
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.naming.UnresolvedException
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSingleton
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import com.tridium.alarm.db.BIAlarmResolver;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSingleton;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BLocalAlarmResolver
|
||||
extends BSingleton
|
||||
implements BIAlarmResolver,
|
||||
BIAgent {
|
||||
public static final BLocalAlarmResolver INSTANCE = new BLocalAlarmResolver();
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BLocalAlarmResolver;
|
||||
|
||||
public final OrdTarget resolve(BISession bISession, OrdTarget ordTarget, AlarmQuery alarmQuery) {
|
||||
BOrd bOrd = BOrd.make((String)"service:alarm:AlarmService");
|
||||
BAlarmService bAlarmService = (BAlarmService)bOrd.resolve(ordTarget.get()).get();
|
||||
try {
|
||||
if (alarmQuery.isDbQuery()) {
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmService.getAlarmDb());
|
||||
}
|
||||
String string = alarmQuery.getQueryParameter("uuid", null);
|
||||
if (string != null) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord(BUuid.make((String)string));
|
||||
if (bAlarmRecord == null) {
|
||||
throw new UnresolvedException(string);
|
||||
}
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmRecord);
|
||||
}
|
||||
throw new UnresolvedException("Invalid alarm query: " + alarmQuery);
|
||||
}
|
||||
catch (UnresolvedException unresolvedException) {
|
||||
throw unresolvedException;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new UnresolvedException("Cannot access alarm database.", (Throwable)exception);
|
||||
}
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private BLocalAlarmResolver() {
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BLocalAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BLocalAlarmResolver = BLocalAlarmResolver.class("[Lcom.tridium.alarm.db.BLocalAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.bql.BSelect
|
||||
* com.tridium.bql.SelectQuery
|
||||
* com.tridium.util.EmptyCursor
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.query.BExpression
|
||||
* javax.baja.query.util.Exprs
|
||||
* javax.baja.query.util.Predicates
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSimple
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.IFilter
|
||||
*/
|
||||
package com.tridium.alarm.db;
|
||||
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.db.BAlarmTable;
|
||||
import com.tridium.bql.BSelect;
|
||||
import com.tridium.bql.SelectQuery;
|
||||
import com.tridium.util.EmptyCursor;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.query.BExpression;
|
||||
import javax.baja.query.util.Exprs;
|
||||
import javax.baja.query.util.Predicates;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSimple;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.IFilter;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BOpenAlarmTable
|
||||
extends BAlarmTable
|
||||
implements Queryable {
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$BOpenAlarmTable;
|
||||
|
||||
public Cursor inner() {
|
||||
try {
|
||||
return this.getAlarmDb().getOpenAlarms();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return new EmptyCursor(null);
|
||||
}
|
||||
}
|
||||
|
||||
public BICollection filter(IFilter iFilter) {
|
||||
return new BOpenAlarmTable(this.getAlarmDb(), iFilter);
|
||||
}
|
||||
|
||||
public BObject bqlQuery(OrdTarget ordTarget, BqlQuery bqlQuery) {
|
||||
BExpression bExpression = Predicates.and((BExpression)Predicates.not((BExpression)Predicates.and((BExpression)Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.acked), (BExpression)Predicates.eq((String)BAlarmRecord.sourceState.getName(), (BSimple)BSourceState.normal))), (BExpression)Predicates.not((BExpression)Predicates.and((BExpression)Predicates.eq((String)BAlarmRecord.ackState.getName(), (BSimple)BAckState.acked), (BExpression)Predicates.eq((String)BAlarmRecord.sourceState.getName(), (BSimple)BSourceState.normal))));
|
||||
BSelect bSelect = ((SelectQuery)bqlQuery).getSelect();
|
||||
if (bSelect.hasPredicate()) {
|
||||
bSelect.where(Exprs.builder((BExpression)bSelect.getPredicate().getPredicateExpr()).and(bExpression).getExpression());
|
||||
} else {
|
||||
bSelect.where(bExpression);
|
||||
}
|
||||
return new BAlarmDbQueryResult(this.getAlarmDb(), (BqlQuery)new SelectQuery(bSelect));
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BOpenAlarmTable(BAlarmDatabase bAlarmDatabase) {
|
||||
super(bAlarmDatabase);
|
||||
}
|
||||
|
||||
public BOpenAlarmTable(BAlarmDatabase bAlarmDatabase, IFilter iFilter) {
|
||||
super(bAlarmDatabase, iFilter);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$BOpenAlarmTable;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$BOpenAlarmTable = BOpenAlarmTable.class("[Lcom.tridium.alarm.db.BOpenAlarmTable;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class AckPendingIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private IndexEntry first = null;
|
||||
private IndexEntry last = null;
|
||||
private int size = 0;
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void add(IndexEntry indexEntry) {
|
||||
if (indexEntry.isAckPending()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setAckPending(true);
|
||||
indexEntry.nextAckPending = null;
|
||||
indexEntry.prevAckPending = null;
|
||||
if (this.size == 0) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
IndexEntry indexEntry2 = indexEntry.prevTimestamp;
|
||||
while (indexEntry2 != null && !indexEntry2.isAckPending()) {
|
||||
indexEntry2 = indexEntry2.prevTimestamp;
|
||||
}
|
||||
if (indexEntry2 == null) {
|
||||
if (this.first == null) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
indexEntry.nextAckPending = this.first;
|
||||
this.first.prevAckPending = indexEntry;
|
||||
this.first = indexEntry;
|
||||
}
|
||||
} else {
|
||||
indexEntry.nextAckPending = indexEntry2.nextAckPending;
|
||||
indexEntry.prevAckPending = indexEntry2;
|
||||
if (indexEntry2.nextAckPending != null) {
|
||||
indexEntry2.nextAckPending.prevAckPending = indexEntry;
|
||||
}
|
||||
indexEntry2.nextAckPending = indexEntry;
|
||||
if (indexEntry.prevAckPending == this.last) {
|
||||
this.last = indexEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0 || indexEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (!indexEntry.isAckPending()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setAckPending(false);
|
||||
if (indexEntry.prevAckPending != null) {
|
||||
indexEntry.prevAckPending.nextAckPending = indexEntry.nextAckPending;
|
||||
}
|
||||
if (indexEntry.nextAckPending != null) {
|
||||
indexEntry.nextAckPending.prevAckPending = indexEntry.prevAckPending;
|
||||
}
|
||||
if (indexEntry == this.first) {
|
||||
this.first = indexEntry.nextAckPending;
|
||||
}
|
||||
if (indexEntry == this.last) {
|
||||
this.last = indexEntry.prevAckPending;
|
||||
}
|
||||
indexEntry.nextAckPending = null;
|
||||
indexEntry.prevAckPending = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
IndexEntry indexEntry = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ") " + indexEntry.timestamp.toString((Context)showSecs) + " ackPending=" + indexEntry.isAckPending());
|
||||
indexEntry = indexEntry.nextAckPending;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isAfter(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is before " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isAckPending()) {
|
||||
throw new IllegalStateException("Cleared alarm in ackPending index, ascending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.nextAckPending;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry = null;
|
||||
indexEntry2 = this.last;
|
||||
n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isBefore(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is after " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isAckPending()) {
|
||||
throw new IllegalStateException("Cleared alarm in ackPending index, descending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.prevAckPending;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.SkipList;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmSourceIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private HashMap table;
|
||||
private double probability;
|
||||
private int maxSizePerSource;
|
||||
|
||||
public synchronized IndexEntry getListForSource(BOrdList bOrdList) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
return null;
|
||||
}
|
||||
return sourceList.getFirstEntry();
|
||||
}
|
||||
|
||||
public synchronized void add(BOrdList bOrdList, IndexEntry indexEntry) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
sourceList = new SourceList(this.probability, this.maxSizePerSource);
|
||||
this.table.put(bOrdList, sourceList);
|
||||
sourceList.add(indexEntry);
|
||||
} else {
|
||||
sourceList.add(indexEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(BOrdList bOrdList, IndexEntry indexEntry) {
|
||||
SourceList sourceList = (SourceList)this.table.get(bOrdList);
|
||||
if (sourceList == null) {
|
||||
return;
|
||||
}
|
||||
sourceList.remove(indexEntry);
|
||||
}
|
||||
|
||||
public IndexEntry getNext(IndexEntry indexEntry) {
|
||||
return indexEntry.nextSource[0];
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.table = new HashMap(1001);
|
||||
}
|
||||
|
||||
public AlarmSourceIndex(double d, int n) {
|
||||
this.this();
|
||||
this.probability = d;
|
||||
this.maxSizePerSource = n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class SourceList
|
||||
extends SkipList {
|
||||
public int compare(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
int n = indexEntry.timestamp.compareTo((Object)indexEntry2.timestamp);
|
||||
if (n == 0) {
|
||||
return indexEntry.pageIndex - indexEntry2.pageIndex;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public int compareToKey(IndexEntry indexEntry, Object object) {
|
||||
return indexEntry.timestamp.compareTo((Object)((BAbsTime)object));
|
||||
}
|
||||
|
||||
public int getLevel(IndexEntry indexEntry) {
|
||||
return indexEntry.nextSource.length;
|
||||
}
|
||||
|
||||
public void setLevel(IndexEntry indexEntry, int n) {
|
||||
indexEntry.nextSource = new IndexEntry[n];
|
||||
}
|
||||
|
||||
public IndexEntry getNext(IndexEntry indexEntry, int n) {
|
||||
return indexEntry.nextSource[n];
|
||||
}
|
||||
|
||||
public void setNext(IndexEntry indexEntry, int n, IndexEntry indexEntry2) {
|
||||
indexEntry.nextSource[n] = indexEntry2;
|
||||
}
|
||||
|
||||
public IndexEntry getPrev(IndexEntry indexEntry) {
|
||||
return indexEntry.prevSource;
|
||||
}
|
||||
|
||||
public void setPrev(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
indexEntry.prevSource = indexEntry2;
|
||||
}
|
||||
|
||||
public String entryToString(IndexEntry indexEntry) {
|
||||
return indexEntry.timestamp.toString((Context)BAlarmRecord.TIMESTAMP_FACETS) + " => " + indexEntry.pageIndex;
|
||||
}
|
||||
|
||||
public SourceList(double d, int n) {
|
||||
super(d, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,794 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.io.ByteBuffer
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AckPendingIndex;
|
||||
import com.tridium.alarm.db.file.AlarmSourceIndex;
|
||||
import com.tridium.alarm.db.file.AlarmStoreHeader;
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import com.tridium.alarm.db.file.BlockCache;
|
||||
import com.tridium.alarm.db.file.FreePageMap;
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.OpenIndex;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import com.tridium.alarm.db.file.PageReader;
|
||||
import com.tridium.alarm.db.file.TimestampIndex;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmStore {
|
||||
private static final int BLOCK_CACHE_SIZE = 10;
|
||||
private static final int MAX_SIZE = 250000;
|
||||
private static final int MAX_SIZE_PER_SOURCE = 10000;
|
||||
private File alarmFile;
|
||||
private RandomAccessFile io;
|
||||
private int capacity;
|
||||
private AlarmStoreHeader header;
|
||||
private FreePageMap freeMap;
|
||||
private BlockCache blockCache;
|
||||
private ByteBuffer writeBuf;
|
||||
private PageReader reader;
|
||||
private int[] recPages;
|
||||
private HashMap byUuid;
|
||||
private TimestampIndex timestampIndex;
|
||||
private AlarmSourceIndex sourceIndex;
|
||||
private OpenIndex openIndex;
|
||||
private AckPendingIndex ackPendingIndex;
|
||||
private BAlarmRecord trimRec;
|
||||
private BAlarmService alarmService;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
|
||||
public AlarmStoreHeader getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public void setCapacity(int n) {
|
||||
this.capacity = n;
|
||||
}
|
||||
|
||||
public synchronized void open() throws IOException {
|
||||
this.byUuid = new HashMap();
|
||||
this.timestampIndex = new TimestampIndex(0.5, 250000);
|
||||
this.sourceIndex = new AlarmSourceIndex(0.5, 10000);
|
||||
this.openIndex = new OpenIndex();
|
||||
this.ackPendingIndex = new AckPendingIndex();
|
||||
this.blockCache = new BlockCache(this, 10);
|
||||
this.io = new RandomAccessFile(this.alarmFile, "rw");
|
||||
try {
|
||||
if (this.io.length() == 0L) {
|
||||
this.create();
|
||||
} else {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
this.io.close();
|
||||
this.io = null;
|
||||
throw iOException;
|
||||
}
|
||||
catch (RuntimeException runtimeException) {
|
||||
this.io.close();
|
||||
this.io = null;
|
||||
throw runtimeException;
|
||||
}
|
||||
this.writeBuf = new ByteBuffer(this.header.getPageSize());
|
||||
}
|
||||
|
||||
private final void create() throws IOException {
|
||||
this.header = new AlarmStoreHeader(new BAlarmRecord().getSerialVersionId());
|
||||
this.io.seek(0L);
|
||||
this.header.write(this.io);
|
||||
this.freeMap = new FreePageMap();
|
||||
BAlarmDatabase.log.message("Created");
|
||||
}
|
||||
|
||||
private final void init() throws IOException {
|
||||
BAlarmDatabase.log.message("Loading...");
|
||||
this.header = new AlarmStoreHeader();
|
||||
this.io.seek(0L);
|
||||
this.header.read(this.io);
|
||||
int n = new BAlarmRecord().getSerialVersionId();
|
||||
if (this.header.getRecordVersion() != n) {
|
||||
throw new IOException("Incompatible record versions. (expected=" + n + ", actual=" + this.header.getRecordVersion() + ')');
|
||||
}
|
||||
this.freeMap = new FreePageMap();
|
||||
int n2 = (int)((this.io.length() - this.header.getDataOffset()) / (long)this.header.getPageSize());
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
BAlarmRecord bAlarmRecord2 = new BAlarmRecord();
|
||||
long l = Clock.ticks();
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < n2) {
|
||||
block11: {
|
||||
block13: {
|
||||
block12: {
|
||||
Page page = this.readPage(n4);
|
||||
if (page.getPageOfRecord() != 0) break block11;
|
||||
if ((bAlarmRecord = this.readRecord(n4, bAlarmRecord, this.freeMap)) != null) break block12;
|
||||
if (++n3 == 20) {
|
||||
throw new IOException("Alarm database is invalid. Too many invalid records read during init.");
|
||||
}
|
||||
break block11;
|
||||
}
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
if (indexEntry == null) break block13;
|
||||
if ((bAlarmRecord2 = this.readRecord(indexEntry.pageIndex, bAlarmRecord2, null)).getLastUpdate().isAfter(bAlarmRecord.getLastUpdate())) break block11;
|
||||
this.freePageRun(indexEntry.pageIndex);
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, n4);
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
long l2 = Clock.ticks();
|
||||
BAlarmDatabase.log.message("Loaded [" + (l2 - l) + "ms, " + this.getRecordCount() + " alarms, " + n2 + " pages]");
|
||||
}
|
||||
|
||||
public synchronized void close() {
|
||||
if (this.io != null) {
|
||||
try {
|
||||
this.io.close();
|
||||
}
|
||||
catch (Exception exception) {}
|
||||
this.io = null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
if (!this.byUuid.containsKey(bAlarmRecord.getUuid())) {
|
||||
this.append(bAlarmRecord, false);
|
||||
this.trimToCapacity();
|
||||
} else {
|
||||
this.update(bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void append(BAlarmRecord bAlarmRecord, boolean bl) throws IOException {
|
||||
Object object;
|
||||
this.writeBuf.reset();
|
||||
bAlarmRecord.write((DataOutput)this.writeBuf);
|
||||
bAlarmRecord.getUuid().encode((DataOutput)this.writeBuf);
|
||||
byte[] byArray = this.writeBuf.getBytes();
|
||||
int n = this.writeBuf.getLength();
|
||||
int n2 = 0;
|
||||
int n3 = this.header.getPageSize() - 12;
|
||||
int n4 = n / n3;
|
||||
if (n % n3 != 0) {
|
||||
++n4;
|
||||
}
|
||||
int[] nArray = this.takePages(n4);
|
||||
if (!bl) {
|
||||
object = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (object.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
object.setTotalAlarmCount(object.getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
object.setUnackedAlarmCount(object.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
object.setOpenAlarmCount(object.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
object.setInAlarmCount(object.getInAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, nArray[0]);
|
||||
} else {
|
||||
object = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
BAlarmRecord bAlarmRecord2 = this.readRecord(((IndexEntry)object).pageIndex, null);
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
if (!((IndexEntry)object).isAcked() && bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
} else if (((IndexEntry)object).isAcked() && !bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (!((IndexEntry)object).isOpen() && bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() + 1);
|
||||
}
|
||||
if (((IndexEntry)object).isOpen() && !bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (((IndexEntry)object).isNormal() && !bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() + 1);
|
||||
}
|
||||
if (!((IndexEntry)object).isNormal() && bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
this.updateIndices(bAlarmRecord, bAlarmRecord2, nArray[0]);
|
||||
}
|
||||
int n5 = 0;
|
||||
while (n5 < n4) {
|
||||
int n6 = nArray[n5];
|
||||
int n7 = n5 == n4 - 1 ? -1 : nArray[n5 + 1];
|
||||
Page page = this.readPage(n6);
|
||||
int n8 = Math.min(n - n2, n3);
|
||||
page.write(n5, n4, n7, byArray, n2, n8);
|
||||
n2 += n8;
|
||||
++n5;
|
||||
}
|
||||
if (n2 != n) {
|
||||
throw new IOException("Write error: " + n2 + " of " + n + " bytes written.");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
int n = -1;
|
||||
if (indexEntry != null) {
|
||||
n = indexEntry.pageIndex;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (indexEntry != null) {
|
||||
bl = true;
|
||||
}
|
||||
this.append(bAlarmRecord, bl);
|
||||
if (n != -1) {
|
||||
this.freePageRun(n);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void remove(IndexEntry indexEntry, BAlarmRecord bAlarmRecord) throws IOException {
|
||||
if (indexEntry == null && bAlarmRecord == null) {
|
||||
return;
|
||||
}
|
||||
if (indexEntry == null && (indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid())) == null) {
|
||||
return;
|
||||
}
|
||||
bAlarmRecord = this.readRecord(indexEntry.pageIndex, bAlarmRecord, null);
|
||||
this.byUuid.remove(bAlarmRecord.getUuid());
|
||||
this.timestampIndex.remove(indexEntry);
|
||||
this.sourceIndex.remove(bAlarmRecord.getSource(), indexEntry);
|
||||
if (indexEntry.isOpen()) {
|
||||
this.openIndex.remove(indexEntry);
|
||||
}
|
||||
if (indexEntry.isAckPending()) {
|
||||
this.ackPendingIndex.remove(indexEntry);
|
||||
}
|
||||
this.freePageRun(indexEntry.pageIndex);
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
indexEntry.nextTimestamp = null;
|
||||
indexEntry.prevTimestamp = null;
|
||||
indexEntry.nextSource = null;
|
||||
indexEntry.prevSource = null;
|
||||
indexEntry = null;
|
||||
}
|
||||
|
||||
private final synchronized void addToIndices(BAlarmRecord bAlarmRecord, int n) {
|
||||
IndexEntry indexEntry = new IndexEntry(bAlarmRecord, n);
|
||||
this.byUuid.put(bAlarmRecord.getUuid(), indexEntry);
|
||||
this.timestampIndex.add(indexEntry);
|
||||
this.sourceIndex.add(bAlarmRecord.getSource(), indexEntry);
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
this.openIndex.add(indexEntry);
|
||||
}
|
||||
if (bAlarmRecord.isAckPending()) {
|
||||
this.ackPendingIndex.add(indexEntry);
|
||||
}
|
||||
indexEntry.setAcked(bAlarmRecord.isAcknowledged());
|
||||
indexEntry.setNormal(bAlarmRecord.isNormal());
|
||||
indexEntry.setAckPending(bAlarmRecord.isAckPending());
|
||||
}
|
||||
|
||||
private final synchronized void updateIndices(BAlarmRecord bAlarmRecord, BAlarmRecord bAlarmRecord2, int n) {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bAlarmRecord.getUuid());
|
||||
if (indexEntry != null) {
|
||||
this.byUuid.remove(bAlarmRecord.getUuid());
|
||||
this.timestampIndex.remove(indexEntry);
|
||||
this.sourceIndex.remove(bAlarmRecord2.getSource(), indexEntry);
|
||||
if (indexEntry.isOpen()) {
|
||||
this.openIndex.remove(indexEntry);
|
||||
}
|
||||
if (indexEntry.isAckPending()) {
|
||||
this.ackPendingIndex.remove(indexEntry);
|
||||
}
|
||||
}
|
||||
this.addToIndices(bAlarmRecord, n);
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
this.blockCache.flush();
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
return this.timestampIndex.getSize();
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord getRecord(BUuid bUuid) throws IOException {
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bUuid);
|
||||
if (indexEntry != null) {
|
||||
return this.readRecord(indexEntry.pageIndex, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() {
|
||||
return new TimestampCursor(this, this.timestampIndex.getFirstEntry(), null);
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) {
|
||||
IndexEntry indexEntry = null;
|
||||
if (bAbsTime == null || bAbsTime.isNull()) {
|
||||
indexEntry = this.timestampIndex.getFirstEntry();
|
||||
} else {
|
||||
indexEntry = this.timestampIndex.find(bAbsTime);
|
||||
if (indexEntry != null) {
|
||||
indexEntry = indexEntry.nextTimestamp[0];
|
||||
}
|
||||
}
|
||||
return new TimestampCursor(this, indexEntry, bAbsTime2);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
IndexEntry indexEntry = this.sourceIndex.getListForSource(bOrdList);
|
||||
return new SourceCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor getOpenAlarms() throws IOException {
|
||||
IndexEntry indexEntry = this.openIndex.getFirstEntry();
|
||||
return new OpenCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAckPendingAlarms() throws IOException {
|
||||
IndexEntry indexEntry = this.ackPendingIndex.getFirstEntry();
|
||||
return new AckPendingCursor(this, indexEntry, null);
|
||||
}
|
||||
|
||||
private final synchronized int[] takePages(int n) throws IOException {
|
||||
if (this.recPages == null || this.recPages.length < n) {
|
||||
this.recPages = new int[n];
|
||||
}
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
this.recPages[n2] = this.nextFreePage();
|
||||
this.freeMap.setFree(this.recPages[n2], false);
|
||||
++n2;
|
||||
}
|
||||
return this.recPages;
|
||||
}
|
||||
|
||||
private final synchronized void freePageRun(int n) throws IOException {
|
||||
int n2 = n;
|
||||
do {
|
||||
Page page;
|
||||
if ((page = this.readPage(n2)) == null) {
|
||||
return;
|
||||
}
|
||||
this.freeMap.setFree(n2, true);
|
||||
n2 = page.getNextPage();
|
||||
page.clear();
|
||||
} while (n2 != -1);
|
||||
}
|
||||
|
||||
private final synchronized int nextFreePage() throws IOException {
|
||||
int n = this.freeMap.getFreePage();
|
||||
if (n == -1) {
|
||||
this.grow();
|
||||
}
|
||||
if ((n = this.freeMap.getFreePage()) == -1) {
|
||||
throw new IOException("Cannot allocate a new page.");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public synchronized Page readPage(int n) throws IOException {
|
||||
int n2 = this.header.getPagesPerBlock();
|
||||
int n3 = n / n2;
|
||||
int n4 = n - n3 * n2;
|
||||
return this.getBlock(n3).getPage(n4);
|
||||
}
|
||||
|
||||
private final synchronized void grow() throws IOException {
|
||||
int n = this.header.getPageSize();
|
||||
int n2 = this.header.getPagesPerBlock();
|
||||
int n3 = n * n2;
|
||||
int n4 = (int)((this.io.length() - this.header.getDataOffset()) / (long)n3);
|
||||
Block block = new Block(this, n4);
|
||||
block.clear();
|
||||
this.io.seek(this.io.length());
|
||||
block.write(this.io);
|
||||
this.freeMap.addFreePages(this.header.getPagesPerBlock());
|
||||
}
|
||||
|
||||
synchronized Block getBlock(int n) throws IOException {
|
||||
Block block = this.blockCache.getBlock(n);
|
||||
if (block == null) {
|
||||
block = this.readBlock(n);
|
||||
this.blockCache.add(block);
|
||||
}
|
||||
return block;
|
||||
}
|
||||
|
||||
synchronized Block readBlock(int n) throws IOException {
|
||||
Block block = new Block(this, n);
|
||||
long l = this.header.getDataOffset() + (long)(n * block.getSize());
|
||||
this.io.seek(l);
|
||||
block.read(this.io);
|
||||
return block;
|
||||
}
|
||||
|
||||
synchronized void writeBlock(Block block) throws IOException {
|
||||
if (!block.isDirty()) {
|
||||
return;
|
||||
}
|
||||
int n = block.getIndex();
|
||||
long l = this.header.getDataOffset() + (long)(n * block.getSize());
|
||||
this.io.seek(l);
|
||||
block.write(this.io);
|
||||
}
|
||||
|
||||
public BAlarmRecord readRecord(int n, BAlarmRecord bAlarmRecord) throws IOException {
|
||||
return this.readRecord(n, bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord readRecord(int n, BAlarmRecord bAlarmRecord, FreePageMap freePageMap) throws IOException {
|
||||
if (bAlarmRecord == null) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
}
|
||||
if (this.reader == null) {
|
||||
this.reader = new PageReader(this, n);
|
||||
} else {
|
||||
this.reader.init(n);
|
||||
}
|
||||
try {
|
||||
bAlarmRecord.read(this.reader);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return null;
|
||||
}
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decode((DataInput)this.reader);
|
||||
if (!bAlarmRecord.getUuid().equals((Object)bUuid)) {
|
||||
return null;
|
||||
}
|
||||
if (freePageMap != null) {
|
||||
int n2 = this.reader.getPageCount();
|
||||
int n3 = 0;
|
||||
while (n3 < n2) {
|
||||
freePageMap.setFree(this.reader.getPageIndex(n3), false);
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
|
||||
public synchronized void trimToCapacity() throws IOException {
|
||||
if (this.timestampIndex.getSize() > this.capacity) {
|
||||
if (this.trimRec == null) {
|
||||
this.trimRec = new BAlarmRecord();
|
||||
}
|
||||
while (this.timestampIndex.getSize() > this.capacity) {
|
||||
this.remove(this.timestampIndex.getFirstEntry(), this.trimRec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.close();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmClass;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmClass = AlarmStore.class("[Ljavax.baja.alarm.BAlarmClass;", false);
|
||||
}
|
||||
BAlarmClass[] bAlarmClassArray = (BAlarmClass[])this.alarmService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bAlarmClassArray.length) {
|
||||
bAlarmClassArray[n].setTotalAlarmCount(0);
|
||||
bAlarmClassArray[n].setUnackedAlarmCount(0);
|
||||
bAlarmClassArray[n].setOpenAlarmCount(0);
|
||||
bAlarmClassArray[n].setInAlarmCount(0);
|
||||
++n;
|
||||
}
|
||||
if (!this.alarmFile.delete()) {
|
||||
this.open();
|
||||
throw new IOException("Cannot delete alarm history file: " + this.alarmFile.getAbsolutePath());
|
||||
}
|
||||
this.open();
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
if (this.timestampIndex.getSize() == 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
while (this.timestampIndex.getSize() > 0) {
|
||||
IndexEntry indexEntry = this.timestampIndex.getFirstEntry();
|
||||
if (!indexEntry.timestamp.isBefore(bAbsTime)) break;
|
||||
this.remove(indexEntry, bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
if (this.byUuid.size() == 0) {
|
||||
return;
|
||||
}
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
IndexEntry indexEntry = (IndexEntry)this.byUuid.get(bUuid);
|
||||
if (indexEntry != null) {
|
||||
this.remove(indexEntry, bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public void analyze(PrintStream printStream) {
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###,###,###,###");
|
||||
DecimalFormat decimalFormat2 = new DecimalFormat("###,###,###.##");
|
||||
DecimalFormat decimalFormat3 = new DecimalFormat("###,###,###");
|
||||
printStream.println("db file : " + this.alarmFile.getAbsolutePath());
|
||||
printStream.println("file size : " + decimalFormat.format(this.alarmFile.length()));
|
||||
printStream.println("capacity : " + this.capacity);
|
||||
printStream.println("record count: " + this.timestampIndex.getSize());
|
||||
printStream.println("free map : " + decimalFormat3.format(this.freeMap.getSizeInBytes()) + " bytes");
|
||||
this.timestampIndex.analyze("timestamp index", printStream);
|
||||
printStream.println();
|
||||
int n = this.timestampIndex.getSize() * 21;
|
||||
printStream.println("non-list entry ram: " + decimalFormat2.format((double)n / 1024.0 / 1024.0) + " MB");
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public AlarmStore(File file, int n) {
|
||||
this.alarmFile = file;
|
||||
this.capacity = n;
|
||||
this.alarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
|
||||
private static class TimestampCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
if (indexEntry.nextTimestamp == null) {
|
||||
return null;
|
||||
}
|
||||
return indexEntry.nextTimestamp[0];
|
||||
}
|
||||
|
||||
public TimestampCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SourceCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
if (indexEntry.nextSource == null) {
|
||||
return null;
|
||||
}
|
||||
return indexEntry.nextSource[0];
|
||||
}
|
||||
|
||||
public SourceCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class OpenCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
return indexEntry.nextOpen;
|
||||
}
|
||||
|
||||
public OpenCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AckPendingCursor
|
||||
extends AlarmStoreCursor {
|
||||
public IndexEntry nextEntry(IndexEntry indexEntry) {
|
||||
return indexEntry.nextAckPending;
|
||||
}
|
||||
|
||||
public AckPendingCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
super(alarmStore, indexEntry, bAbsTime);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private static abstract class AlarmStoreCursor
|
||||
implements Cursor {
|
||||
boolean init = true;
|
||||
AlarmStore store;
|
||||
IndexEntry entry;
|
||||
BAlarmRecord rec;
|
||||
BAbsTime endTime;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Context getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.init) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
if (this.entry != null) {
|
||||
return this.rec;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
* Converted monitor instructions to comments
|
||||
* Lifted jumps to return sites
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.entry == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.init) {
|
||||
this.init = false;
|
||||
try {
|
||||
AlarmStore alarmStore = this.store;
|
||||
// MONITORENTER : alarmStore
|
||||
if (this.store.io == null) {
|
||||
throw new IllegalStateException("Alarm database is closed.");
|
||||
}
|
||||
if (-1 == this.store.readPage(this.entry.pageIndex).getPageOfRecord()) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
if (!this.store.readRecord(this.entry.pageIndex, this.rec).getTimestamp().equals((Object)this.entry.timestamp)) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
// MONITOREXIT : alarmStore
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return false;
|
||||
}
|
||||
if (this.endTime == null) return true;
|
||||
if (!this.rec.getTimestamp().isAfter(this.endTime)) return true;
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
this.entry = this.nextEntry(this.entry);
|
||||
if (this.entry == null) {
|
||||
this.rec = null;
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
AlarmStore alarmStore = this.store;
|
||||
// MONITORENTER : alarmStore
|
||||
if (this.store.io == null) {
|
||||
throw new IllegalStateException("Alarm database is closed.");
|
||||
}
|
||||
if (-1 == this.store.readPage(this.entry.pageIndex).getPageOfRecord()) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
if (!this.store.readRecord(this.entry.pageIndex, this.rec).getTimestamp().equals((Object)this.entry.timestamp)) {
|
||||
// MONITOREXIT : alarmStore
|
||||
return false;
|
||||
}
|
||||
// MONITOREXIT : alarmStore
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Unable to read record", (Throwable)exception);
|
||||
return false;
|
||||
}
|
||||
if (this.endTime == null) return true;
|
||||
if (!this.rec.getTimestamp().isAfter(this.endTime)) return true;
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = AlarmStoreCursor.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.equals(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract IndexEntry nextEntry(IndexEntry var1);
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public AlarmStoreCursor(AlarmStore alarmStore, IndexEntry indexEntry, BAbsTime bAbsTime) {
|
||||
this.store = alarmStore;
|
||||
this.entry = indexEntry;
|
||||
this.rec = new BAlarmRecord();
|
||||
this.endTime = bAbsTime;
|
||||
if (this.endTime != null && this.endTime.isNull()) {
|
||||
this.endTime = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.io.ByteBuffer
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmStoreHeader {
|
||||
private static final int MAGIC = 1611526157;
|
||||
private static final int LATEST_VERSION = 1;
|
||||
private static final int DEFAULT_HEADER_SIZE = 1024;
|
||||
private static final int DEFAULT_PAGE_SIZE = 512;
|
||||
private static final int DEFAULT_PAGES_PER_BLOCK = 8;
|
||||
private long creationTime;
|
||||
private int version;
|
||||
private int recordVersion;
|
||||
private long dataOffset;
|
||||
private int pageSize;
|
||||
private int pagesPerBlock;
|
||||
private boolean newStore;
|
||||
private ByteBuffer writeBuffer;
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
if (this.writeBuffer == null) {
|
||||
this.writeBuffer = new ByteBuffer(1024);
|
||||
} else {
|
||||
this.writeBuffer.reset();
|
||||
}
|
||||
this.writeBuffer.writeInt(1611526157);
|
||||
this.writeBuffer.writeInt(this.version);
|
||||
this.writeBuffer.writeInt(this.recordVersion);
|
||||
this.writeBuffer.writeLong(this.creationTime);
|
||||
this.writeBuffer.writeInt(this.pageSize);
|
||||
this.writeBuffer.writeInt(this.pagesPerBlock);
|
||||
int n = this.writeBuffer.getLength();
|
||||
int n2 = n + 8;
|
||||
if (this.newStore) {
|
||||
this.writeBuffer.writeTo(dataOutput, 0, n);
|
||||
this.dataOffset = Math.max(n2, 1024);
|
||||
dataOutput.writeLong(this.dataOffset);
|
||||
int n3 = (int)this.dataOffset - n2;
|
||||
dataOutput.write(new byte[n3]);
|
||||
} else {
|
||||
if ((long)n2 > this.dataOffset) {
|
||||
throw new IOException("Header overflow: " + n2 + " > " + this.dataOffset);
|
||||
}
|
||||
this.writeBuffer.writeTo(dataOutput, 0, n);
|
||||
dataOutput.writeLong(this.dataOffset);
|
||||
}
|
||||
}
|
||||
|
||||
public void read(DataInput dataInput) throws IOException {
|
||||
this.newStore = false;
|
||||
int n = dataInput.readInt();
|
||||
if (n != 1611526157) {
|
||||
throw new IOException("Invalid or corrupt alarm database.");
|
||||
}
|
||||
this.version = dataInput.readInt();
|
||||
if (this.version != 1) {
|
||||
throw new IOException("Unrecognized alarm db version: " + this.version);
|
||||
}
|
||||
this.recordVersion = dataInput.readInt();
|
||||
this.creationTime = dataInput.readLong();
|
||||
this.pageSize = dataInput.readInt();
|
||||
this.pagesPerBlock = dataInput.readInt();
|
||||
this.dataOffset = dataInput.readLong();
|
||||
}
|
||||
|
||||
public int getRecordVersion() {
|
||||
return this.recordVersion;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return this.pageSize;
|
||||
}
|
||||
|
||||
public int getPagesPerBlock() {
|
||||
return this.pagesPerBlock;
|
||||
}
|
||||
|
||||
public long getDataOffset() {
|
||||
return this.dataOffset;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.newStore = true;
|
||||
}
|
||||
|
||||
public AlarmStoreHeader() {
|
||||
this(0);
|
||||
}
|
||||
|
||||
public AlarmStoreHeader(int n) {
|
||||
this.this();
|
||||
this.version = 1;
|
||||
this.creationTime = System.currentTimeMillis();
|
||||
this.pageSize = 512;
|
||||
this.pagesPerBlock = 8;
|
||||
this.recordVersion = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,575 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.platform.BSystemPlatformService
|
||||
* com.tridium.platform.archive.FileArchive
|
||||
* com.tridium.sys.Nre
|
||||
* com.tridium.sys.resource.ResourceReport
|
||||
* com.tridium.sys.service.BServiceEvent
|
||||
* com.tridium.sys.service.ServiceListener
|
||||
* javax.baja.dataRecovery.BIDataRecoveryService
|
||||
* javax.baja.dataRecovery.BIDataRecoverySource
|
||||
* javax.baja.dataRecovery.IDataRecoveryRecord
|
||||
* javax.baja.file.BDirectory
|
||||
* javax.baja.file.BFileSpace
|
||||
* javax.baja.file.BIFile
|
||||
* javax.baja.file.BLocalFileStore
|
||||
* javax.baja.file.FilePath
|
||||
* javax.baja.io.BIEncodable
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.security.AuditEvent
|
||||
* javax.baja.security.Auditor
|
||||
* javax.baja.spy.SpyWriter
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BLong
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.ServiceNotFoundException
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.DataRecoveryAlarmEvent;
|
||||
import com.tridium.platform.BSystemPlatformService;
|
||||
import com.tridium.platform.archive.FileArchive;
|
||||
import com.tridium.sys.Nre;
|
||||
import com.tridium.sys.resource.ResourceReport;
|
||||
import com.tridium.sys.service.BServiceEvent;
|
||||
import com.tridium.sys.service.ServiceListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.dataRecovery.BIDataRecoveryService;
|
||||
import javax.baja.dataRecovery.BIDataRecoverySource;
|
||||
import javax.baja.dataRecovery.IDataRecoveryRecord;
|
||||
import javax.baja.file.BDirectory;
|
||||
import javax.baja.file.BFileSpace;
|
||||
import javax.baja.file.BIFile;
|
||||
import javax.baja.file.BLocalFileStore;
|
||||
import javax.baja.file.FilePath;
|
||||
import javax.baja.io.BIEncodable;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.security.AuditEvent;
|
||||
import javax.baja.security.Auditor;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BLong;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFileAlarmDatabase
|
||||
extends BAlarmDatabase
|
||||
implements BIDataRecoverySource {
|
||||
public static final Type TYPE;
|
||||
private static final BOrd ordInSession;
|
||||
private static final String CAPACITY = "capacity";
|
||||
private static final String ARCHIVE_ID = "alarm";
|
||||
private static final Log dataRecoveryLog;
|
||||
private ServiceListener serviceListener;
|
||||
private int capacity;
|
||||
private File dbDir;
|
||||
private File alarmFile;
|
||||
private AlarmStore alarmStore;
|
||||
private BOrd alarmServiceOrd;
|
||||
private BIDataRecoveryService dataRecoveryService;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$file$BFileAlarmDatabase;
|
||||
|
||||
public void doOpen() throws IOException {
|
||||
Object object;
|
||||
if (this.dbDir == null) {
|
||||
try {
|
||||
FilePath filePath;
|
||||
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)Sys.getService((Type)BSystemPlatformService.TYPE);
|
||||
if (bSystemPlatformService.archiveEnabled(ARCHIVE_ID)) {
|
||||
bSystemPlatformService.extractArchive(ARCHIVE_ID);
|
||||
}
|
||||
String string = bSystemPlatformService.getRuntimeDirectory(ARCHIVE_ID);
|
||||
object = (BFileSpace)BOrd.make((String)"file:").get();
|
||||
BIFile bIFile = object.findFile(filePath = new FilePath(string));
|
||||
if (bIFile == null) {
|
||||
BDirectory bDirectory = object.makeDir(filePath);
|
||||
this.dbDir = ((BLocalFileStore)bDirectory.getStore()).getLocalFile();
|
||||
} else {
|
||||
this.dbDir = ((BLocalFileStore)bIFile.getStore()).getLocalFile();
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
if (Sys.getStation() != null) {
|
||||
log.warning("No system platform service available, using station home directory for alarm database root.");
|
||||
this.dbDir = new File(Sys.getBajaHome().getAbsolutePath() + File.separatorChar + "stations" + File.separatorChar + Sys.getStation().getStationName() + File.separatorChar + ARCHIVE_ID);
|
||||
}
|
||||
log.warning("No system platform service available, using Niagara home directory for alarm database root.");
|
||||
this.dbDir = new File(Sys.getBajaHome().getAbsolutePath() + File.separatorChar + ARCHIVE_ID);
|
||||
}
|
||||
}
|
||||
if (!this.dbDir.exists()) {
|
||||
this.dbDir.mkdirs();
|
||||
}
|
||||
this.alarmFile = new File(this.dbDir, "alarm.adb");
|
||||
if (!this.alarmFile.exists()) {
|
||||
this.alarmFile.createNewFile();
|
||||
}
|
||||
int n = 0;
|
||||
while (true) {
|
||||
try {
|
||||
this.alarmStore = new AlarmStore(this.alarmFile, this.capacity);
|
||||
this.alarmStore.open();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BAlarmDatabase.log.error("Cannot open alarm database.", (Throwable)exception);
|
||||
if (!this.alarmFile.exists() || ++n == 2) break;
|
||||
if (Nre.getPlatform().isFlashFileSystem()) {
|
||||
if (this.alarmFile.delete()) {
|
||||
BAlarmDatabase.log.error("Old alarm database deleted.");
|
||||
continue;
|
||||
}
|
||||
throw new IOException("Unable to delete old alarm database.");
|
||||
}
|
||||
object = this.saveErrorDb();
|
||||
if (object == null) continue;
|
||||
BAlarmDatabase.log.error("Old alarm database saved as " + ((File)object).getAbsolutePath() + '.');
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.alarmServiceOrd = Sys.getService((Type)BAlarmService.TYPE).getOrdInSession();
|
||||
try {
|
||||
this.dataRecoveryService = (BIDataRecoveryService)Sys.getService((Type)BIDataRecoveryService.TYPE);
|
||||
if (!this.dataRecoveryService.isEnabled()) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {}
|
||||
Nre.serviceManager.addServiceListener(this.serviceListener);
|
||||
}
|
||||
|
||||
private final File saveErrorDb() throws IOException {
|
||||
String[] stringArray = this.dbDir.list();
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
while (n2 < stringArray.length) {
|
||||
if (stringArray[n2].indexOf("error") != -1) {
|
||||
++n;
|
||||
}
|
||||
if (n == 3) {
|
||||
throw new IOException("Cannot create recovery file. " + n + " recovery files already exist.");
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
File file = new File(this.dbDir, "alarm_error.adb");
|
||||
if (file.exists()) {
|
||||
int n3 = 2;
|
||||
while (file.exists()) {
|
||||
file = new File(this.dbDir, "alarm_error" + n3 + ".adb");
|
||||
++n3;
|
||||
}
|
||||
}
|
||||
if (!this.alarmFile.renameTo(file)) {
|
||||
throw new IOException("Unable to create recovery file.");
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public void doSave() throws IOException {
|
||||
try {
|
||||
BSystemPlatformService bSystemPlatformService = (BSystemPlatformService)Sys.getService((Type)BSystemPlatformService.TYPE);
|
||||
if (bSystemPlatformService.archiveEnabled(ARCHIVE_ID)) {
|
||||
FileArchive fileArchive = bSystemPlatformService.createFileArchive(ARCHIVE_ID);
|
||||
String string = this.dbDir.getAbsolutePath();
|
||||
String string2 = this.alarmFile.getAbsolutePath().substring(string.length() + 1);
|
||||
fileArchive.writeFile(this.alarmFile, string2);
|
||||
fileArchive.close();
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
log.error("No system platform service available, cannot create alarm archive file.");
|
||||
throw new IOException("Could not create alarm archive file.");
|
||||
}
|
||||
}
|
||||
|
||||
public void doFlush() throws IOException {
|
||||
this.alarmStore.flush();
|
||||
}
|
||||
|
||||
public void doClose() {
|
||||
this.alarmStore.close();
|
||||
this.alarmStore = null;
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)bAlarmRecord.getUuid(), new DataRecoveryAlarmEvent.Append(bAlarmRecord).encode());
|
||||
}
|
||||
this.alarmStore.append(bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.update((BIDataRecoverySource)this, (BIEncodable)bAlarmRecord.getUuid(), new DataRecoveryAlarmEvent.Update(bAlarmRecord).encode());
|
||||
}
|
||||
this.alarmStore.update(bAlarmRecord);
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getRecordCount();
|
||||
}
|
||||
|
||||
public synchronized BAlarmRecord getRecord(BUuid bUuid) throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getRecord(bUuid);
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.scan();
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.timeQuery(bAbsTime, bAbsTime2);
|
||||
}
|
||||
|
||||
public synchronized Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getAlarmsForSource(bOrdList);
|
||||
}
|
||||
|
||||
public synchronized Cursor getOpenAlarms() throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getOpenAlarms();
|
||||
}
|
||||
|
||||
public synchronized Cursor getAckPendingAlarms() throws IOException {
|
||||
this.assertOpen();
|
||||
return this.alarmStore.getAckPendingAlarms();
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BString.make((String)"clearAll"), new DataRecoveryAlarmEvent.ClearAll().encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearAllRecords(context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear", Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BLong.make((long)Clock.ticks()), new DataRecoveryAlarmEvent.ClearOld(bAbsTime).encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearOldRecords(bAbsTime, context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear before " + bAbsTime.toString((Context)BAlarmRecord.TIMESTAMP_FACETS), Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
if (bUuid == null || bUuid.isNull()) {
|
||||
return;
|
||||
}
|
||||
this.assertOpen();
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)bUuid, new DataRecoveryAlarmEvent.ClearRecord(bUuid).encode());
|
||||
}
|
||||
Auditor auditor = Nre.auditor;
|
||||
int n = this.getRecordCount();
|
||||
this.alarmStore.clearRecord(bUuid, context);
|
||||
if (auditor != null) {
|
||||
String string = "";
|
||||
if (context != null && context.getUser() != null) {
|
||||
string = context.getUser().getUsername();
|
||||
}
|
||||
auditor.audit(new AuditEvent("Invoked", "Alarm Database", "Clear record " + bUuid, Integer.toString(n) + " records", Integer.toString(this.getRecordCount()) + " records", string));
|
||||
}
|
||||
}
|
||||
|
||||
public void setCapacity(int n) throws IOException {
|
||||
if (this.capacity == n) {
|
||||
return;
|
||||
}
|
||||
if (this.dataRecoveryService != null) {
|
||||
this.dataRecoveryService.append((BIDataRecoverySource)this, (BIEncodable)BString.make((String)CAPACITY), new DataRecoveryAlarmEvent.CapacityChange(n).encode());
|
||||
}
|
||||
this.capacity = n;
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
this.alarmStore.setCapacity(this.capacity);
|
||||
this.alarmStore.trimToCapacity();
|
||||
}
|
||||
|
||||
public BOrd getOrdInSession() throws Exception {
|
||||
return ordInSession;
|
||||
}
|
||||
|
||||
public void dataRecoveryRestoreComplete() {
|
||||
}
|
||||
|
||||
public boolean dataRecoveryRestore(IDataRecoveryRecord iDataRecoveryRecord) throws Exception {
|
||||
DataRecoveryAlarmEvent dataRecoveryAlarmEvent = null;
|
||||
try {
|
||||
dataRecoveryAlarmEvent = DataRecoveryAlarmEvent.make(iDataRecoveryRecord.getData());
|
||||
dataRecoveryAlarmEvent.execute(this);
|
||||
if (dataRecoveryLog.isTraceOn()) {
|
||||
dataRecoveryLog.trace("Restored alarm event " + dataRecoveryAlarmEvent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (dataRecoveryAlarmEvent == null) {
|
||||
dataRecoveryLog.error("Could not restore event", (Throwable)exception);
|
||||
} else {
|
||||
dataRecoveryLog.error("Could not restore event " + dataRecoveryAlarmEvent, (Throwable)exception);
|
||||
}
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
public void dataRecoverySpy(SpyWriter spyWriter, Iterator iterator) throws Exception {
|
||||
Object object;
|
||||
Object object2;
|
||||
IDataRecoveryRecord iDataRecoveryRecord;
|
||||
DataRecoveryAlarmEvent dataRecoveryAlarmEvent = null;
|
||||
HashMap<Object, DataRecoveryAlarmSpyData> hashMap = new HashMap<Object, DataRecoveryAlarmSpyData>();
|
||||
int n = 0;
|
||||
while (iterator.hasNext()) {
|
||||
try {
|
||||
++n;
|
||||
iDataRecoveryRecord = (IDataRecoveryRecord)iterator.next();
|
||||
dataRecoveryAlarmEvent = DataRecoveryAlarmEvent.make(iDataRecoveryRecord.getData());
|
||||
object2 = new Integer(dataRecoveryAlarmEvent.getEventCode());
|
||||
object = (DataRecoveryAlarmSpyData)hashMap.get(object2);
|
||||
if (object == null) {
|
||||
hashMap.put(object2, new DataRecoveryAlarmSpyData(iDataRecoveryRecord.getData().length));
|
||||
continue;
|
||||
}
|
||||
hashMap.put(object2, ((DataRecoveryAlarmSpyData)object).addEvent(iDataRecoveryRecord.getData().length));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
iDataRecoveryRecord = hashMap.keySet().iterator();
|
||||
object2 = n + " Alarm Events Recently Recorded in Data Recovery";
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle(object2, 4);
|
||||
spyWriter.w((Object)"<tr><th>Event</th><th>Occurrences</th><th>Total Bytes</th><th>Avg Bytes</th></tr>\n");
|
||||
while (iDataRecoveryRecord.hasNext()) {
|
||||
try {
|
||||
String string;
|
||||
object = (Integer)iDataRecoveryRecord.next();
|
||||
DataRecoveryAlarmSpyData dataRecoveryAlarmSpyData = (DataRecoveryAlarmSpyData)hashMap.get(object);
|
||||
switch ((Integer)object) {
|
||||
case 0: {
|
||||
string = "Append";
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
string = "Update";
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
string = "ClearAll";
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
string = "ClearOld";
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
string = "ClearRecord";
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
string = "CapacityChange";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new IllegalStateException("Unknown alarm event code: '" + object + '\'');
|
||||
}
|
||||
}
|
||||
spyWriter.tr((Object)string, (Object)("" + dataRecoveryAlarmSpyData.occurances), (Object)("" + dataRecoveryAlarmSpyData.totalBytes), (Object)("" + (double)dataRecoveryAlarmSpyData.totalBytes / (double)dataRecoveryAlarmSpyData.occurances));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
spyWriter.endTable();
|
||||
}
|
||||
|
||||
private final BIDataRecoveryService getDataRecoveryService() {
|
||||
if (this.dataRecoveryService == null) {
|
||||
try {
|
||||
this.dataRecoveryService = (BIDataRecoveryService)Sys.getService((Type)BIDataRecoveryService.TYPE);
|
||||
if (!this.dataRecoveryService.isEnabled()) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
return this.dataRecoveryService;
|
||||
}
|
||||
|
||||
public final Object fw(int n, Object object, Object object2, Object object3, Object object4) {
|
||||
switch (n) {
|
||||
case 21: {
|
||||
((ResourceReport)object).add(ARCHIVE_ID, this.countResourceUnits());
|
||||
break;
|
||||
}
|
||||
case 602: {
|
||||
return this.alarmStore;
|
||||
}
|
||||
}
|
||||
return super.fw(n, object, object2, object3, object4);
|
||||
}
|
||||
|
||||
private final int countResourceUnits() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static void main(String[] stringArray) throws Exception {
|
||||
try {
|
||||
String string = stringArray[0];
|
||||
if (string.equals("o")) {
|
||||
BFileAlarmDatabase bFileAlarmDatabase = new BFileAlarmDatabase();
|
||||
bFileAlarmDatabase.open();
|
||||
System.out.println("Done.");
|
||||
bFileAlarmDatabase.close();
|
||||
}
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.serviceListener = new ServiceListener(){
|
||||
|
||||
public final void serviceEvent(BServiceEvent bServiceEvent) {
|
||||
if (bServiceEvent.getServiceType().is(BIDataRecoveryService.TYPE)) {
|
||||
if (bServiceEvent.getId() == 0) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = (BIDataRecoveryService)bServiceEvent.getService();
|
||||
if (!BFileAlarmDatabase.this.dataRecoveryService.isEnabled()) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = null;
|
||||
}
|
||||
} else if (bServiceEvent.getId() == 1) {
|
||||
BFileAlarmDatabase.this.dataRecoveryService = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return "ServiceListener for AlarmService";
|
||||
}
|
||||
};
|
||||
this.capacity = 10000;
|
||||
this.dbDir = null;
|
||||
this.alarmFile = null;
|
||||
this.alarmStore = null;
|
||||
this.alarmServiceOrd = null;
|
||||
this.dataRecoveryService = null;
|
||||
}
|
||||
|
||||
public BFileAlarmDatabase() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$file$BFileAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$file$BFileAlarmDatabase = BFileAlarmDatabase.class("[Lcom.tridium.alarm.db.file.BFileAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
ordInSession = BOrd.make((String)"alarm:");
|
||||
dataRecoveryLog = Log.getLog((String)"alarm.dataRecovery");
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class DataRecoveryAlarmSpyData {
|
||||
int occurances;
|
||||
int totalBytes;
|
||||
|
||||
public DataRecoveryAlarmSpyData addEvent(int n) {
|
||||
++this.occurances;
|
||||
this.totalBytes += n;
|
||||
return this;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.occurances = -1;
|
||||
this.totalBytes = -1;
|
||||
}
|
||||
|
||||
public DataRecoveryAlarmSpyData(int n) {
|
||||
this.this();
|
||||
this.occurances = 1;
|
||||
this.totalBytes = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Block {
|
||||
private AlarmStore store;
|
||||
private int index;
|
||||
private byte[] data;
|
||||
private Page[] pages;
|
||||
private Input in;
|
||||
private Output out;
|
||||
private boolean dirty;
|
||||
Block prev;
|
||||
Block next;
|
||||
|
||||
public int getSize() {
|
||||
return this.data.length;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return this.dirty;
|
||||
}
|
||||
|
||||
public void clear() throws IOException {
|
||||
int n = 0;
|
||||
while (n < this.pages.length) {
|
||||
this.pages[n] = new Page(this, n, this.store.getHeader().getPageSize());
|
||||
this.pages[n].clear();
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public void read(DataInput dataInput) throws IOException {
|
||||
dataInput.readFully(this.data);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public void write(DataOutput dataOutput) throws IOException {
|
||||
dataOutput.write(this.data);
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public synchronized Page getPage(int n) throws IOException {
|
||||
if (this.pages == null) {
|
||||
this.pages = new Page[this.store.getHeader().getPagesPerBlock()];
|
||||
}
|
||||
try {
|
||||
if (this.pages[n] == null) {
|
||||
this.pages[n] = this.initPage(n);
|
||||
}
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
|
||||
int n2 = this.store.getHeader().getPagesPerBlock();
|
||||
throw new IllegalArgumentException("Invalid page index: " + n + ". Pages per block = " + n2);
|
||||
}
|
||||
return this.pages[n];
|
||||
}
|
||||
|
||||
private final Page initPage(int n) throws IOException {
|
||||
Page page = new Page(this, n, this.store.getHeader().getPageSize());
|
||||
page.read();
|
||||
return page;
|
||||
}
|
||||
|
||||
public void dump() throws IOException {
|
||||
int n = this.store.getHeader().getPagesPerBlock();
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
Page page = this.getPage(n2);
|
||||
System.out.println(n2 + "] " + page.getPageOfRecord() + " of " + page.getPagesOfRecord());
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
public Input getInput() {
|
||||
return this.in;
|
||||
}
|
||||
|
||||
public int write(int n, int n2) {
|
||||
this.data[n] = (byte)n2;
|
||||
this.dirty = true;
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
public int write(int n, byte[] byArray, int n2, int n3) {
|
||||
System.arraycopy(byArray, n2, this.data, n, n3);
|
||||
this.dirty = true;
|
||||
return n + n3;
|
||||
}
|
||||
|
||||
public int writeInt(int n, int n2) {
|
||||
this.write(n++, n2 >>> 24 & 0xFF);
|
||||
this.write(n++, n2 >>> 16 & 0xFF);
|
||||
this.write(n++, n2 >>> 8 & 0xFF);
|
||||
this.write(n++, n2 & 0xFF);
|
||||
return n;
|
||||
}
|
||||
|
||||
public Output getOutput() {
|
||||
return this.out;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
public Block(AlarmStore alarmStore, int n) {
|
||||
this.this();
|
||||
this.store = alarmStore;
|
||||
this.index = n;
|
||||
int n2 = alarmStore.getHeader().getPageSize();
|
||||
int n3 = alarmStore.getHeader().getPagesPerBlock();
|
||||
this.data = new byte[n2 * n3];
|
||||
this.pages = new Page[n3];
|
||||
this.out = new Output(this);
|
||||
this.in = new Input(this.data);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Output {
|
||||
private Block block;
|
||||
private int pos;
|
||||
|
||||
public void seek(int n) {
|
||||
this.pos = n;
|
||||
}
|
||||
|
||||
public void write(int n) {
|
||||
this.block.write(this.pos++, n);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray) {
|
||||
this.pos = this.block.write(this.pos, byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void write(byte[] byArray, int n, int n2) {
|
||||
this.pos = this.block.write(this.pos, byArray, n, n2);
|
||||
}
|
||||
|
||||
public void writeInt(int n) {
|
||||
this.pos = this.block.writeInt(this.pos, n);
|
||||
}
|
||||
|
||||
public Output(Block block2) {
|
||||
this.block = block2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class Input {
|
||||
private byte[] buffer;
|
||||
private int length;
|
||||
private int pos;
|
||||
|
||||
public void seek(int n) {
|
||||
this.pos = n;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
try {
|
||||
return this.buffer[this.pos++] & 0xFF;
|
||||
}
|
||||
catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3 = Math.min(n2, this.length - this.pos);
|
||||
if (n3 == 0) {
|
||||
return -1;
|
||||
}
|
||||
System.arraycopy(this.buffer, this.pos, byArray, n, n3);
|
||||
this.pos += n3;
|
||||
return n3;
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray) throws IOException {
|
||||
this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray, int n, int n2) throws IOException {
|
||||
this.read(byArray, n, n2);
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (this.read() << 24) + (this.read() << 16) + (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public Input(byte[] byArray) {
|
||||
this.buffer = byArray;
|
||||
this.length = byArray.length;
|
||||
this.pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.IntHashMap
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import java.io.IOException;
|
||||
import javax.baja.nre.util.IntHashMap;
|
||||
|
||||
public class BlockCache {
|
||||
private AlarmStore store;
|
||||
private int max;
|
||||
private int size;
|
||||
private IntHashMap table;
|
||||
private Block newest;
|
||||
private Block oldest;
|
||||
|
||||
public synchronized Block getBlock(int n) {
|
||||
return (Block)this.table.get(n);
|
||||
}
|
||||
|
||||
public synchronized void add(Block block) throws IOException {
|
||||
int n = block.getIndex();
|
||||
Block block2 = (Block)this.table.get(n);
|
||||
if (block2 != null) {
|
||||
if (block2.prev != null) {
|
||||
block2.prev.next = block2.next;
|
||||
}
|
||||
if (block2.next != null) {
|
||||
block2.next.prev = block2.prev;
|
||||
}
|
||||
if (block2 == this.newest) {
|
||||
this.newest = block2.next;
|
||||
}
|
||||
if (block2 == this.oldest) {
|
||||
this.oldest = block2.prev;
|
||||
}
|
||||
block2.next = null;
|
||||
block2.prev = null;
|
||||
--this.size;
|
||||
}
|
||||
this.table.put(n, (Object)block);
|
||||
if (this.newest == null) {
|
||||
this.newest = this.oldest = block;
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
} else {
|
||||
this.newest.prev = block;
|
||||
block.next = this.newest;
|
||||
block.prev = null;
|
||||
this.newest = block;
|
||||
}
|
||||
++this.size;
|
||||
if (this.size > this.max) {
|
||||
this.evict(this.size - this.max);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(int n) {
|
||||
Block block = (Block)this.table.get(n);
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
this.table.remove(n);
|
||||
if (block.prev != null) {
|
||||
block.prev.next = block.next;
|
||||
}
|
||||
if (block.next != null) {
|
||||
block.next.prev = block.prev;
|
||||
}
|
||||
if (block == this.newest) {
|
||||
this.newest = block.next;
|
||||
}
|
||||
if (block == this.oldest) {
|
||||
this.oldest = block.prev;
|
||||
}
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public synchronized void remove(Block block) {
|
||||
this.remove(block.getIndex());
|
||||
}
|
||||
|
||||
public synchronized void flush() throws IOException {
|
||||
Block block = this.newest;
|
||||
while (block != null) {
|
||||
this.store.writeBlock(block);
|
||||
block = block.next;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void evict(int n) throws IOException {
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if (this.size == 0) {
|
||||
return;
|
||||
}
|
||||
this.store.writeBlock(this.oldest);
|
||||
this.table.remove(this.oldest.getIndex());
|
||||
if (this.newest == this.oldest) {
|
||||
this.oldest = null;
|
||||
this.newest = null;
|
||||
} else {
|
||||
Block block = this.oldest;
|
||||
this.oldest = this.oldest.prev;
|
||||
this.oldest.next = null;
|
||||
block.next = null;
|
||||
block.prev = null;
|
||||
}
|
||||
--this.size;
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
System.out.println("BlockCache.dump");
|
||||
System.out.println(" forward");
|
||||
int n = 0;
|
||||
Block block = this.newest;
|
||||
while (block != null) {
|
||||
System.out.print(" " + n++ + ") block " + block.getIndex());
|
||||
if (block == this.oldest) {
|
||||
System.out.print(" (oldest)");
|
||||
}
|
||||
if (block == this.newest) {
|
||||
System.out.print(" (newest)");
|
||||
}
|
||||
System.out.println();
|
||||
block = block.next;
|
||||
}
|
||||
System.out.println(" reverse");
|
||||
--n;
|
||||
block = this.oldest;
|
||||
while (block != null) {
|
||||
System.out.print(" " + n-- + ") block " + block.getIndex());
|
||||
if (block == this.oldest) {
|
||||
System.out.print(" (oldest)");
|
||||
}
|
||||
if (block == this.newest) {
|
||||
System.out.print(" (newest)");
|
||||
}
|
||||
System.out.println();
|
||||
block = block.prev;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockCache(AlarmStore alarmStore, int n) {
|
||||
this.store = alarmStore;
|
||||
this.max = n;
|
||||
this.table = new IntHashMap(this.max);
|
||||
this.size = 0;
|
||||
this.newest = null;
|
||||
this.oldest = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.dataRecovery.DataRecoveryException
|
||||
* javax.baja.io.ByteBuffer
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.BFileAlarmDatabase;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.dataRecovery.DataRecoveryException;
|
||||
import javax.baja.io.ByteBuffer;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public abstract class DataRecoveryAlarmEvent {
|
||||
static final byte EVENT_APPEND = 0;
|
||||
static final byte EVENT_UPDATE = 1;
|
||||
static final byte EVENT_CLEARALL = 2;
|
||||
static final byte EVENT_CLEAROLD = 3;
|
||||
static final byte EVENT_CLEARRECORD = 4;
|
||||
static final byte EVENT_CAPACITYCHANGE = 5;
|
||||
private int eventCode;
|
||||
|
||||
public static final DataRecoveryAlarmEvent make(byte[] byArray) throws Exception {
|
||||
ByteBuffer byteBuffer = new ByteBuffer(byArray);
|
||||
int n = -1;
|
||||
try {
|
||||
n = byteBuffer.readByte();
|
||||
switch (n) {
|
||||
case 0: {
|
||||
return new Append(byteBuffer);
|
||||
}
|
||||
case 1: {
|
||||
return new Update(byteBuffer);
|
||||
}
|
||||
case 2: {
|
||||
return new ClearAll(byteBuffer);
|
||||
}
|
||||
case 3: {
|
||||
return new ClearOld(byteBuffer);
|
||||
}
|
||||
case 4: {
|
||||
return new ClearRecord(byteBuffer);
|
||||
}
|
||||
case 5: {
|
||||
return new CapacityChange(byteBuffer);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown alarm event code: '" + n + '\'');
|
||||
}
|
||||
catch (IOException iOException) {
|
||||
throw new DataRecoveryException("Invalid alarm data (event=" + n + ", length=" + byArray.length + ')', (Throwable)iOException);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void execute(BFileAlarmDatabase var1) throws Exception;
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.writeByte(this.eventCode);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
protected final AlarmStore getAlarmStore(BFileAlarmDatabase bFileAlarmDatabase) {
|
||||
return (AlarmStore)bFileAlarmDatabase.fw(602, null, null, null, null);
|
||||
}
|
||||
|
||||
int getEventCode() {
|
||||
return this.eventCode;
|
||||
}
|
||||
|
||||
private DataRecoveryAlarmEvent(int n) {
|
||||
this.eventCode = n;
|
||||
}
|
||||
|
||||
public static class Append
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAlarmRecord record;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
BAlarmRecord bAlarmRecord = alarmStore.getRecord(this.record.getUuid());
|
||||
if (bAlarmRecord == null || bAlarmRecord.getLastUpdate().isBefore(this.record.getLastUpdate())) {
|
||||
this.getAlarmStore(bFileAlarmDatabase).append(this.record);
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).ackAlarm(this.record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.record.write((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Append ");
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
stringBuffer.append("and Route ");
|
||||
}
|
||||
stringBuffer.append(this.record.getUuid()).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public Append(BAlarmRecord bAlarmRecord) {
|
||||
super(0);
|
||||
this.record = bAlarmRecord;
|
||||
}
|
||||
|
||||
public Append(ByteBuffer byteBuffer) throws Exception {
|
||||
super(0);
|
||||
this.record = new BAlarmRecord();
|
||||
this.record.read((DataInput)byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Update
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAlarmRecord record;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
BAlarmRecord bAlarmRecord = alarmStore.getRecord(this.record.getUuid());
|
||||
if (bAlarmRecord == null || bAlarmRecord.getLastUpdate().isBefore(this.record.getLastUpdate())) {
|
||||
this.getAlarmStore(bFileAlarmDatabase).update(this.record);
|
||||
if (bAlarmRecord != null && bAlarmRecord.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
((BAlarmService)Sys.getService((Type)BAlarmService.TYPE)).ackAlarm(this.record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.record.write((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Update ");
|
||||
if (this.record.getAckState().equals((Object)BAckState.ackPending)) {
|
||||
stringBuffer.append("and Route ");
|
||||
}
|
||||
stringBuffer.append(this.record.getUuid()).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public Update(BAlarmRecord bAlarmRecord) {
|
||||
super(1);
|
||||
this.record = bAlarmRecord;
|
||||
}
|
||||
|
||||
public Update(ByteBuffer byteBuffer) throws Exception {
|
||||
super(1);
|
||||
this.record = new BAlarmRecord();
|
||||
this.record.read((DataInput)byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearAll
|
||||
extends DataRecoveryAlarmEvent {
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearAllRecords(null);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[ClearAll]";
|
||||
}
|
||||
|
||||
public ClearAll() {
|
||||
super(2);
|
||||
}
|
||||
|
||||
public ClearAll(ByteBuffer byteBuffer) {
|
||||
this();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearOld
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BAbsTime before;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearOldRecords(this.before, null);
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.before.encode((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[ClearOld ").append(this.before).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ClearOld(BAbsTime bAbsTime) {
|
||||
super(3);
|
||||
this.before = bAbsTime;
|
||||
}
|
||||
|
||||
public ClearOld(ByteBuffer byteBuffer) throws Exception {
|
||||
this(BAbsTime.make((long)byteBuffer.readLong()));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearRecord
|
||||
extends DataRecoveryAlarmEvent {
|
||||
BUuid uuid;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
this.getAlarmStore(bFileAlarmDatabase).clearRecord(this.uuid, null);
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
this.uuid.encode((DataOutput)byteBuffer);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[ClearRecord ").append(this.uuid).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public ClearRecord(BUuid bUuid) {
|
||||
super(4);
|
||||
this.uuid = bUuid;
|
||||
}
|
||||
|
||||
public ClearRecord(ByteBuffer byteBuffer) throws IOException {
|
||||
this((BUuid)BUuid.DEFAULT.decode((DataInput)byteBuffer));
|
||||
}
|
||||
}
|
||||
|
||||
public static class CapacityChange
|
||||
extends DataRecoveryAlarmEvent {
|
||||
int capacity;
|
||||
|
||||
public void execute(BFileAlarmDatabase bFileAlarmDatabase) throws IOException {
|
||||
AlarmStore alarmStore = this.getAlarmStore(bFileAlarmDatabase);
|
||||
alarmStore.setCapacity(this.capacity);
|
||||
alarmStore.trimToCapacity();
|
||||
}
|
||||
|
||||
public byte[] encode() throws IOException {
|
||||
ByteBuffer byteBuffer = new ByteBuffer();
|
||||
byteBuffer.write(super.encode());
|
||||
byteBuffer.writeInt(this.capacity);
|
||||
return byteBuffer.toByteArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("[Capacity ").append(this.capacity).append("]");
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public CapacityChange(int n) {
|
||||
super(5);
|
||||
this.capacity = n;
|
||||
}
|
||||
|
||||
public CapacityChange(ByteBuffer byteBuffer) throws Exception {
|
||||
this(byteBuffer.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
public class FreePageMap {
|
||||
private static final int[] BIT_MASKS = new int[]{1, 2, 4, 8, 16, 32, 64, 128};
|
||||
private int pageCount = 0;
|
||||
private byte[] pageMask = null;
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pageCount;
|
||||
}
|
||||
|
||||
public int getFreeCount() {
|
||||
int n;
|
||||
int n2;
|
||||
byte by;
|
||||
if (this.pageCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < this.pageMask.length - 1) {
|
||||
by = this.pageMask[n4];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < 8) {
|
||||
if ((by & n2) == 0) {
|
||||
++n3;
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
n4 = this.pageCount - (this.pageMask.length - 1) * 8;
|
||||
by = this.pageMask[this.pageMask.length - 1];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < n4) {
|
||||
if ((by & n2) == 0) {
|
||||
++n3;
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
return n3;
|
||||
}
|
||||
|
||||
public int getFreePage() {
|
||||
if (this.pageCount != 0) {
|
||||
int n = this.pageMask.length;
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if ((this.pageMask[n2] & 0xFF ^ 0xFF) != 0) {
|
||||
int n3 = 1;
|
||||
int n4 = 0;
|
||||
while (n4 < 8) {
|
||||
if ((this.pageMask[n2] & 0xFF & n3) == 0) {
|
||||
return n2 * 8 + n4;
|
||||
}
|
||||
n3 <<= 1;
|
||||
++n4;
|
||||
}
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean isFree(int n) {
|
||||
int n2 = n / 8;
|
||||
if (n2 >= this.pageCount) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
boolean bl = false;
|
||||
if ((this.pageMask[n2] & BIT_MASKS[n - n2 * 8]) == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public void setFree(int n, boolean bl) {
|
||||
if (n >= this.pageCount) {
|
||||
this.addFreePages(n - this.pageCount + 1);
|
||||
}
|
||||
int n2 = n / 8;
|
||||
int n3 = BIT_MASKS[n - n2 * 8];
|
||||
this.pageMask[n2] = bl ? (byte)(this.pageMask[n2] & ~n3) : (byte)(this.pageMask[n2] | n3);
|
||||
}
|
||||
|
||||
public void addFreePages(int n) {
|
||||
int n2;
|
||||
if (n < 0) {
|
||||
throw new IllegalArgumentException("Invalid add count: " + n);
|
||||
}
|
||||
if (this.pageMask == null) {
|
||||
int n3 = n / 8;
|
||||
if (n % 8 != 0) {
|
||||
++n3;
|
||||
}
|
||||
this.pageMask = new byte[n3];
|
||||
this.pageCount = n;
|
||||
return;
|
||||
}
|
||||
int n4 = this.pageMask.length * 8;
|
||||
int n5 = n4 - this.pageCount;
|
||||
if (n5 != 0) {
|
||||
n2 = n5 > n ? n : n5;
|
||||
this.pageCount += n2;
|
||||
n -= n2;
|
||||
}
|
||||
if (n == 0) {
|
||||
return;
|
||||
}
|
||||
n2 = n / 8;
|
||||
if (n % 8 != 0) {
|
||||
++n2;
|
||||
}
|
||||
int n6 = this.pageMask.length;
|
||||
byte[] byArray = new byte[n6 + n2];
|
||||
System.arraycopy(this.pageMask, 0, byArray, 0, n6);
|
||||
this.pageMask = byArray;
|
||||
this.pageCount += n;
|
||||
}
|
||||
|
||||
public int getSizeInBytes() {
|
||||
return this.pageMask.length;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
int n;
|
||||
int n2;
|
||||
byte by;
|
||||
if (this.pageCount == 0) {
|
||||
return;
|
||||
}
|
||||
int n3 = 0;
|
||||
int n4 = 0;
|
||||
while (n4 < this.pageMask.length - 1) {
|
||||
by = this.pageMask[n4];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < 8) {
|
||||
if ((by & n2) == 0) {
|
||||
System.out.println(n3++ + ") free");
|
||||
} else {
|
||||
System.out.println(n3++ + ") in use");
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
++n4;
|
||||
}
|
||||
n4 = this.pageCount - (this.pageMask.length - 1) * 8;
|
||||
by = this.pageMask[this.pageMask.length - 1];
|
||||
n2 = 1;
|
||||
n = 0;
|
||||
while (n < n4) {
|
||||
if ((by & n2) == 0) {
|
||||
System.out.println(n3++ + ") free");
|
||||
} else {
|
||||
System.out.println(n3++ + ") in use");
|
||||
}
|
||||
n2 <<= 1;
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class IndexEntry {
|
||||
public static final int FLAG_OPEN = 1;
|
||||
public static final int FLAG_ACKED = 2;
|
||||
public static final int FLAG_NORMAL = 4;
|
||||
public static final int FLAG_ACK_PENDING = 8;
|
||||
public final BAbsTime timestamp;
|
||||
public final int pageIndex;
|
||||
public IndexEntry[] nextTimestamp;
|
||||
public IndexEntry prevTimestamp;
|
||||
public IndexEntry[] nextSource;
|
||||
public IndexEntry prevSource;
|
||||
public byte flags;
|
||||
public IndexEntry prevOpen;
|
||||
public IndexEntry nextOpen;
|
||||
public IndexEntry prevAckPending;
|
||||
public IndexEntry nextAckPending;
|
||||
|
||||
public boolean equals(Object object) {
|
||||
IndexEntry indexEntry = (IndexEntry)object;
|
||||
if (this.timestamp == null && indexEntry.timestamp == null) {
|
||||
return true;
|
||||
}
|
||||
if (this.timestamp == null || indexEntry.timestamp == null) {
|
||||
return false;
|
||||
}
|
||||
boolean bl = false;
|
||||
if (this.timestamp.equals((Object)indexEntry.timestamp) && this.pageIndex == indexEntry.pageIndex) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean isOpen() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 1) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setOpen(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 1) : (byte)(this.flags & 0xFFFFFFFE);
|
||||
}
|
||||
|
||||
public final boolean isAcked() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 2) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setAcked(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 2) : (byte)(this.flags & 0xFFFFFFFD);
|
||||
}
|
||||
|
||||
public final boolean isNormal() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 4) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setNormal(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 4) : (byte)(this.flags & 0xFFFFFFFB);
|
||||
}
|
||||
|
||||
public final boolean isAckPending() {
|
||||
boolean bl = false;
|
||||
if ((this.flags & 8) != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final void setAckPending(boolean bl) {
|
||||
this.flags = bl ? (byte)(this.flags | 8) : (byte)(this.flags & 0xFFFFFFF7);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.flags = 0;
|
||||
}
|
||||
|
||||
public IndexEntry() {
|
||||
this.this();
|
||||
this.timestamp = null;
|
||||
this.pageIndex = -1;
|
||||
}
|
||||
|
||||
public IndexEntry(BAlarmRecord bAlarmRecord, int n) {
|
||||
this.this();
|
||||
this.timestamp = bAlarmRecord.getTimestamp();
|
||||
this.pageIndex = n;
|
||||
}
|
||||
|
||||
public IndexEntry(BAbsTime bAbsTime, int n) {
|
||||
this.this();
|
||||
this.timestamp = bAbsTime;
|
||||
this.pageIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.sys.BBoolean
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.sys.BBoolean;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class OpenIndex {
|
||||
private static final BFacets showSecs = BFacets.make((String)"showSeconds", (BIDataValue)BBoolean.TRUE);
|
||||
private IndexEntry first = null;
|
||||
private IndexEntry last = null;
|
||||
private int size = 0;
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void add(IndexEntry indexEntry) {
|
||||
if (indexEntry.isOpen()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setOpen(true);
|
||||
indexEntry.nextOpen = null;
|
||||
indexEntry.prevOpen = null;
|
||||
if (this.size == 0) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
IndexEntry indexEntry2 = indexEntry.prevTimestamp;
|
||||
while (indexEntry2 != null && !indexEntry2.isOpen()) {
|
||||
indexEntry2 = indexEntry2.prevTimestamp;
|
||||
}
|
||||
if (indexEntry2 == null) {
|
||||
if (this.first == null) {
|
||||
this.first = this.last = indexEntry;
|
||||
} else {
|
||||
indexEntry.nextOpen = this.first;
|
||||
this.first.prevOpen = indexEntry;
|
||||
this.first = indexEntry;
|
||||
}
|
||||
} else {
|
||||
indexEntry.nextOpen = indexEntry2.nextOpen;
|
||||
indexEntry.prevOpen = indexEntry2;
|
||||
if (indexEntry2.nextOpen != null) {
|
||||
indexEntry2.nextOpen.prevOpen = indexEntry;
|
||||
}
|
||||
indexEntry2.nextOpen = indexEntry;
|
||||
if (indexEntry.prevOpen == this.last) {
|
||||
this.last = indexEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0 || indexEntry == null) {
|
||||
return;
|
||||
}
|
||||
if (!indexEntry.isOpen()) {
|
||||
return;
|
||||
}
|
||||
indexEntry.setOpen(false);
|
||||
if (indexEntry.prevOpen != null) {
|
||||
indexEntry.prevOpen.nextOpen = indexEntry.nextOpen;
|
||||
}
|
||||
if (indexEntry.nextOpen != null) {
|
||||
indexEntry.nextOpen.prevOpen = indexEntry.prevOpen;
|
||||
}
|
||||
if (indexEntry == this.first) {
|
||||
this.first = indexEntry.nextOpen;
|
||||
}
|
||||
if (indexEntry == this.last) {
|
||||
this.last = indexEntry.prevOpen;
|
||||
}
|
||||
indexEntry.nextOpen = null;
|
||||
indexEntry.prevOpen = null;
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public void dump() {
|
||||
IndexEntry indexEntry = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ") " + indexEntry.timestamp.toString((Context)showSecs) + " open=" + indexEntry.isOpen());
|
||||
indexEntry = indexEntry.nextOpen;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.first;
|
||||
int n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isAfter(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is before " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isOpen()) {
|
||||
throw new IllegalStateException("Cleared alarm in open index, ascending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.nextOpen;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry = null;
|
||||
indexEntry2 = this.last;
|
||||
n = 0;
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && indexEntry.timestamp.isBefore(indexEntry2.timestamp)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + indexEntry2.timestamp.toString((Context)showSecs) + " is after " + indexEntry.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
if (!indexEntry2.isOpen()) {
|
||||
throw new IllegalStateException("Cleared alarm in open index, descending. " + indexEntry2.timestamp.toString((Context)showSecs));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = indexEntry2.prevOpen;
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.Block;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Page {
|
||||
public static final int HEADER_SIZE = 12;
|
||||
private Block block;
|
||||
private int pageInBlock;
|
||||
private int size;
|
||||
private int recPage;
|
||||
private int recPages;
|
||||
private int nextPage;
|
||||
|
||||
public int getPageOfRecord() {
|
||||
return this.recPage;
|
||||
}
|
||||
|
||||
public int getPagesOfRecord() {
|
||||
return this.recPages;
|
||||
}
|
||||
|
||||
public int getNextPage() {
|
||||
return this.nextPage;
|
||||
}
|
||||
|
||||
public synchronized void read() throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock);
|
||||
this.recPage = input.readInt();
|
||||
this.recPages = input.readInt();
|
||||
this.nextPage = input.readInt();
|
||||
}
|
||||
|
||||
public synchronized void write(int n, int n2, int n3, byte[] byArray, int n4, int n5) throws IOException {
|
||||
this.recPage = n;
|
||||
this.recPages = n2;
|
||||
this.nextPage = n3;
|
||||
Block.Output output = this.block.getOutput();
|
||||
output.seek(this.size * this.pageInBlock);
|
||||
output.writeInt(n);
|
||||
output.writeInt(n2);
|
||||
output.writeInt(n3);
|
||||
if (n5 != 0) {
|
||||
output.write(byArray, n4, n5);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() throws IOException {
|
||||
this.write(-1, 0, -1, null, 0, 0);
|
||||
}
|
||||
|
||||
public synchronized int readData(int n) throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock + 12 + n);
|
||||
return input.read();
|
||||
}
|
||||
|
||||
public synchronized int readData(int n, byte[] byArray, int n2, int n3) throws IOException {
|
||||
Block.Input input = this.block.getInput();
|
||||
input.seek(this.size * this.pageInBlock + 12 + n);
|
||||
int n4 = this.size - 12 - n;
|
||||
if (n4 < n3) {
|
||||
return input.read(byArray, n2, n4);
|
||||
}
|
||||
return input.read(byArray, n2, n3);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.recPage + " of " + this.recPages + ", next=" + this.nextPage;
|
||||
}
|
||||
|
||||
public Page(Block block, int n, int n2) {
|
||||
this.block = block;
|
||||
this.pageInBlock = n;
|
||||
this.size = n2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.Page;
|
||||
import java.io.DataInput;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.UTFDataFormatException;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class PageReader
|
||||
implements DataInput {
|
||||
private AlarmStore store;
|
||||
private int pageIndex;
|
||||
private Page page;
|
||||
private int pos;
|
||||
private int pageLen;
|
||||
private int[] pages;
|
||||
private int pageCount;
|
||||
|
||||
public void init(int n) throws IOException {
|
||||
this.pageIndex = n;
|
||||
if (this.pageIndex != -1) {
|
||||
this.page = this.store.readPage(this.pageIndex);
|
||||
}
|
||||
this.pos = 0;
|
||||
this.pageLen = this.store.getHeader().getPageSize() - 12;
|
||||
this.pageCount = 1;
|
||||
if (this.pages == null) {
|
||||
this.pages = new int[3];
|
||||
}
|
||||
this.pages[0] = n;
|
||||
}
|
||||
|
||||
private final void nextPage() throws IOException {
|
||||
if (this.page == null) {
|
||||
throw new IllegalStateException("PageReader has not been initialized.");
|
||||
}
|
||||
int n = this.page.getNextPage();
|
||||
if (n == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
this.pageIndex = n;
|
||||
this.page = this.store.readPage(this.pageIndex);
|
||||
this.pos = 0;
|
||||
if (this.pageCount == this.pages.length) {
|
||||
int[] nArray = new int[this.pageCount + 1];
|
||||
System.arraycopy(this.pages, 0, nArray, 0, this.pageCount);
|
||||
this.pages = nArray;
|
||||
}
|
||||
this.pages[this.pageCount++] = this.pageIndex;
|
||||
}
|
||||
|
||||
public int getPageCount() {
|
||||
return this.pageCount;
|
||||
}
|
||||
|
||||
public int getPageIndex(int n) {
|
||||
return this.pages[n];
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (this.pos >= this.pageLen) {
|
||||
this.nextPage();
|
||||
}
|
||||
return this.page.readData(this.pos++);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray) throws IOException {
|
||||
return this.read(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public int read(byte[] byArray, int n, int n2) throws IOException {
|
||||
if (this.pos >= this.pageLen) {
|
||||
this.nextPage();
|
||||
}
|
||||
int n3 = this.page.readData(this.pos, byArray, n, n2);
|
||||
this.pos += n3;
|
||||
return n3;
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray) throws IOException {
|
||||
this.readFully(byArray, 0, byArray.length);
|
||||
}
|
||||
|
||||
public void readFully(byte[] byArray, int n, int n2) throws IOException {
|
||||
int n3 = n2;
|
||||
int n4 = 0;
|
||||
while (n4 < n3) {
|
||||
int n5 = this.read(byArray, n + n4, n3 - n4);
|
||||
if (n5 == -1) {
|
||||
throw new EOFException();
|
||||
}
|
||||
n4 += n5;
|
||||
}
|
||||
}
|
||||
|
||||
public int skipBytes(int n) throws IOException {
|
||||
int n2 = n;
|
||||
while (n > 0) {
|
||||
int n3 = this.pageLen - this.pos;
|
||||
if (n3 > n) {
|
||||
this.pos += n;
|
||||
return n2;
|
||||
}
|
||||
n -= n3;
|
||||
this.nextPage();
|
||||
}
|
||||
return n2;
|
||||
}
|
||||
|
||||
public boolean readBoolean() throws IOException {
|
||||
boolean bl = false;
|
||||
if (this.read() != 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public byte readByte() throws IOException {
|
||||
return (byte)this.read();
|
||||
}
|
||||
|
||||
public int readUnsignedByte() throws IOException {
|
||||
return this.read();
|
||||
}
|
||||
|
||||
public short readShort() throws IOException {
|
||||
return (short)((this.read() << 8) + this.read());
|
||||
}
|
||||
|
||||
public int readUnsignedShort() throws IOException {
|
||||
return (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public char readChar() throws IOException {
|
||||
return (char)((this.read() << 8) + this.read());
|
||||
}
|
||||
|
||||
public int readInt() throws IOException {
|
||||
return (this.read() << 24) + (this.read() << 16) + (this.read() << 8) + this.read();
|
||||
}
|
||||
|
||||
public long readLong() throws IOException {
|
||||
return ((long)this.readInt() << 32) + ((long)this.readInt() & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
public float readFloat() throws IOException {
|
||||
return Float.intBitsToFloat(this.readInt());
|
||||
}
|
||||
|
||||
public double readDouble() throws IOException {
|
||||
return Double.longBitsToDouble(this.readLong());
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String readUTF() throws IOException {
|
||||
int n = this.readUnsignedShort();
|
||||
StringBuffer stringBuffer = new StringBuffer(n);
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
int n3 = this.read();
|
||||
switch (n3 >> 4) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: {
|
||||
++n2;
|
||||
stringBuffer.append((char)n3);
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
case 13: {
|
||||
if ((n2 += 2) > n) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
int n4 = this.read();
|
||||
if ((n4 & 0xC0) != 128) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
stringBuffer.append((char)((n3 & 0x1F) << 6 | n4 & 0x3F));
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
if ((n2 += 3) > n) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
int n4 = this.read();
|
||||
int n5 = this.read();
|
||||
if ((n4 & 0xC0) != 128 || (n5 & 0xC0) != 128) {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
stringBuffer.append((char)((n3 & 0xF) << 12 | (n4 & 0x3F) << 6 | n5 & 0x3F));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new UTFDataFormatException();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new String(stringBuffer);
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.pageIndex = -1;
|
||||
}
|
||||
|
||||
public PageReader(AlarmStore alarmStore) throws IOException {
|
||||
this(alarmStore, -1);
|
||||
}
|
||||
|
||||
public PageReader(AlarmStore alarmStore, int n) throws IOException {
|
||||
this.this();
|
||||
this.store = alarmStore;
|
||||
this.init(n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.AlarmStore;
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Random;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class SkipList {
|
||||
public static final int EQUAL_OR_AFTER = 0;
|
||||
public static final int EQUAL_OR_BEFORE = 1;
|
||||
public static final int EQUAL = 2;
|
||||
private int maxLevel;
|
||||
private IndexEntry header;
|
||||
private double probability;
|
||||
private int level;
|
||||
private int size;
|
||||
private Random rand;
|
||||
private IndexEntry[] addAt;
|
||||
private IndexEntry[] removeAt;
|
||||
private IndexEntry[] findAt;
|
||||
|
||||
public synchronized int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
public IndexEntry getHeader() {
|
||||
return this.header;
|
||||
}
|
||||
|
||||
public IndexEntry getFirstEntry() {
|
||||
return this.getNext(this.header, 0);
|
||||
}
|
||||
|
||||
public synchronized void add(IndexEntry indexEntry) {
|
||||
int n = this.generateNewLevel();
|
||||
this.setLevel(indexEntry, n);
|
||||
if (n > this.level) {
|
||||
this.level = n;
|
||||
}
|
||||
this.pathTo(indexEntry, this.addAt);
|
||||
int n2 = 0;
|
||||
while (n2 < n) {
|
||||
if (n2 == 0) {
|
||||
this.setPrev(indexEntry, this.addAt[0]);
|
||||
IndexEntry indexEntry2 = this.getNext(this.addAt[0], 0);
|
||||
if (indexEntry2 != null) {
|
||||
this.setPrev(indexEntry2, indexEntry);
|
||||
}
|
||||
}
|
||||
this.setNext(indexEntry, n2, this.getNext(this.addAt[n2], n2));
|
||||
this.setNext(this.addAt[n2], n2, indexEntry);
|
||||
++n2;
|
||||
}
|
||||
++this.size;
|
||||
}
|
||||
|
||||
public synchronized void remove(IndexEntry indexEntry) {
|
||||
if (this.size == 0) {
|
||||
return;
|
||||
}
|
||||
this.pathTo(indexEntry, this.removeAt);
|
||||
IndexEntry indexEntry2 = this.getNext(this.removeAt[0], 0);
|
||||
if (!indexEntry2.equals(indexEntry)) {
|
||||
throw new IllegalArgumentException("Entry not found: " + this.entryToString(indexEntry2));
|
||||
}
|
||||
int n = 0;
|
||||
while (n < this.level) {
|
||||
IndexEntry indexEntry3;
|
||||
if (this.getNext(this.removeAt[n], n) != indexEntry2) break;
|
||||
if (n == 0 && (indexEntry3 = this.getNext(indexEntry2, 0)) != null) {
|
||||
this.setPrev(indexEntry3, this.removeAt[0]);
|
||||
}
|
||||
this.setNext(this.removeAt[n], n, this.getNext(indexEntry2, n));
|
||||
++n;
|
||||
}
|
||||
while (this.level > 1 && this.getNext(this.header, this.level - 1) == null) {
|
||||
--this.level;
|
||||
}
|
||||
n = this.level;
|
||||
while (n < this.maxLevel) {
|
||||
this.addAt[n] = null;
|
||||
this.removeAt[n] = null;
|
||||
this.findAt[n] = null;
|
||||
++n;
|
||||
}
|
||||
--this.size;
|
||||
}
|
||||
|
||||
public IndexEntry find(Object object) {
|
||||
this.pathTo(object, this.findAt);
|
||||
return this.findAt[0];
|
||||
}
|
||||
|
||||
protected void pathTo(Object object, IndexEntry[] indexEntryArray) {
|
||||
IndexEntry indexEntry = this.header;
|
||||
IndexEntry indexEntry2 = null;
|
||||
int n = this.level - 1;
|
||||
while (n >= 0) {
|
||||
indexEntry2 = this.getNext(indexEntry, n);
|
||||
while (indexEntry2 != null && this.compareToKey(indexEntry2, object) < 0) {
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getNext(indexEntry2, n);
|
||||
}
|
||||
indexEntryArray[n] = indexEntry;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
protected void pathTo(IndexEntry indexEntry, IndexEntry[] indexEntryArray) {
|
||||
IndexEntry indexEntry2 = this.header;
|
||||
IndexEntry indexEntry3 = null;
|
||||
int n = this.level - 1;
|
||||
while (n >= 0) {
|
||||
indexEntry3 = this.getNext(indexEntry2, n);
|
||||
while (indexEntry3 != null && this.isBefore(indexEntry3, indexEntry)) {
|
||||
indexEntry2 = indexEntry3;
|
||||
indexEntry3 = this.getNext(indexEntry3, n);
|
||||
}
|
||||
indexEntryArray[n] = indexEntry2;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
||||
private final int generateNewLevel() {
|
||||
if (this.size == 0) {
|
||||
return 1;
|
||||
}
|
||||
int n = 1;
|
||||
while (this.rand.nextDouble() < this.probability && n < this.maxLevel) {
|
||||
if (++n != this.level + 1) continue;
|
||||
return n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected abstract int compare(IndexEntry var1, IndexEntry var2);
|
||||
|
||||
protected abstract int compareToKey(IndexEntry var1, Object var2);
|
||||
|
||||
protected boolean equals(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected boolean isBefore(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) < 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected boolean isAfter(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
boolean bl = false;
|
||||
if (this.compare(indexEntry, indexEntry2) > 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
protected abstract int getLevel(IndexEntry var1);
|
||||
|
||||
protected abstract void setLevel(IndexEntry var1, int var2);
|
||||
|
||||
protected abstract IndexEntry getNext(IndexEntry var1, int var2);
|
||||
|
||||
protected abstract void setNext(IndexEntry var1, int var2, IndexEntry var3);
|
||||
|
||||
protected abstract IndexEntry getPrev(IndexEntry var1);
|
||||
|
||||
protected abstract void setPrev(IndexEntry var1, IndexEntry var2);
|
||||
|
||||
public void dump() throws IOException {
|
||||
this.dump(null);
|
||||
}
|
||||
|
||||
public void dump(AlarmStore alarmStore) throws IOException {
|
||||
int n = 0;
|
||||
IndexEntry indexEntry = this.getNext(this.header, 0);
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
if (alarmStore != null) {
|
||||
bAlarmRecord = new BAlarmRecord();
|
||||
}
|
||||
while (indexEntry != null) {
|
||||
System.out.println(n++ + ": (" + this.getLevel(indexEntry) + ") " + this.entryToString(indexEntry));
|
||||
if (alarmStore != null) {
|
||||
bAlarmRecord = alarmStore.readRecord(indexEntry.pageIndex, bAlarmRecord, null);
|
||||
System.out.println(" " + bAlarmRecord.toSummaryString());
|
||||
}
|
||||
indexEntry = this.getNext(indexEntry, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void analyze(String string, PrintStream printStream) {
|
||||
printStream.println(string);
|
||||
printStream.println(" probability: " + this.probability);
|
||||
printStream.println(" maxLevel : " + this.maxLevel);
|
||||
printStream.println(" level : " + this.level);
|
||||
int[] nArray = new int[this.level];
|
||||
int n = 0;
|
||||
while (n < this.level) {
|
||||
IndexEntry indexEntry = this.getNext(this.header, n);
|
||||
while (indexEntry != null) {
|
||||
nArray[n] = nArray[n] + 1;
|
||||
indexEntry = this.getNext(indexEntry, n);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
n = 0;
|
||||
while (n < this.level) {
|
||||
System.out.println(" level " + (n + 1) + ": " + nArray[n]);
|
||||
++n;
|
||||
}
|
||||
n = this.size * 4;
|
||||
int n2 = 0;
|
||||
while (n2 < this.level) {
|
||||
n += nArray[n2] * 4;
|
||||
++n2;
|
||||
}
|
||||
DecimalFormat decimalFormat = new DecimalFormat("###,###,###.##");
|
||||
printStream.println(" ptr ram : " + decimalFormat.format((double)n / 1024.0 / 1024.0) + " MB");
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
int n = 0;
|
||||
IndexEntry indexEntry = null;
|
||||
IndexEntry indexEntry2 = this.getNext(this.header, 0);
|
||||
while (indexEntry2 != null) {
|
||||
++n;
|
||||
if (indexEntry != null && this.isAfter(indexEntry, indexEntry2)) {
|
||||
throw new IllegalStateException("Invalid ascending order. " + this.entryToString(indexEntry2) + " is before " + this.entryToString(indexEntry));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getNext(indexEntry2, 0);
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid ascending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
indexEntry2 = indexEntry;
|
||||
n = 0;
|
||||
indexEntry = null;
|
||||
while (indexEntry2 != this.header) {
|
||||
++n;
|
||||
if (indexEntry != null && this.isBefore(indexEntry, indexEntry2)) {
|
||||
throw new IllegalStateException("Invalid descending order. " + this.entryToString(indexEntry2) + " is after " + this.entryToString(indexEntry));
|
||||
}
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getPrev(indexEntry2);
|
||||
}
|
||||
if (this.size != n) {
|
||||
throw new IllegalStateException("Invalid descending count. size=" + this.size + ", count=" + n);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String entryToString(IndexEntry var1);
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.rand = new Random();
|
||||
}
|
||||
|
||||
public SkipList(double d, int n) {
|
||||
this.this();
|
||||
this.maxLevel = (int)(Math.log(n) / Math.log(1.0 / d)) + 1;
|
||||
this.probability = d;
|
||||
this.header = new IndexEntry();
|
||||
this.setLevel(this.header, this.maxLevel);
|
||||
this.level = 1;
|
||||
this.size = 0;
|
||||
this.addAt = new IndexEntry[this.maxLevel];
|
||||
this.removeAt = new IndexEntry[this.maxLevel];
|
||||
this.findAt = new IndexEntry[this.maxLevel];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.Context
|
||||
*/
|
||||
package com.tridium.alarm.db.file;
|
||||
|
||||
import com.tridium.alarm.db.file.IndexEntry;
|
||||
import com.tridium.alarm.db.file.SkipList;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Context;
|
||||
|
||||
public class TimestampIndex
|
||||
extends SkipList {
|
||||
public IndexEntry find(Object object) {
|
||||
BAbsTime bAbsTime = (BAbsTime)object;
|
||||
IndexEntry indexEntry = super.find(object);
|
||||
if (indexEntry.timestamp == null) {
|
||||
return indexEntry;
|
||||
}
|
||||
if (!indexEntry.timestamp.equals((Object)bAbsTime)) {
|
||||
return indexEntry;
|
||||
}
|
||||
IndexEntry indexEntry2 = this.getPrev(indexEntry);
|
||||
while (indexEntry2.timestamp != null && indexEntry2.timestamp.equals((Object)bAbsTime)) {
|
||||
indexEntry = indexEntry2;
|
||||
indexEntry2 = this.getPrev(indexEntry);
|
||||
}
|
||||
return indexEntry;
|
||||
}
|
||||
|
||||
protected int compareToKey(IndexEntry indexEntry, Object object) {
|
||||
return indexEntry.timestamp.compareTo((Object)((BAbsTime)object));
|
||||
}
|
||||
|
||||
protected int compare(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
int n = indexEntry.timestamp.compareTo((Object)indexEntry2.timestamp);
|
||||
if (n == 0) {
|
||||
return indexEntry.pageIndex - indexEntry2.pageIndex;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
protected int getLevel(IndexEntry indexEntry) {
|
||||
return indexEntry.nextTimestamp.length;
|
||||
}
|
||||
|
||||
protected void setLevel(IndexEntry indexEntry, int n) {
|
||||
indexEntry.nextTimestamp = new IndexEntry[n];
|
||||
}
|
||||
|
||||
protected IndexEntry getNext(IndexEntry indexEntry, int n) {
|
||||
return indexEntry.nextTimestamp[n];
|
||||
}
|
||||
|
||||
protected void setNext(IndexEntry indexEntry, int n, IndexEntry indexEntry2) {
|
||||
indexEntry.nextTimestamp[n] = indexEntry2;
|
||||
}
|
||||
|
||||
protected IndexEntry getPrev(IndexEntry indexEntry) {
|
||||
return indexEntry.prevTimestamp;
|
||||
}
|
||||
|
||||
protected void setPrev(IndexEntry indexEntry, IndexEntry indexEntry2) {
|
||||
indexEntry.prevTimestamp = indexEntry2;
|
||||
}
|
||||
|
||||
public String entryToString(IndexEntry indexEntry) {
|
||||
return indexEntry.timestamp.toString((Context)BAlarmRecord.TIMESTAMP_FACETS) + " => " + indexEntry.pageIndex;
|
||||
}
|
||||
|
||||
public TimestampIndex(double d, int n) {
|
||||
super(d, n);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.nre.util.IFilter
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.db.memory;
|
||||
|
||||
import com.tridium.alarm.FilterCursor;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.nre.util.IFilter;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BMemoryAlarmDatabase
|
||||
extends BAlarmDatabase {
|
||||
public static final Type TYPE;
|
||||
private static final String CAPACITY = "capacity";
|
||||
private int capacity;
|
||||
private AlarmEntry first;
|
||||
private AlarmEntry last;
|
||||
private int recordCount;
|
||||
private HashMap byUuid;
|
||||
private IFilter openFilter;
|
||||
private IFilter ackPendingFilter;
|
||||
private BAlarmService alarmService;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmClass;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
protected void doOpen() {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
}
|
||||
|
||||
protected void doClose() {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
}
|
||||
|
||||
public synchronized void append(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
Object object;
|
||||
AlarmEntry alarmEntry = new AlarmEntry((BAlarmRecord)bAlarmRecord.newCopy(true));
|
||||
if (this.first == null) {
|
||||
this.first = this.last = alarmEntry;
|
||||
} else {
|
||||
object = bAlarmRecord.getTimestamp();
|
||||
AlarmEntry alarmEntry2 = this.first;
|
||||
while (alarmEntry2 != null && alarmEntry2.rec.getTimestamp().isBefore((BAbsTime)object)) {
|
||||
alarmEntry2 = alarmEntry2.next;
|
||||
}
|
||||
if (alarmEntry2 == null) {
|
||||
this.last.next = alarmEntry;
|
||||
alarmEntry.prev = this.last;
|
||||
this.last = alarmEntry;
|
||||
} else {
|
||||
alarmEntry.prev = alarmEntry2.prev;
|
||||
if (alarmEntry2.prev != null) {
|
||||
alarmEntry2.prev.next = alarmEntry;
|
||||
}
|
||||
alarmEntry.next = alarmEntry2;
|
||||
alarmEntry2.prev = alarmEntry;
|
||||
if (alarmEntry2 == this.first) {
|
||||
this.first = alarmEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.byUuid.put(bAlarmRecord.getUuid(), alarmEntry);
|
||||
++this.recordCount;
|
||||
object = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (object.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
((BAlarmClass)((Object)object)).setTotalAlarmCount(((BAlarmClass)((Object)object)).getTotalAlarmCount() + 1);
|
||||
if (!bAlarmRecord.isAcknowledged()) {
|
||||
((BAlarmClass)((Object)object)).setUnackedAlarmCount(((BAlarmClass)((Object)object)).getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (!bAlarmRecord.isNormal()) {
|
||||
((BAlarmClass)((Object)object)).setInAlarmCount(((BAlarmClass)((Object)object)).getInAlarmCount() + 1);
|
||||
}
|
||||
if (bAlarmRecord.isOpen()) {
|
||||
((BAlarmClass)((Object)object)).setOpenAlarmCount(((BAlarmClass)((Object)object)).getOpenAlarmCount() + 1);
|
||||
}
|
||||
}
|
||||
if (this.recordCount > this.capacity) {
|
||||
this.trim();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update(BAlarmRecord bAlarmRecord) throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
bAlarmRecord.write(new DataOutputStream(byteArrayOutputStream));
|
||||
BUuid bUuid = bAlarmRecord.getUuid();
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(bAlarmRecord.getAlarmClass())) {
|
||||
if (!alarmEntry.rec.isAcknowledged() && bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
} else if (alarmEntry.rec.isAcknowledged() && !bAlarmRecord.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() + 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen() && !bAlarmRecord.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!alarmEntry.rec.isNormal() && bAlarmRecord.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
alarmEntry.rec = (BAlarmRecord)bAlarmRecord.newCopy(true);
|
||||
} else {
|
||||
this.append(bAlarmRecord);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(BAlarmRecord bAlarmRecord) {
|
||||
BUuid bUuid = bAlarmRecord.getUuid();
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
if (alarmEntry.prev != null) {
|
||||
alarmEntry.prev.next = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry.next != null) {
|
||||
alarmEntry.next.prev = alarmEntry.prev;
|
||||
}
|
||||
if (alarmEntry == this.first) {
|
||||
this.first = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry == this.last) {
|
||||
this.last = alarmEntry.prev;
|
||||
}
|
||||
alarmEntry.prev = null;
|
||||
alarmEntry.next = null;
|
||||
this.byUuid.remove(bUuid);
|
||||
}
|
||||
}
|
||||
|
||||
private final synchronized void trim() {
|
||||
while (this.recordCount > this.capacity) {
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = this.first.next;
|
||||
alarmEntry.next = null;
|
||||
if (this.first != null) {
|
||||
this.first.prev = null;
|
||||
}
|
||||
this.byUuid.remove(alarmEntry.rec.getUuid());
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (!bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) continue;
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isNormal()) continue;
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int getRecordCount() {
|
||||
return this.recordCount;
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) {
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry == null) {
|
||||
return null;
|
||||
}
|
||||
return alarmEntry.rec;
|
||||
}
|
||||
|
||||
public synchronized Cursor scan() throws IOException, AlarmException {
|
||||
return new AlarmCursor(this, this.first, BAbsTime.NULL, null);
|
||||
}
|
||||
|
||||
public synchronized Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws IOException, AlarmException {
|
||||
AlarmEntry alarmEntry = null;
|
||||
AlarmEntry alarmEntry2 = this.first;
|
||||
while (alarmEntry2 != null) {
|
||||
if (!alarmEntry2.rec.getTimestamp().isBefore(bAbsTime)) {
|
||||
alarmEntry = alarmEntry2;
|
||||
break;
|
||||
}
|
||||
alarmEntry2 = alarmEntry2.next;
|
||||
}
|
||||
return new AlarmCursor(this, alarmEntry, bAbsTime2, null);
|
||||
}
|
||||
|
||||
public Cursor getAlarmsForSource(BOrdList bOrdList) throws IOException {
|
||||
return new FilterCursor(new SourceFilter(bOrdList), this.scan());
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms() throws IOException {
|
||||
return new FilterCursor(this.openFilter, this.scan());
|
||||
}
|
||||
|
||||
public Cursor getAckPendingAlarms() throws IOException {
|
||||
return new FilterCursor(this.ackPendingFilter, this.scan());
|
||||
}
|
||||
|
||||
public synchronized void clearAllRecords(Context context) throws IOException {
|
||||
this.recordCount = 0;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.byUuid = new HashMap();
|
||||
Class clazz = class$javax$baja$alarm$BAlarmClass;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmClass = BMemoryAlarmDatabase.class("[Ljavax.baja.alarm.BAlarmClass;", false);
|
||||
}
|
||||
BAlarmClass[] bAlarmClassArray = (BAlarmClass[])this.alarmService.getChildren(clazz);
|
||||
int n = 0;
|
||||
while (n < bAlarmClassArray.length) {
|
||||
bAlarmClassArray[n].setTotalAlarmCount(0);
|
||||
bAlarmClassArray[n].setUnackedAlarmCount(0);
|
||||
bAlarmClassArray[n].setOpenAlarmCount(0);
|
||||
bAlarmClassArray[n].setInAlarmCount(0);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
while (this.first != null) {
|
||||
if (!bAbsTime.isAfter(this.first.rec.getTimestamp())) {
|
||||
return;
|
||||
}
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = this.first.next;
|
||||
alarmEntry.next = null;
|
||||
if (this.first != null) {
|
||||
this.first.prev = null;
|
||||
}
|
||||
this.byUuid.remove(alarmEntry.rec.getUuid());
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (!bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) continue;
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isNormal()) continue;
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid, Context context) {
|
||||
if (bUuid == null || bUuid.isNull()) {
|
||||
return;
|
||||
}
|
||||
AlarmEntry alarmEntry = (AlarmEntry)this.byUuid.get(bUuid);
|
||||
if (alarmEntry != null) {
|
||||
if (alarmEntry.prev != null) {
|
||||
alarmEntry.prev.next = alarmEntry.next;
|
||||
}
|
||||
if (alarmEntry.next != null) {
|
||||
alarmEntry.next.prev = alarmEntry.prev;
|
||||
}
|
||||
alarmEntry.next = null;
|
||||
alarmEntry.prev = null;
|
||||
this.byUuid.remove(bUuid);
|
||||
--this.recordCount;
|
||||
BAlarmClass bAlarmClass = this.alarmService.lookupAlarmClass(alarmEntry.rec.getAlarmClass());
|
||||
if (bAlarmClass.getName().equals(alarmEntry.rec.getAlarmClass())) {
|
||||
bAlarmClass.setTotalAlarmCount(bAlarmClass.getTotalAlarmCount() - 1);
|
||||
if (!alarmEntry.rec.isAcknowledged()) {
|
||||
bAlarmClass.setUnackedAlarmCount(bAlarmClass.getUnackedAlarmCount() - 1);
|
||||
}
|
||||
if (alarmEntry.rec.isOpen()) {
|
||||
bAlarmClass.setOpenAlarmCount(bAlarmClass.getOpenAlarmCount() - 1);
|
||||
}
|
||||
if (!alarmEntry.rec.isNormal()) {
|
||||
bAlarmClass.setInAlarmCount(bAlarmClass.getInAlarmCount() - 1);
|
||||
}
|
||||
}
|
||||
if (this.byUuid.size() == 0) {
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
}
|
||||
alarmEntry = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public void setCapacity(int n) throws IOException {
|
||||
if (n < 5) {
|
||||
throw new IllegalArgumentException("Attempted to set capacity < 5.");
|
||||
}
|
||||
if (this.capacity == n) {
|
||||
return;
|
||||
}
|
||||
this.capacity = n;
|
||||
if (!this.isOpen()) {
|
||||
return;
|
||||
}
|
||||
BMemoryAlarmDatabase bMemoryAlarmDatabase = this;
|
||||
synchronized (bMemoryAlarmDatabase) {
|
||||
AlarmEntry alarmEntry = this.first;
|
||||
this.first = null;
|
||||
this.last = null;
|
||||
this.recordCount = 0;
|
||||
while (alarmEntry != null) {
|
||||
this.append(alarmEntry.rec);
|
||||
alarmEntry = alarmEntry.next;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.capacity = 1000;
|
||||
this.byUuid = new HashMap();
|
||||
this.openFilter = new OpenFilter();
|
||||
this.ackPendingFilter = new AckPendingFilter();
|
||||
}
|
||||
|
||||
public BMemoryAlarmDatabase() {
|
||||
this.this();
|
||||
this.alarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$db$memory$BMemoryAlarmDatabase = BMemoryAlarmDatabase.class("[Lcom.tridium.alarm.db.memory.BMemoryAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmEntry {
|
||||
BAlarmRecord rec;
|
||||
AlarmEntry prev;
|
||||
AlarmEntry next;
|
||||
|
||||
public AlarmEntry(BAlarmRecord bAlarmRecord) {
|
||||
this.rec = bAlarmRecord;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmCursor
|
||||
implements Cursor {
|
||||
private BMemoryAlarmDatabase db;
|
||||
private AlarmEntry start;
|
||||
private AlarmEntry entry;
|
||||
private BAbsTime endTime;
|
||||
private Context context;
|
||||
|
||||
public Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
if (this.start == null) {
|
||||
return null;
|
||||
}
|
||||
if (this.entry == null) {
|
||||
throw new IllegalStateException("get() before next()");
|
||||
}
|
||||
return this.entry.rec;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public boolean next() {
|
||||
if (this.start == null) {
|
||||
return false;
|
||||
}
|
||||
BMemoryAlarmDatabase bMemoryAlarmDatabase = this.db;
|
||||
synchronized (bMemoryAlarmDatabase) {
|
||||
this.entry = this.entry == null ? this.start : this.entry.next;
|
||||
if (this.entry == null) {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BMemoryAlarmDatabase.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
return this.next();
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
this.start = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public AlarmCursor(BMemoryAlarmDatabase bMemoryAlarmDatabase2, AlarmEntry alarmEntry, BAbsTime bAbsTime, Context context) {
|
||||
this.db = bMemoryAlarmDatabase2;
|
||||
this.start = alarmEntry;
|
||||
this.endTime = bAbsTime;
|
||||
this.context = context;
|
||||
this.entry = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class SourceFilter
|
||||
implements IFilter {
|
||||
BOrdList source;
|
||||
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).getSource().equals((Object)this.source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public SourceFilter(BOrdList bOrdList) {
|
||||
this.source = bOrdList;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class OpenFilter
|
||||
implements IFilter {
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).isOpen();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AckPendingFilter
|
||||
implements IFilter {
|
||||
public boolean accept(Object object) {
|
||||
if (object == null || object instanceof BAlarmRecord) {
|
||||
return ((BAlarmRecord)((Object)object)).isAckPending();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,713 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.data.BToDataTable
|
||||
* com.tridium.data.DataTableDecoder
|
||||
* com.tridium.data.DataTableEncoder
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* com.tridium.fox.session.FoxCircuit
|
||||
* com.tridium.fox.session.FoxRequest
|
||||
* com.tridium.fox.session.FoxResponse
|
||||
* com.tridium.fox.session.InvalidCommandException
|
||||
* com.tridium.fox.sys.BFoxChannel
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.collection.BITable
|
||||
* javax.baja.collection.Column
|
||||
* javax.baja.collection.ColumnList
|
||||
* javax.baja.data.BIDataTable
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.util.BUuid
|
||||
* javax.baja.util.Version
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.alarm.AlarmColumnSpec;
|
||||
import com.tridium.alarm.AlarmInput;
|
||||
import com.tridium.alarm.AlarmInputCursor;
|
||||
import com.tridium.alarm.AlarmOutput;
|
||||
import com.tridium.alarm.BAlarmInputTable;
|
||||
import com.tridium.alarm.db.BAlarmDbQueryResult;
|
||||
import com.tridium.alarm.fox.FoxAlarmCodec;
|
||||
import com.tridium.data.BToDataTable;
|
||||
import com.tridium.data.DataTableDecoder;
|
||||
import com.tridium.data.DataTableEncoder;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import com.tridium.fox.session.FoxCircuit;
|
||||
import com.tridium.fox.session.FoxRequest;
|
||||
import com.tridium.fox.session.FoxResponse;
|
||||
import com.tridium.fox.session.InvalidCommandException;
|
||||
import com.tridium.fox.sys.BFoxChannel;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.HashMap;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.collection.BITable;
|
||||
import javax.baja.collection.Column;
|
||||
import javax.baja.collection.ColumnList;
|
||||
import javax.baja.data.BIDataTable;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.util.BUuid;
|
||||
import javax.baja.util.Version;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BAlarmDbChannel
|
||||
extends BFoxChannel {
|
||||
public static final Type TYPE;
|
||||
private Version serverVersion;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$fox$BAlarmDbChannel;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public FoxResponse process(FoxRequest foxRequest) throws Exception {
|
||||
String string = foxRequest.command;
|
||||
if (string == "append") {
|
||||
return this.append(foxRequest);
|
||||
}
|
||||
if (string == "update") {
|
||||
return this.update(foxRequest);
|
||||
}
|
||||
if (string == "getRecordCount") {
|
||||
return this.getRecordCount(foxRequest);
|
||||
}
|
||||
if (string == "getRecord") {
|
||||
return this.getRecord(foxRequest);
|
||||
}
|
||||
if (string == "clearAll") {
|
||||
return this.clearAllRecords(foxRequest);
|
||||
}
|
||||
if (string == "clearOld") {
|
||||
return this.clearOldRecords(foxRequest);
|
||||
}
|
||||
if (string == "getVersion") {
|
||||
return this.getVersion(foxRequest);
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public void circuitOpened(FoxCircuit foxCircuit) throws Exception {
|
||||
String string = foxCircuit.command;
|
||||
if (string == "resolve") {
|
||||
this.resolve(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "resolve34") {
|
||||
this.resolve34(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "scan") {
|
||||
this.scan(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "timeQuery") {
|
||||
this.timeQuery(foxCircuit);
|
||||
return;
|
||||
}
|
||||
if (string == "bqlQuery") {
|
||||
this.bqlQuery(foxCircuit);
|
||||
return;
|
||||
}
|
||||
throw new InvalidCommandException(string);
|
||||
}
|
||||
|
||||
public Version checkVersion() {
|
||||
if (this.serverVersion == null) {
|
||||
try {
|
||||
this.serverVersion = this.getVersion();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
this.serverVersion = Version.ZERO;
|
||||
}
|
||||
}
|
||||
return this.serverVersion;
|
||||
}
|
||||
|
||||
public Version getVersion() throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getVersion");
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
return new Version(foxResponse.getString("version", ""));
|
||||
}
|
||||
|
||||
public FoxResponse getVersion(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("version", TYPE.getModule().getVendorVersion().toString());
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public void append(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("append");
|
||||
foxRequest.add("rec", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
this.sendSync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse append(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(foxRequest.getMessage("rec"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
bAlarmService.getAlarmDb().append(bAlarmRecord);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("update");
|
||||
foxRequest.add("rec", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
this.sendSync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse update(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmRecord bAlarmRecord = FoxAlarmCodec.decodeAlarm(foxRequest.getMessage("rec"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorWrite);
|
||||
bAlarmService.getAlarmDb().update(bAlarmRecord);
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getRecordCount() throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getRecordCount");
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
return foxResponse.getInt("count");
|
||||
}
|
||||
|
||||
private final FoxResponse getRecordCount(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("count", bAlarmService.getAlarmDb().getRecordCount());
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("getRecord");
|
||||
foxRequest.add("uuid", bUuid.encodeToString());
|
||||
FoxResponse foxResponse = this.sendSync(foxRequest);
|
||||
return FoxAlarmCodec.decodeAlarm(foxResponse.getMessage("rec"));
|
||||
}
|
||||
|
||||
private final FoxResponse getRecord(FoxRequest foxRequest) throws Exception {
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decodeFromString(foxRequest.getString("uuid"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord(bUuid);
|
||||
BUser bUser = this.getSessionContext().getUser();
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
bUser.check((BIProtected)bAlarmClass, BPermissions.operatorRead);
|
||||
FoxResponse foxResponse = new FoxResponse(foxRequest);
|
||||
foxResponse.add("rec", FoxAlarmCodec.encodeAlarm(bAlarmRecord));
|
||||
return foxResponse;
|
||||
}
|
||||
|
||||
public void clearAllRecords() throws Exception {
|
||||
this.sendAsync(this.makeRequest("clearAll"));
|
||||
}
|
||||
|
||||
private final FoxResponse clearAllRecords(FoxRequest foxRequest) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService != null) {
|
||||
bAlarmService.getAlarmDb().clearAllRecords(this.getSessionContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearOldRecords(BAbsTime bAbsTime) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("clearOld");
|
||||
foxRequest.add("before", bAbsTime.getMillis());
|
||||
this.sendAsync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse clearOldRecords(FoxRequest foxRequest) throws Exception {
|
||||
BAbsTime bAbsTime = BAbsTime.make((long)foxRequest.getTime("before"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService != null) {
|
||||
bAlarmService.getAlarmDb().clearOldRecords(bAbsTime, this.getSessionContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid) throws Exception {
|
||||
FoxRequest foxRequest = this.makeRequest("clear");
|
||||
foxRequest.add("uuid", bUuid.encodeToString());
|
||||
this.sendAsync(foxRequest);
|
||||
}
|
||||
|
||||
private final FoxResponse clearRecord(FoxRequest foxRequest) throws Exception {
|
||||
BUuid bUuid = (BUuid)BUuid.DEFAULT.decodeFromString(foxRequest.getString("uuid"));
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (bAlarmService != null) {
|
||||
bAlarmService.getAlarmDb().clearRecord(bUuid, this.getSessionContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Cursor scan() throws Exception {
|
||||
FoxCircuit foxCircuit = this.openCircuit("scan");
|
||||
AlarmInput alarmInput = new AlarmInput(new DataInputStream(foxCircuit.getInputStream()));
|
||||
return new AlarmInputCursor(alarmInput, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void scan(FoxCircuit foxCircuit) throws Exception {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
AlarmSecurityCursor alarmSecurityCursor = new AlarmSecurityCursor(bAlarmDatabase.scan(), bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
AlarmOutput alarmOutput = new AlarmOutput(null, dataOutputStream);
|
||||
while (true) {
|
||||
block4: {
|
||||
if (alarmSecurityCursor.next()) break block4;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)alarmSecurityCursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var3_8 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var3_9 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
public Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws Exception {
|
||||
FoxCircuit foxCircuit = this.openCircuit("timeQuery");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
if (bAbsTime != null && !bAbsTime.isNull()) {
|
||||
foxMessage.add("startTime", bAbsTime.getMillis());
|
||||
}
|
||||
if (bAbsTime2 != null && !bAbsTime2.isNull()) {
|
||||
foxMessage.add("endTime", bAbsTime2.getMillis());
|
||||
}
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
AlarmInput alarmInput = new AlarmInput(new DataInputStream(foxCircuit.getInputStream()));
|
||||
return new AlarmInputCursor(alarmInput, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void timeQuery(FoxCircuit foxCircuit) throws Exception {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
FoxMessage foxMessage = foxCircuit.readMessage();
|
||||
BAbsTime bAbsTime = null;
|
||||
BAbsTime bAbsTime2 = null;
|
||||
long l = foxMessage.getTime("startTime", (long)-1);
|
||||
if (l != (long)-1) {
|
||||
bAbsTime = BAbsTime.make((long)l);
|
||||
}
|
||||
if ((l = foxMessage.getTime("endTime", (long)-1)) != (long)-1) {
|
||||
bAbsTime2 = BAbsTime.make((long)l);
|
||||
}
|
||||
Cursor cursor = bAlarmDatabase.timeQuery(bAbsTime, bAbsTime2);
|
||||
cursor = new AlarmSecurityCursor(cursor, bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
AlarmOutput alarmOutput = new AlarmOutput(null, dataOutputStream);
|
||||
while (true) {
|
||||
block6: {
|
||||
if (cursor.next()) break block6;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)cursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var3_12 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var3_13 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
public Cursor bqlQuery(BqlQuery bqlQuery) throws Exception {
|
||||
Version version = this.getVersion();
|
||||
if (version.compareTo((Object)new Version("3.4.23")) < 0) {
|
||||
throw new AlarmException("Incompatible Version: " + version + " < 3.4.23");
|
||||
}
|
||||
FoxCircuit foxCircuit = this.openCircuit("bqlQuery");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
if (bqlQuery != null) {
|
||||
foxMessage.add("bql", bqlQuery.getBody());
|
||||
}
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
AlarmInput alarmInput = new AlarmInput(new DataInputStream(foxCircuit.getInputStream()));
|
||||
return new AlarmInputCursor(alarmInput, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void bqlQuery(FoxCircuit foxCircuit) throws Exception {
|
||||
try {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
FoxMessage foxMessage = foxCircuit.readMessage();
|
||||
BqlQuery bqlQuery = BqlQuery.make((String)foxMessage.getString("bql", ""));
|
||||
AlarmSecurityCursor alarmSecurityCursor = new AlarmSecurityCursor(((BAlarmDbQueryResult)bAlarmDatabase.bqlQuery(null, bqlQuery)).cursor(), bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
AlarmOutput alarmOutput = new AlarmOutput(null, dataOutputStream);
|
||||
while (true) {
|
||||
block4: {
|
||||
if (alarmSecurityCursor.next()) break block4;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)alarmSecurityCursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var3_10 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var3_11 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
public BObject resolve(BOrd bOrd) throws Exception {
|
||||
Version version = this.checkVersion();
|
||||
boolean bl = false;
|
||||
if (version.major() == 3) {
|
||||
boolean bl2 = false;
|
||||
if (version.minor() >= 4) {
|
||||
bl2 = true;
|
||||
}
|
||||
bl = bl2;
|
||||
} else {
|
||||
bl = version.major() >= 4;
|
||||
}
|
||||
if (bl) {
|
||||
bOrd = bOrd.relativizeToSession();
|
||||
FoxCircuit foxCircuit = this.openCircuit("resolve34");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
foxMessage.add("ord", bOrd.toString());
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
FoxMessage foxMessage2 = foxCircuit.readMessage();
|
||||
String string = foxMessage2.getString("resultType", null);
|
||||
if (string.equals("records")) {
|
||||
DataInputStream dataInputStream = new DataInputStream(foxCircuit.getInputStream());
|
||||
AlarmColumnSpec[] alarmColumnSpecArray = this.readColumns(dataInputStream);
|
||||
AlarmInput alarmInput = new AlarmInput(dataInputStream);
|
||||
return new BAlarmInputTable(alarmColumnSpecArray, alarmInput);
|
||||
}
|
||||
if (string.equals("table")) {
|
||||
BIDataTable bIDataTable = DataTableDecoder.decode((DataInput)new DataInputStream(foxCircuit.getInputStream()));
|
||||
foxCircuit.close();
|
||||
return (BObject)bIDataTable;
|
||||
}
|
||||
throw new UnsupportedOperationException("Unsupported result type: " + string);
|
||||
}
|
||||
bOrd = bOrd.relativizeToSession();
|
||||
FoxCircuit foxCircuit = this.openCircuit("resolve");
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
foxMessage.add("ord", bOrd.toString());
|
||||
foxCircuit.writeMessage(foxMessage);
|
||||
foxCircuit.flush();
|
||||
DataInputStream dataInputStream = new DataInputStream(foxCircuit.getInputStream());
|
||||
AlarmInput alarmInput = new AlarmInput(dataInputStream);
|
||||
return new BAlarmInputTable(null, alarmInput);
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void resolve(FoxCircuit foxCircuit) throws Exception {
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
try {
|
||||
FoxMessage foxMessage = foxCircuit.readMessage();
|
||||
BOrd bOrd = BOrd.make((String)foxMessage.getString("ord"));
|
||||
BObject bObject = bOrd.resolve((BObject)this).get();
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(foxCircuit.getOutputStream());
|
||||
if (!(bObject instanceof BICollection)) throw new IllegalStateException("Unsupported result type: " + bObject.getClass().getName());
|
||||
BITable bITable = ((BICollection)bObject).toTable();
|
||||
AlarmOutput alarmOutput = new AlarmOutput(bITable, dataOutputStream);
|
||||
AlarmSecurityCursor alarmSecurityCursor = new AlarmSecurityCursor(((BICollection)bObject).cursor(), bAlarmService, BPermissions.operatorRead, this.getSessionContext());
|
||||
while (true) {
|
||||
block4: {
|
||||
if (alarmSecurityCursor.next()) break block4;
|
||||
alarmOutput.flush();
|
||||
alarmOutput.close();
|
||||
break;
|
||||
}
|
||||
alarmOutput.write((BAlarmRecord)alarmSecurityCursor.get());
|
||||
}
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
Object var4_11 = null;
|
||||
foxCircuit.close();
|
||||
throw throwable;
|
||||
}
|
||||
{
|
||||
Object var4_12 = null;
|
||||
}
|
||||
foxCircuit.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed back jump from a try to a catch block - possible behaviour change.
|
||||
* Unable to fully structure code
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
private final void resolve34(FoxCircuit var1_1) throws Exception {
|
||||
var2_2 = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
try {
|
||||
block6: {
|
||||
var5_3 = var1_1.readMessage();
|
||||
var6_4 = new FoxMessage("resp");
|
||||
var7_5 = BOrd.make((String)var5_3.getString("ord"));
|
||||
var8_6 = var7_5.resolve((BObject)this).get();
|
||||
var6_4.add("resolved", true);
|
||||
var9_7 = new DataOutputStream(var1_1.getOutputStream());
|
||||
if (var8_6 instanceof BICollection == false) throw new IllegalStateException("Unsupported result type: " + var8_6.getClass().getName());
|
||||
var10_8 = ((BICollection)var8_6).toTable();
|
||||
var11_9 = var10_8.getColumns();
|
||||
var12_10 = true;
|
||||
var13_11 = new BAlarmRecord();
|
||||
var14_12 = 0;
|
||||
while (var14_12 < var11_9.size()) {
|
||||
var15_15 /* !! */ = var11_9.get(var14_12);
|
||||
if (var13_11.getProperty(var15_15 /* !! */ .getName()) == null) {
|
||||
var12_10 = false;
|
||||
break;
|
||||
}
|
||||
++var14_12;
|
||||
}
|
||||
if (!var12_10) break block6;
|
||||
var6_4.add("resultType", "records");
|
||||
var1_1.writeMessage(var6_4);
|
||||
var1_1.flush();
|
||||
this.writeColumns(var10_8, var9_7, this.getSessionContext());
|
||||
var14_13 = new AlarmOutput(var10_8, var9_7);
|
||||
var15_15 /* !! */ = new AlarmSecurityCursor(((BICollection)var8_6).cursor(), var2_2, BPermissions.operatorRead, this.getSessionContext());
|
||||
while (true) {
|
||||
block7: {
|
||||
if (var15_15 /* !! */ .next()) break block7;
|
||||
var14_13.flush();
|
||||
var14_13.close();
|
||||
** GOTO lbl-1000
|
||||
}
|
||||
var14_13.write((BAlarmRecord)var15_15 /* !! */ .get());
|
||||
}
|
||||
}
|
||||
var6_4.add("resultType", "table");
|
||||
var1_1.writeMessage(var6_4);
|
||||
var1_1.flush();
|
||||
var14_14 = new DataOutputStream(var1_1.getOutputStream());
|
||||
DataTableEncoder.encode((BIDataTable)BToDataTable.toDataTable((BITable)var10_8), (DataOutput)var14_14, (Context)this.getSessionContext());
|
||||
var14_14.flush();
|
||||
var14_14.close();
|
||||
}
|
||||
catch (Throwable var3_16) {
|
||||
var4_17 = null;
|
||||
var1_1.close();
|
||||
throw var3_16;
|
||||
}
|
||||
lbl-1000:
|
||||
// 2 sources
|
||||
|
||||
{
|
||||
var4_18 = null;
|
||||
}
|
||||
var1_1.close();
|
||||
}
|
||||
|
||||
private final AlarmColumnSpec[] readColumns(DataInput dataInput) throws Exception {
|
||||
int n = dataInput.readInt();
|
||||
AlarmColumnSpec[] alarmColumnSpecArray = new AlarmColumnSpec[n];
|
||||
int n2 = 0;
|
||||
while (n2 < alarmColumnSpecArray.length) {
|
||||
alarmColumnSpecArray[n2] = AlarmColumnSpec.read(dataInput);
|
||||
++n2;
|
||||
}
|
||||
return alarmColumnSpecArray;
|
||||
}
|
||||
|
||||
private final void writeColumns(BITable bITable, DataOutput dataOutput, Context context) throws Exception {
|
||||
ColumnList columnList = bITable.getColumns();
|
||||
dataOutput.writeInt(columnList.size());
|
||||
int n = 0;
|
||||
while (n < columnList.size()) {
|
||||
Column column = columnList.get(n);
|
||||
new AlarmColumnSpec(column.getName(), column.getDisplayName(context), column.getFacets()).write(dataOutput);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmDbChannel() {
|
||||
super("alarmdb");
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$fox$BAlarmDbChannel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$fox$BAlarmDbChannel = BAlarmDbChannel.class("[Lcom.tridium.alarm.fox.BAlarmDbChannel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
private class AlarmSecurityCursor
|
||||
implements Cursor {
|
||||
private BAlarmService service;
|
||||
private BUser user;
|
||||
private Context context;
|
||||
private BPermissions required;
|
||||
private Cursor inner;
|
||||
private BAlarmRecord rec;
|
||||
private HashMap classPermissions;
|
||||
|
||||
public Context getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
public BObject get() {
|
||||
return this.rec;
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
while (this.inner.next()) {
|
||||
this.rec = (BAlarmRecord)this.inner.get();
|
||||
if (this.user != null) {
|
||||
BPermissions bPermissions = this.getClassPermissions(this.user, this.service.lookupAlarmClass(this.rec.getAlarmClass()));
|
||||
if (!bPermissions.has(this.required)) continue;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean nextComponent() {
|
||||
while (this.inner.next()) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean next(Class clazz) {
|
||||
Class clazz2 = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz2 == null) {
|
||||
clazz2 = class$javax$baja$alarm$BAlarmRecord = BAlarmDbChannel.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
if (clazz2.isAssignableFrom(clazz)) {
|
||||
return this.next();
|
||||
}
|
||||
while (this.inner.next()) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final BPermissions getClassPermissions(BUser bUser, BAlarmClass bAlarmClass) {
|
||||
BPermissions bPermissions = (BPermissions)this.classPermissions.get(bAlarmClass.getHandle());
|
||||
if (bPermissions == null) {
|
||||
bPermissions = BAlarmDbChannel.this.getPermissionsFor((Object)bAlarmClass);
|
||||
this.classPermissions.put(bAlarmClass.getHandle(), bPermissions);
|
||||
}
|
||||
return bPermissions;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.classPermissions = new HashMap();
|
||||
}
|
||||
|
||||
public AlarmSecurityCursor(Cursor cursor, BAlarmService bAlarmService, BPermissions bPermissions, Context context) {
|
||||
this.this();
|
||||
this.inner = cursor;
|
||||
this.service = bAlarmService;
|
||||
this.required = bPermissions;
|
||||
this.context = context;
|
||||
this.user = context != null ? context.getUser() : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.BFoxChannelRegistry
|
||||
* com.tridium.fox.sys.BFoxSession
|
||||
* javax.baja.bql.BqlQuery
|
||||
* javax.baja.bql.Queryable
|
||||
* javax.baja.bql.RemoteQueryable
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.alarm.fox.BAlarmDbChannel;
|
||||
import com.tridium.fox.sys.BFoxChannelRegistry;
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import java.io.IOException;
|
||||
import javax.baja.alarm.AlarmException;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.bql.BqlQuery;
|
||||
import javax.baja.bql.Queryable;
|
||||
import javax.baja.bql.RemoteQueryable;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFoxAlarmDatabase
|
||||
extends BAlarmDatabase
|
||||
implements Queryable,
|
||||
RemoteQueryable {
|
||||
public static final Type TYPE;
|
||||
private BFoxSession session;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$fox$BFoxAlarmDatabase;
|
||||
|
||||
public BAlarmDbChannel getChannel() {
|
||||
BAlarmDbChannel bAlarmDbChannel = null;
|
||||
try {
|
||||
bAlarmDbChannel = (BAlarmDbChannel)this.session.getConnection().getChannels().get("alarmdb", BAlarmDbChannel.TYPE);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
BFoxChannelRegistry.getPrototype().add("alarmdb", (BValue)new BAlarmDbChannel());
|
||||
bAlarmDbChannel = (BAlarmDbChannel)this.session.getConnection().getChannels().get("alarmdb", BAlarmDbChannel.TYPE);
|
||||
}
|
||||
return bAlarmDbChannel;
|
||||
}
|
||||
|
||||
public void append(BAlarmRecord bAlarmRecord) throws AlarmException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void update(BAlarmRecord bAlarmRecord) throws AlarmException {
|
||||
try {
|
||||
this.getChannel().update(bAlarmRecord);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRecordCount() {
|
||||
try {
|
||||
return this.getChannel().getRecordCount();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public BAlarmRecord getRecord(BUuid bUuid) {
|
||||
try {
|
||||
return this.getChannel().getRecord(bUuid);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor scan() throws IOException, AlarmException {
|
||||
try {
|
||||
return this.getChannel().scan();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor timeQuery(BAbsTime bAbsTime, BAbsTime bAbsTime2) throws IOException, AlarmException {
|
||||
try {
|
||||
return this.getChannel().timeQuery(bAbsTime, bAbsTime2);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor doBqlQuery(BqlQuery bqlQuery) throws IOException, AlarmException {
|
||||
try {
|
||||
return this.getChannel().bqlQuery(bqlQuery);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor getAlarmsForSource(BOrdList bOrdList) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Cursor getOpenAlarms() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Cursor getAckPendingAlarms() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public BObject bqlQuery(BOrd bOrd) {
|
||||
try {
|
||||
return this.getChannel().resolve(bOrd);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllRecords(Context context) throws IOException {
|
||||
try {
|
||||
this.getChannel().clearAllRecords();
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearOldRecords(BAbsTime bAbsTime, Context context) throws IOException {
|
||||
try {
|
||||
this.getChannel().clearOldRecords(bAbsTime);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearRecord(BUuid bUuid, Context context) throws IOException {
|
||||
try {
|
||||
this.getChannel().clearRecord(bUuid);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
if (exception instanceof AlarmException) {
|
||||
throw (AlarmException)((Object)exception);
|
||||
}
|
||||
throw new AlarmException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public BFoxAlarmDatabase(BFoxSession bFoxSession) {
|
||||
this.session = bFoxSession;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$fox$BFoxAlarmDatabase;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$fox$BFoxAlarmDatabase = BFoxAlarmDatabase.class("[Lcom.tridium.alarm.fox.BFoxAlarmDatabase;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.sys.BFoxSession
|
||||
* javax.baja.agent.BIAgent
|
||||
* javax.baja.naming.BISession
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.naming.UnresolvedException
|
||||
* javax.baja.sys.BObject
|
||||
* javax.baja.sys.BSingleton
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.alarm.db.AlarmQuery;
|
||||
import com.tridium.alarm.db.BIAlarmResolver;
|
||||
import com.tridium.alarm.fox.BFoxAlarmDatabase;
|
||||
import com.tridium.fox.sys.BFoxSession;
|
||||
import javax.baja.agent.BIAgent;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.naming.BISession;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.naming.UnresolvedException;
|
||||
import javax.baja.sys.BObject;
|
||||
import javax.baja.sys.BSingleton;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BFoxAlarmResolver
|
||||
extends BSingleton
|
||||
implements BIAlarmResolver,
|
||||
BIAgent {
|
||||
public static final BFoxAlarmResolver INSTANCE = new BFoxAlarmResolver();
|
||||
public static final Type TYPE;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$fox$BFoxAlarmResolver;
|
||||
|
||||
public OrdTarget resolve(BISession bISession, OrdTarget ordTarget, AlarmQuery alarmQuery) {
|
||||
BFoxSession bFoxSession = (BFoxSession)bISession;
|
||||
if (alarmQuery.isDbQuery()) {
|
||||
return new OrdTarget(ordTarget, (BObject)new BFoxAlarmDatabase(bFoxSession));
|
||||
}
|
||||
String string = alarmQuery.getQueryParameter("uuid", null);
|
||||
if (string != null) {
|
||||
BFoxAlarmDatabase bFoxAlarmDatabase = new BFoxAlarmDatabase(bFoxSession);
|
||||
BAlarmRecord bAlarmRecord = bFoxAlarmDatabase.getRecord(BUuid.make((String)string));
|
||||
if (bAlarmRecord == null) {
|
||||
throw new UnresolvedException(string);
|
||||
}
|
||||
return new OrdTarget(ordTarget, (BObject)bAlarmRecord);
|
||||
}
|
||||
throw new UnresolvedException("Invalid alarm query: " + alarmQuery);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$fox$BFoxAlarmResolver;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$fox$BFoxAlarmResolver = BFoxAlarmResolver.class("[Lcom.tridium.alarm.fox.BFoxAlarmResolver;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* com.tridium.fox.encoding.DecoderFactory
|
||||
* com.tridium.fox.message.FoxMessage
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.fox;
|
||||
|
||||
import com.tridium.fox.encoding.DecoderFactory;
|
||||
import com.tridium.fox.message.FoxMessage;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
public class FoxAlarmCodec {
|
||||
public static FoxMessage encodeAlarm(BAlarmRecord bAlarmRecord) throws Exception {
|
||||
FoxMessage foxMessage = new FoxMessage();
|
||||
foxMessage.add("timestamp", bAlarmRecord.getTimestamp().getMillis());
|
||||
foxMessage.add("uuid", bAlarmRecord.getUuid().encodeToString());
|
||||
foxMessage.add("sourceState", bAlarmRecord.getSourceState().encodeToString());
|
||||
foxMessage.add("ackState", bAlarmRecord.getAckState().encodeToString());
|
||||
foxMessage.add("ackRequired", bAlarmRecord.getAckRequired());
|
||||
foxMessage.add("source", bAlarmRecord.getSource().encodeToString());
|
||||
foxMessage.add("alarmClass", bAlarmRecord.getAlarmClass());
|
||||
foxMessage.add("priority", bAlarmRecord.getPriority());
|
||||
foxMessage.add("normalTime", bAlarmRecord.getNormalTime().getMillis());
|
||||
foxMessage.add("ackTime", bAlarmRecord.getAckTime().getMillis());
|
||||
foxMessage.add("user", bAlarmRecord.getUser());
|
||||
foxMessage.add("alarmData", bAlarmRecord.getAlarmData().encodeToString());
|
||||
foxMessage.add("alarmTransition", bAlarmRecord.getAlarmTransition().encodeToString());
|
||||
foxMessage.add("lastUpdate", bAlarmRecord.getLastUpdate().getMillis());
|
||||
return foxMessage;
|
||||
}
|
||||
|
||||
public static BAlarmRecord decodeAlarm(FoxMessage foxMessage) throws Exception {
|
||||
BAlarmRecord bAlarmRecord = new BAlarmRecord();
|
||||
try {
|
||||
bAlarmRecord.setTimestamp(BAbsTime.make((long)foxMessage.getTime("timestamp")));
|
||||
bAlarmRecord.setUuid((BUuid)BUuid.DEFAULT.decodeFromString(foxMessage.getString("uuid")));
|
||||
bAlarmRecord.setSourceState((BSourceState)BSourceState.normal.decodeFromString(foxMessage.getString("sourceState")));
|
||||
bAlarmRecord.setAckState((BAckState)BAckState.acked.decodeFromString(foxMessage.getString("ackState")));
|
||||
bAlarmRecord.setAckRequired(foxMessage.getBoolean("ackRequired"));
|
||||
bAlarmRecord.setSource((BOrdList)BOrdList.DEFAULT.decodeFromString(foxMessage.getString("source")));
|
||||
bAlarmRecord.setAlarmClass(foxMessage.getString("alarmClass"));
|
||||
bAlarmRecord.setPriority(foxMessage.getInt("priority"));
|
||||
bAlarmRecord.setNormalTime(BAbsTime.make((long)foxMessage.getTime("normalTime")));
|
||||
bAlarmRecord.setAckTime(BAbsTime.make((long)foxMessage.getTime("ackTime")));
|
||||
bAlarmRecord.setUser(foxMessage.getString("user"));
|
||||
bAlarmRecord.setAlarmData((BFacets)BFacets.DEFAULT.decodeFromString(foxMessage.getString("alarmData")));
|
||||
bAlarmRecord.setAlarmTransition((BSourceState)BSourceState.normal.decodeFromString(foxMessage.getString("alarmTransition")));
|
||||
bAlarmRecord.setLastUpdate(BAbsTime.make((long)foxMessage.getTime("lastUpdate")));
|
||||
}
|
||||
catch (Exception exception) {
|
||||
bAlarmRecord.setTimestamp(BAbsTime.make((long)foxMessage.getTime("timestamp")));
|
||||
bAlarmRecord.setUuid((BUuid)DecoderFactory.decode((FoxMessage)foxMessage, (String)"uuid", null));
|
||||
bAlarmRecord.setSourceState((BSourceState)((Object)DecoderFactory.decode((FoxMessage)foxMessage, (String)"sourceState", null)));
|
||||
bAlarmRecord.setAckState((BAckState)((Object)DecoderFactory.decode((FoxMessage)foxMessage, (String)"ackState", null)));
|
||||
bAlarmRecord.setAckRequired(foxMessage.getBoolean("ackRequired"));
|
||||
bAlarmRecord.setSource((BOrdList)DecoderFactory.decode((FoxMessage)foxMessage, (String)"source", null));
|
||||
bAlarmRecord.setAlarmClass(foxMessage.getString("alarmClass"));
|
||||
bAlarmRecord.setPriority(foxMessage.getInt("priority"));
|
||||
bAlarmRecord.setNormalTime(BAbsTime.make((long)foxMessage.getTime("normalTime")));
|
||||
bAlarmRecord.setAckTime(BAbsTime.make((long)foxMessage.getTime("ackTime")));
|
||||
bAlarmRecord.setUser(foxMessage.getString("user"));
|
||||
bAlarmRecord.setAlarmData((BFacets)DecoderFactory.decode((FoxMessage)foxMessage, (String)"alarmData", null));
|
||||
bAlarmRecord.setAlarmTransition((BSourceState)((Object)DecoderFactory.decode((FoxMessage)foxMessage, (String)"alarmTransition", null)));
|
||||
bAlarmRecord.setLastUpdate(BAbsTime.make((long)foxMessage.getTime("lastUpdate")));
|
||||
}
|
||||
return bAlarmRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.hx.HxOp
|
||||
* javax.baja.naming.OrdTarget
|
||||
* javax.baja.nre.util.Array
|
||||
*/
|
||||
package com.tridium.alarm.hx;
|
||||
|
||||
import javax.baja.hx.HxOp;
|
||||
import javax.baja.naming.OrdTarget;
|
||||
import javax.baja.nre.util.Array;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class AlarmConsoleOp
|
||||
extends HxOp {
|
||||
private Array args;
|
||||
|
||||
public String getCmd() {
|
||||
return this.args.size() > 0 ? (String)this.args.get(0) : "";
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.args.size() > 1 ? (String)this.args.get(1) : "";
|
||||
}
|
||||
|
||||
public String getSortCol() {
|
||||
return this.args.size() > 2 ? (String)this.args.get(2) : "";
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public void setSortCol(String var1_1) {
|
||||
block1: {
|
||||
if (this.args.size() <= 2) ** GOTO lbl7
|
||||
this.args.set(2, (Object)var1_1);
|
||||
break block1;
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
this.args.add((Object)"");
|
||||
lbl7:
|
||||
// 2 sources
|
||||
|
||||
** while (this.args.size() < 2)
|
||||
}
|
||||
lbl8:
|
||||
// 1 sources
|
||||
|
||||
this.args.add((Object)var1_1);
|
||||
}
|
||||
}
|
||||
|
||||
public String getSortOrder() {
|
||||
return this.args.size() > 3 ? (String)this.args.get(3) : "";
|
||||
}
|
||||
|
||||
/*
|
||||
* Unable to fully structure code
|
||||
*/
|
||||
public void setSortOrder(String var1_1) {
|
||||
block1: {
|
||||
if (this.args.size() <= 3) ** GOTO lbl7
|
||||
this.args.set(3, (Object)var1_1);
|
||||
break block1;
|
||||
lbl-1000:
|
||||
// 1 sources
|
||||
|
||||
{
|
||||
this.args.add((Object)"");
|
||||
lbl7:
|
||||
// 2 sources
|
||||
|
||||
** while (this.args.size() < 3)
|
||||
}
|
||||
lbl8:
|
||||
// 1 sources
|
||||
|
||||
this.args.add((Object)var1_1);
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.args = new Array();
|
||||
}
|
||||
|
||||
public AlarmConsoleOp(HxOp hxOp) {
|
||||
super(hxOp.getUniqueName(), (OrdTarget)hxOp, hxOp);
|
||||
this.this();
|
||||
}
|
||||
|
||||
public AlarmConsoleOp(HxOp hxOp, String[] stringArray) {
|
||||
super(hxOp.getUniqueName(), (OrdTarget)hxOp, hxOp);
|
||||
this.this();
|
||||
this.args = new Array((Object[])stringArray);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,419 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.collection.BICollection
|
||||
* javax.baja.data.BIDataValue
|
||||
* javax.baja.log.Log
|
||||
* javax.baja.naming.BOrd
|
||||
* javax.baja.naming.BOrdList
|
||||
* javax.baja.naming.SlotPath
|
||||
* javax.baja.nre.util.Array
|
||||
* javax.baja.security.BIProtected
|
||||
* javax.baja.security.BPermissions
|
||||
* javax.baja.security.PermissionException
|
||||
* javax.baja.sys.Action
|
||||
* javax.baja.sys.BAbsTime
|
||||
* javax.baja.sys.BComplex
|
||||
* javax.baja.sys.BComponent
|
||||
* javax.baja.sys.BFacets
|
||||
* javax.baja.sys.BRelTime
|
||||
* javax.baja.sys.BString
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.BasicContext
|
||||
* javax.baja.sys.Clock
|
||||
* javax.baja.sys.Clock$Ticket
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Cursor
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Slot
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
* javax.baja.user.BUser
|
||||
* javax.baja.util.BUuid
|
||||
*/
|
||||
package com.tridium.alarm.model;
|
||||
|
||||
import com.tridium.alarm.BConsoleRecipient;
|
||||
import com.tridium.alarm.model.BAlarmConsoleRow;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmClass;
|
||||
import javax.baja.alarm.BAlarmDatabase;
|
||||
import javax.baja.alarm.BAlarmRecipient;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BAlarmService;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.collection.BICollection;
|
||||
import javax.baja.data.BIDataValue;
|
||||
import javax.baja.log.Log;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.naming.BOrdList;
|
||||
import javax.baja.naming.SlotPath;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.security.BIProtected;
|
||||
import javax.baja.security.BPermissions;
|
||||
import javax.baja.security.PermissionException;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComplex;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BFacets;
|
||||
import javax.baja.sys.BRelTime;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.BasicContext;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Cursor;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Slot;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.user.BUser;
|
||||
import javax.baja.util.BUuid;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BAlarmConsoleModel
|
||||
extends BComponent {
|
||||
public static final Action routeAlarm = BAlarmConsoleModel.newAction((int)260, (BValue)new BAlarmRecord(), null);
|
||||
public static final Action ackAlarms = BAlarmConsoleModel.newAction((int)260, (BValue)new BComponent(), null);
|
||||
public static final Action forceClear = BAlarmConsoleModel.newAction((int)260, (BValue)new BComponent(), null);
|
||||
public static final Action refresh = BAlarmConsoleModel.newAction((int)260, null);
|
||||
public static final Action addNotes = BAlarmConsoleModel.newAction((int)260, (BValue)new BComponent(), null);
|
||||
public static final Action expire = BAlarmConsoleModel.newAction((int)260, null);
|
||||
public static final Type TYPE;
|
||||
private static final BRelTime expiryTime;
|
||||
private static final Log log;
|
||||
private volatile Context routeAlarmCx;
|
||||
private final Object alarmMon;
|
||||
private volatile boolean started;
|
||||
private volatile Clock.Ticket expireTicket;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$model$BAlarmConsoleModel;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$model$BAlarmConsoleRow;
|
||||
static /* synthetic */ Class class$javax$baja$alarm$BAlarmRecord;
|
||||
|
||||
public final void routeAlarm(BAlarmRecord bAlarmRecord) {
|
||||
this.invoke(routeAlarm, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public final void ackAlarms(BComponent bComponent) {
|
||||
this.invoke(ackAlarms, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public final void forceClear(BComponent bComponent) {
|
||||
this.invoke(forceClear, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public final void refresh() {
|
||||
this.invoke(refresh, null, null);
|
||||
}
|
||||
|
||||
public final void addNotes(BComponent bComponent) {
|
||||
this.invoke(addNotes, (BValue)bComponent, null);
|
||||
}
|
||||
|
||||
public final void expire() {
|
||||
this.invoke(expire, null, null);
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final void started() {
|
||||
this.linkTo(this.getConsole(), (Slot)BAlarmRecipient.routeAlarm, (Slot)routeAlarm);
|
||||
this.expireTicket = Clock.schedule((BComponent)this, (BRelTime)expiryTime, (Action)expire, null);
|
||||
}
|
||||
|
||||
public final void stopped() throws Exception {
|
||||
this.expireTicket.cancel();
|
||||
}
|
||||
|
||||
public final void subscribed() {
|
||||
this.expireTicket.cancel();
|
||||
}
|
||||
|
||||
public final void unsubscribed() {
|
||||
if (this.isRunning()) {
|
||||
this.expireTicket = Clock.schedule((BComponent)this, (BRelTime)expiryTime, (Action)expire, null);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean isParentLegal(BComponent bComponent) {
|
||||
return bComponent instanceof BConsoleRecipient;
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Unable to fully structure code
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public final void doRefresh(Context var1_1) {
|
||||
if (this.routeAlarmCx == null) {
|
||||
this.routeAlarmCx = new BasicContext(var1_1.getUser(), var1_1.getLanguage());
|
||||
}
|
||||
this.started = true;
|
||||
var2_2 = this.alarmMon;
|
||||
synchronized (var2_2) {
|
||||
if (BAlarmConsoleModel.log.isTraceOn()) {
|
||||
BAlarmConsoleModel.log.trace("Refreshing alarm console");
|
||||
}
|
||||
if ((v0 = BAlarmConsoleModel.class$com$tridium$alarm$model$BAlarmConsoleRow) == null) {
|
||||
v0 = BAlarmConsoleModel.class$com$tridium$alarm$model$BAlarmConsoleRow = BAlarmConsoleModel.class("[Lcom.tridium.alarm.model.BAlarmConsoleRow;", false);
|
||||
}
|
||||
var4_3 = (BAlarmConsoleRow[])this.getChildren(v0);
|
||||
var5_4 = 0;
|
||||
while (true) {
|
||||
block8: {
|
||||
if (var5_4 < var4_3.length) break block8;
|
||||
var5_5 = this.getConsole().getOpenAlarms(var1_1);
|
||||
if (true) ** GOTO lbl27
|
||||
}
|
||||
this.remove((BComplex)var4_3[var5_4]);
|
||||
++var5_4;
|
||||
}
|
||||
do {
|
||||
if ((var6_6 = (BAlarmRecord)var5_5.get()).getSourceState() == BSourceState.normal && (var6_6.isAcknowledged() || !var6_6.getAckRequired())) continue;
|
||||
this.doRouteAlarm(var6_6, var1_1);
|
||||
lbl27:
|
||||
// 3 sources
|
||||
|
||||
} while (var5_5.next());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
* Enabled aggressive block sorting
|
||||
* Enabled unnecessary exception pruning
|
||||
* Enabled aggressive exception aggregation
|
||||
*/
|
||||
public final void doRouteAlarm(BAlarmRecord bAlarmRecord, Context context) {
|
||||
if (!this.started) {
|
||||
return;
|
||||
}
|
||||
if (!this.getConsole().accept(bAlarmRecord)) {
|
||||
return;
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
if (!this.hasPermissions(bAlarmService, bAlarmRecord, BPermissions.operatorRead, this.routeAlarmCx)) {
|
||||
return;
|
||||
}
|
||||
Object object = this.alarmMon;
|
||||
synchronized (object) {
|
||||
block11: {
|
||||
BAlarmConsoleRow bAlarmConsoleRow;
|
||||
String string;
|
||||
block10: {
|
||||
string = SlotPath.escape((String)bAlarmRecord.getSource().toString());
|
||||
bAlarmConsoleRow = (BAlarmConsoleRow)this.get(string);
|
||||
if (bAlarmConsoleRow == null) {
|
||||
bAlarmConsoleRow = new BAlarmConsoleRow(this.routeAlarmCx);
|
||||
}
|
||||
bAlarmConsoleRow.update(bAlarmRecord);
|
||||
if (!bAlarmConsoleRow.isEmpty()) break block10;
|
||||
if (bAlarmConsoleRow.getParent() != null) {
|
||||
this.remove((BComplex)bAlarmConsoleRow);
|
||||
}
|
||||
break block11;
|
||||
}
|
||||
int n = 258;
|
||||
if (!this.hasPermissions(bAlarmService, bAlarmRecord, BPermissions.operatorWrite, this.routeAlarmCx)) {
|
||||
n |= 1;
|
||||
}
|
||||
if (bAlarmConsoleRow.getParent() == null) {
|
||||
this.add(string, (BValue)bAlarmConsoleRow, n);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private final BAlarmRecord[] getAlarmRecords(BAlarmService bAlarmService, BComponent bComponent) throws Exception {
|
||||
BComponent bComponent2 = (BComponent)bComponent.get("alarmSources");
|
||||
Class clazz = class$javax$baja$alarm$BAlarmRecord;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$alarm$BAlarmRecord = BAlarmConsoleModel.class("[Ljavax.baja.alarm.BAlarmRecord;", false);
|
||||
}
|
||||
Array array = new Array(clazz);
|
||||
if (bComponent2 != null) {
|
||||
Property[] propertyArray = bComponent2.getDynamicPropertiesArray();
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
BValue bValue = bComponent2.get(propertyArray[n]);
|
||||
if (bValue instanceof BOrdList) {
|
||||
BOrdList bOrdList = (BOrdList)bValue;
|
||||
BOrd bOrd = BOrd.make((String)("alarm:|bql:select * from openAlarms where source = OrdList '" + SlotPath.escape((String)bOrdList.encodeToString()) + '\''));
|
||||
BICollection bICollection = (BICollection)bOrd.get();
|
||||
Cursor cursor = bICollection.cursor();
|
||||
while (cursor.next()) {
|
||||
array.add((Object)cursor.get().asValue().newCopy(true));
|
||||
}
|
||||
}
|
||||
++n;
|
||||
}
|
||||
} else {
|
||||
BComponent bComponent3 = (BComponent)bComponent.get("alarms");
|
||||
Property[] propertyArray = bComponent3.getDynamicPropertiesArray();
|
||||
int n = 0;
|
||||
while (n < propertyArray.length) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmService.getAlarmDb().getRecord((BUuid)bComponent3.get(propertyArray[n]));
|
||||
if (bAlarmRecord != null) {
|
||||
array.add((Object)bAlarmRecord.newCopy(true));
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
return (BAlarmRecord[])array.trim();
|
||||
}
|
||||
|
||||
public final void doAckAlarms(BComponent bComponent, Context context) throws Exception {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Acknowledging alarms");
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
BAlarmRecord[] bAlarmRecordArray = this.getAlarmRecords(bAlarmService, bComponent);
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
if (this.hasPermissions(bAlarmService, bAlarmRecordArray[n], BPermissions.operatorWrite, context)) {
|
||||
boolean bl = false;
|
||||
if (bAlarmRecordArray[n].getAckState() != BAckState.ackPending) {
|
||||
bl = true;
|
||||
}
|
||||
boolean bl2 = bl;
|
||||
bAlarmRecordArray[n].setUser(context.getUser().getUsername());
|
||||
bAlarmRecordArray[n].setAckTime(BAbsTime.now());
|
||||
bAlarmRecordArray[n].setAckState(BAckState.ackPending);
|
||||
if (bl2) {
|
||||
bAlarmDatabase.update(bAlarmRecordArray[n]);
|
||||
}
|
||||
bAlarmService.ackAlarm(bAlarmRecordArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final void doAddNotes(BComponent bComponent, Context context) throws Exception {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Add Notes to alarms");
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("##");
|
||||
stringBuffer.append(BAbsTime.now().toString());
|
||||
stringBuffer.append(" - ");
|
||||
stringBuffer.append(context.getUser().getName());
|
||||
stringBuffer.append(" ##\n");
|
||||
stringBuffer.append(((BString)bComponent.get("notes")).toString());
|
||||
BAlarmRecord[] bAlarmRecordArray = this.getAlarmRecords(bAlarmService, bComponent);
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
if (this.hasPermissions(bAlarmService, bAlarmRecordArray[n], BPermissions.operatorWrite, context)) {
|
||||
String string = bAlarmRecordArray[n].getAlarmData().gets("notes", "");
|
||||
bAlarmRecordArray[n].setAlarmData(BFacets.make((BFacets)bAlarmRecordArray[n].getAlarmData(), (String)"notes", (BIDataValue)BString.make((String)(stringBuffer + string))));
|
||||
bAlarmRecordArray[n].setLastUpdate(BAbsTime.now());
|
||||
bAlarmService.routeAlarm(bAlarmRecordArray[n]);
|
||||
bAlarmService.doRouteToSource(bAlarmRecordArray[n]);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
public final void doExpire(Context context) {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Expiring Alarm Console Model: " + this.toPathString());
|
||||
}
|
||||
this.getConsole().remove((BComplex)this);
|
||||
}
|
||||
|
||||
public final void doForceClear(BComponent bComponent, Context context) throws Exception {
|
||||
if (log.isTraceOn()) {
|
||||
log.trace("Alarm force clear");
|
||||
}
|
||||
BAlarmService bAlarmService = (BAlarmService)Sys.getService((Type)BAlarmService.TYPE);
|
||||
BAlarmDatabase bAlarmDatabase = bAlarmService.getAlarmDb();
|
||||
BUser bUser = context.getUser();
|
||||
BPermissions bPermissions = bUser.getPermissionsFor((BIProtected)this.getConsole());
|
||||
if (!bPermissions.has(BPermissions.adminWrite) && !bPermissions.has(BPermissions.adminInvoke)) {
|
||||
throw new PermissionException(bPermissions + " < " + BPermissions.adminWrite);
|
||||
}
|
||||
BAlarmRecord[] bAlarmRecordArray = this.getAlarmRecords(bAlarmService, bComponent);
|
||||
int n = 0;
|
||||
while (n < bAlarmRecordArray.length) {
|
||||
BAlarmRecord bAlarmRecord = bAlarmRecordArray[n];
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
if (bUser.getPermissionsFor((BIProtected)bAlarmClass).has(BPermissions.adminWrite)) {
|
||||
bAlarmRecord.addAlarmFacet("forceCleared", (BIDataValue)BString.make((String)bUser.getUsername()));
|
||||
if (bAlarmRecord.getAckTime().equals((Object)BAbsTime.NULL)) {
|
||||
bAlarmRecord.setAckTime(BAbsTime.now());
|
||||
}
|
||||
if (bAlarmRecord.getNormalTime().equals((Object)BAbsTime.NULL)) {
|
||||
bAlarmRecord.setNormalTime(BAbsTime.now());
|
||||
}
|
||||
if (!bAlarmRecord.getAckState().equals((Object)BAckState.acked)) {
|
||||
bAlarmRecord.setUser(bUser.getUsername());
|
||||
}
|
||||
bAlarmRecord.setSourceState(BSourceState.normal);
|
||||
bAlarmRecord.setAckState(BAckState.acked);
|
||||
bAlarmDatabase.update(bAlarmRecord);
|
||||
bAlarmService.invoke(BAlarmService.auditForceClear, (BValue)bAlarmRecord, context);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean hasPermissions(BAlarmService bAlarmService, BAlarmRecord bAlarmRecord, BPermissions bPermissions, Context context) {
|
||||
BAlarmClass bAlarmClass = bAlarmService.lookupAlarmClass(bAlarmRecord.getAlarmClass());
|
||||
if (bAlarmClass == null) {
|
||||
bAlarmClass = bAlarmService.getDefaultAlarmClass();
|
||||
}
|
||||
return context.getUser().getPermissionsFor((BIProtected)bAlarmClass).has(bPermissions);
|
||||
}
|
||||
|
||||
private final BConsoleRecipient getConsole() {
|
||||
return (BConsoleRecipient)this.getParent();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.alarmMon = new Object();
|
||||
this.started = false;
|
||||
this.expireTicket = Clock.expiredTicket;
|
||||
}
|
||||
|
||||
public BAlarmConsoleModel() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$model$BAlarmConsoleModel;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$model$BAlarmConsoleModel = BAlarmConsoleModel.class("[Lcom.tridium.alarm.model.BAlarmConsoleModel;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
expiryTime = BRelTime.makeSeconds((int)60);
|
||||
log = Log.getLog((String)"alarm.alarmConsoleModel");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.sys.BStruct
|
||||
* javax.baja.sys.BValue
|
||||
* javax.baja.sys.Context
|
||||
* javax.baja.sys.Property
|
||||
* javax.baja.sys.Sys
|
||||
* javax.baja.sys.Type
|
||||
*/
|
||||
package com.tridium.alarm.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.baja.alarm.BAckState;
|
||||
import javax.baja.alarm.BAlarmRecord;
|
||||
import javax.baja.alarm.BSourceState;
|
||||
import javax.baja.sys.BStruct;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BAlarmConsoleRow
|
||||
extends BStruct {
|
||||
public static final Property alarm = BAlarmConsoleRow.newProperty((int)257, (BValue)new BAlarmRecord(), null);
|
||||
public static final Property ackState = BAlarmConsoleRow.newProperty((int)257, (String)"", null);
|
||||
public static final Type TYPE;
|
||||
private Map openAlarms;
|
||||
private Context cx;
|
||||
private int ackedCount;
|
||||
private int ackPendingCount;
|
||||
private int unackedCount;
|
||||
static /* synthetic */ Class class$com$tridium$alarm$model$BAlarmConsoleRow;
|
||||
|
||||
public final BAlarmRecord getAlarm() {
|
||||
return (BAlarmRecord)this.get(alarm);
|
||||
}
|
||||
|
||||
public final void setAlarm(BAlarmRecord bAlarmRecord) {
|
||||
this.set(alarm, (BValue)bAlarmRecord, null);
|
||||
}
|
||||
|
||||
public final String getAckState() {
|
||||
return this.getString(ackState);
|
||||
}
|
||||
|
||||
public final void setAckState(String string) {
|
||||
this.setString(ackState, string, null);
|
||||
}
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final String toString(Context context) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(this.getAlarm().getTimestamp().toString());
|
||||
stringBuffer.append(" ");
|
||||
stringBuffer.append(this.getAckStateStr());
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
final void update(BAlarmRecord bAlarmRecord) {
|
||||
BAlarmRecord bAlarmRecord2 = (BAlarmRecord)((Object)this.openAlarms.get(bAlarmRecord.getUuid()));
|
||||
bAlarmRecord = (BAlarmRecord)bAlarmRecord.newCopy(true);
|
||||
this.openAlarms.put(bAlarmRecord.getUuid(), bAlarmRecord);
|
||||
if (bAlarmRecord2 != null) {
|
||||
if (!bAlarmRecord2.isAcknowledged() && !bAlarmRecord2.isAckPending() && bAlarmRecord.isAckPending()) {
|
||||
++this.ackPendingCount;
|
||||
--this.unackedCount;
|
||||
} else if (bAlarmRecord2.isAckPending() && bAlarmRecord.isAcknowledged()) {
|
||||
--this.ackPendingCount;
|
||||
++this.ackedCount;
|
||||
} else if (bAlarmRecord2.isAckPending() && !bAlarmRecord.isAcknowledged() && !bAlarmRecord.isAckPending()) {
|
||||
--this.ackPendingCount;
|
||||
++this.unackedCount;
|
||||
} else if (bAlarmRecord2.isAcknowledged() && !bAlarmRecord.isAcknowledged() && !bAlarmRecord.isAckPending()) {
|
||||
--this.ackedCount;
|
||||
++this.unackedCount;
|
||||
} else if (bAlarmRecord2.isAcknowledged() && bAlarmRecord.isAckPending()) {
|
||||
--this.ackedCount;
|
||||
++this.ackPendingCount;
|
||||
} else if (bAlarmRecord.isAcknowledged() && !bAlarmRecord2.isAcknowledged() && !bAlarmRecord2.isAckPending()) {
|
||||
++this.ackedCount;
|
||||
--this.unackedCount;
|
||||
}
|
||||
} else if (bAlarmRecord.isAcknowledged()) {
|
||||
++this.ackedCount;
|
||||
} else if (bAlarmRecord.isAckPending()) {
|
||||
++this.ackPendingCount;
|
||||
} else {
|
||||
++this.unackedCount;
|
||||
}
|
||||
if (!(bAlarmRecord.getSourceState() != BSourceState.normal && bAlarmRecord.getSourceState() != BSourceState.alert || !bAlarmRecord.isAcknowledged() && bAlarmRecord.getAckRequired())) {
|
||||
if (this.openAlarms.get(bAlarmRecord.getUuid()) == null) {
|
||||
return;
|
||||
}
|
||||
this.openAlarms.remove(bAlarmRecord.getUuid());
|
||||
if (bAlarmRecord.isAcknowledged()) {
|
||||
--this.ackedCount;
|
||||
} else if (bAlarmRecord.getAckState() == BAckState.ackPending) {
|
||||
--this.ackPendingCount;
|
||||
} else {
|
||||
--this.unackedCount;
|
||||
}
|
||||
}
|
||||
this.updateAlarmInfo();
|
||||
}
|
||||
|
||||
final boolean isEmpty() {
|
||||
boolean bl = false;
|
||||
if (this.openAlarms.size() == 0) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
private final void updateAlarmInfo() {
|
||||
BAlarmRecord bAlarmRecord = null;
|
||||
BAlarmRecord bAlarmRecord2 = null;
|
||||
Iterator iterator = this.openAlarms.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
bAlarmRecord2 = (BAlarmRecord)((Object)this.openAlarms.get(iterator.next()));
|
||||
if (bAlarmRecord == null) {
|
||||
bAlarmRecord = bAlarmRecord2;
|
||||
continue;
|
||||
}
|
||||
if (!bAlarmRecord2.getTimestamp().isAfter(bAlarmRecord.getTimestamp())) continue;
|
||||
bAlarmRecord = bAlarmRecord2;
|
||||
}
|
||||
if (bAlarmRecord != null) {
|
||||
this.setAlarm(bAlarmRecord);
|
||||
}
|
||||
this.setAckState(this.getAckStateStr());
|
||||
}
|
||||
|
||||
private final String getAckStateStr() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(this.ackedCount).append(" ").append(BAckState.acked.getDisplayTag(this.cx)).append(" / ");
|
||||
stringBuffer.append(this.unackedCount).append(" ").append(BAckState.unacked.getDisplayTag(this.cx));
|
||||
if (this.ackPendingCount > 0) {
|
||||
stringBuffer.append(" / ").append(this.ackPendingCount).append(" ").append(BAckState.ackPending.getDisplayTag(this.cx));
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.openAlarms = new HashMap();
|
||||
this.ackedCount = 0;
|
||||
this.ackPendingCount = 0;
|
||||
this.unackedCount = 0;
|
||||
}
|
||||
|
||||
public BAlarmConsoleRow() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
public BAlarmConsoleRow(Context context) {
|
||||
this.this();
|
||||
this.cx = context;
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$com$tridium$alarm$model$BAlarmConsoleRow;
|
||||
if (clazz == null) {
|
||||
clazz = class$com$tridium$alarm$model$BAlarmConsoleRow = BAlarmConsoleRow.class("[Lcom.tridium.alarm.model.BAlarmConsoleRow;", false);
|
||||
}
|
||||
TYPE = Sys.loadType((Class)clazz);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user