FileDataBufferImpl.java
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.datamanager.impl;
import com.adobe.CORBA.ServantBase;
import com.adobe.aemds.datamanager.impl.DataManagerManagedConnection;
import com.adobe.service.DataManager;
import com.adobe.service.FileDataBufferOperations;
import java.io.File;
import java.io.RandomAccessFile;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.UNKNOWN;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FileDataBufferImpl
extends ServantBase
implements FileDataBufferOperations {
private static final Logger logger = LoggerFactory.getLogger(DataManager.class);
private String contentType = "unknown";
private final String filePath;
FileDataBufferImpl(String filePath, DataManagerManagedConnection resource) {
this.filePath = filePath;
resource.connect(this);
}
public String getFilePath() {
return this.filePath;
}
public long getBufLength() {
return new File(this.filePath).length();
}
public byte[] getBytes(long pos, long nBytes) {
byte[] data;
int count = (int)nBytes;
if (count <= 0) {
logger.error("Invalid arg nBytes for getBytes: {}", (Object)nBytes);
throw new UNKNOWN("Invalid arg nBytes for getBytes: " + nBytes);
}
try {
data = new byte[count];
}
catch (OutOfMemoryError e) {
logger.error("Out of memory exception in getBytes for size: " + count, (Throwable)e);
throw new UNKNOWN("Out of memory exception in getBytes for size: " + count);
}
try {
RandomAccessFile inFile = new RandomAccessFile(this.filePath, "r");
inFile.seek(pos);
inFile.readFully(data);
inFile.close();
}
catch (Exception e) {
logger.error("Exception while performing operation on file:" + e.toString(), (Throwable)e);
throw new UNKNOWN("Exception while performing operation on file:" + e.toString());
}
return data;
}
public String getContentType() {
return this.contentType;
}
public void setContentType(String contentType) {
if (this.contentType.equals("unknown")) {
if (contentType != null) {
this.contentType = contentType;
}
} else {
logger.debug("Content type already set: {}", (Object)this.contentType);
throw new BAD_INV_ORDER("Content type already set");
}
}
}