ProxyUtil.java
3.15 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
84
85
86
87
88
89
90
91
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.RepositoryException
* org.osgi.service.event.Event
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.dam.commons.proxy;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.osgi.service.event.Event;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Deprecated
public abstract class ProxyUtil {
private static final Logger log = LoggerFactory.getLogger(ProxyUtil.class);
public static final String PATH_JOBS = "/var/proxy/jobs";
public static final String PROPERTY_WORKING_DIR = "workingDir";
private static final String RESULT_NODE = "result";
private static final String STATUS_NODE = "status";
public static final String JOB_SERVLET = "/libs/dam/cloud/proxy";
public static final String PARAMETER_FILE = "file";
public static final String PARAMETER_JOB_ID = "jobid";
public static final String PARAMETER_JOB_EVENT = "jobevent";
public static final String PARAMETER_RESOURCE_PATH = "resourcePath";
public static final String JOB_STATUS = "jobStatus";
public static final String JOB_STATUS_CODE = "jobStatusCode";
public static final String OPERATION = ":operation";
public static final String OPERATION_JOB = "job";
public static final String OPERATION_REMOVE = "remove";
public static final String OPERATION_RESULT = "result";
public static final String OPERATION_STATUS = "status";
public static final String OPERATION_RESOURCE = "resource";
public static String getJobsDir() {
return "/var/proxy/jobs";
}
public static String getWorkingDir(String jobId) {
return "/var/proxy/jobs" + "/" + jobId;
}
public static String getWorkingDir(Event event) {
return (String)event.getProperty("workingDir");
}
public static Node getOrCreateStatusNode(Node jobNode) throws RepositoryException {
if (jobNode.hasNode("status")) {
return jobNode.getNode("status");
}
return jobNode.addNode("status", "nt:unstructured");
}
public static String getStatusNodePath(String jobId) {
return "/var/proxy/jobs" + "/" + jobId + "/" + "status";
}
public static String getResultNodePath(String jobId) {
return "/var/proxy/jobs" + "/" + jobId + "/" + "result";
}
public static Node getOrCreateResultNode(Node jobNode) throws RepositoryException {
if (jobNode.hasNode("result")) {
return jobNode.getNode("result");
}
return jobNode.addNode("result", "nt:unstructured");
}
public static String getEncodedString(String str, String encoding) throws UnsupportedEncodingException {
if (encoding == null) {
return str;
}
return URLEncoder.encode(str, encoding);
}
public static String getDecodedString(String str, String encoding) throws UnsupportedEncodingException {
if (encoding == null) {
return str;
}
return URLDecoder.decode(str, encoding);
}
}