@@ -21,11 +21,13 @@ public class IndexQueueMessageParser {
21
21
private final static String HEADER_ID = "id" ;
22
22
//The header name in the message to store the index type
23
23
private final static String HEADER_INDEX_TYPE = "index_type" ;
24
-
24
+ //The header name in the message to store the path of the object
25
+ private final static String HEADER_PATH = "path" ;
25
26
private Identifier identifier = null ;
26
27
private String indexType = null ;
27
28
private int priority = 1 ;
28
-
29
+ private String objectPath ;
30
+
29
31
private static Log logger = LogFactory .getLog (IndexQueueMessageParser .class );
30
32
31
33
/**
@@ -46,33 +48,49 @@ public void parse(AMQP.BasicProperties properties, byte[] body) throws InvalidRe
46
48
}
47
49
Object pidObj = headers .get (HEADER_ID );
48
50
if (pidObj == null ) {
49
- throw new InvalidRequest ("0000" , "The identifier cannot be null in the index queue message." );
51
+ throw new InvalidRequest (
52
+ "0000" , "The identifier cannot be null in the index queue message." );
50
53
}
51
54
String pid = ((LongString )pidObj ).toString ();
52
- if (pid == null || pid .trim ().equals ("" )) {
53
- throw new InvalidRequest ("0000" , "The identifier cannot be null or blank in the index queue message." );
55
+ if (pid == null || pid .isBlank ()) {
56
+ throw new InvalidRequest (
57
+ "0000" , "The identifier cannot be null or blank in the index queue message." );
54
58
}
55
59
logger .debug ("IndexQueueMessageParser.parse - the identifier in the message is " + pid );
56
60
identifier = new Identifier ();
57
61
identifier .setValue (pid );
58
62
59
63
Object typeObj = headers .get (HEADER_INDEX_TYPE );
60
64
if (typeObj == null ) {
61
- throw new InvalidRequest ("0000" , "The index type cannot be null in the index queue message." );
65
+ throw new InvalidRequest (
66
+ "0000" , "The index type cannot be null in the index queue message for " + pid );
62
67
}
63
68
indexType = ((LongString )typeObj ).toString ();
64
- if (indexType == null || indexType .trim ().equals ("" )) {
65
- throw new InvalidRequest ("0000" , "The index type cannot be null or blank in the index queue message." );
69
+ if (indexType == null || indexType .isBlank ()) {
70
+ throw new InvalidRequest (
71
+ "0000" ,
72
+ "The index type cannot be null or blank in the index queue message for " + pid );
73
+ }
74
+ logger .debug ("The index type in the message is " + indexType + " for " + pid );
75
+ Object pathObject = headers .get (HEADER_PATH );
76
+ if (pathObject != null ) {
77
+ objectPath = ((LongString )pathObject ).toString ();
66
78
}
67
- logger .debug ("IndexQueueMessageParser.parse - the index type in the message is " + indexType );
79
+ logger .debug (
80
+ "The file path of the object which will be indexed in the message is " + objectPath +
81
+ " for " + pid );
68
82
69
83
try {
70
84
priority = properties .getPriority ();
71
85
} catch (NullPointerException e ) {
72
- logger .info ("IndexQueueMessageParser.parse - the priority is not set in the message and we will set it one." );
86
+ logger .info (
87
+ "IndexQueueMessageParser.parse - the priority is not set in the message and we "
88
+ + "will set it one." );
73
89
priority =1 ;
74
90
}
75
- logger .debug ("IndexQueueMessageParser.parse - the priority in the message is " + priority );
91
+ logger .debug (
92
+ "IndexQueueMessageParser.parse - the priority in the message is " + priority + " for "
93
+ + pid );
76
94
}
77
95
78
96
/**
@@ -99,4 +117,14 @@ public int getPriority() {
99
117
return priority ;
100
118
}
101
119
120
+ /**
121
+ * Get the file path of the object, which will be indexed,
122
+ * after calling the parse method to parse the index queue message.
123
+ * @return the file path of the object. It can be null or blank, which
124
+ * means we don't have the object in the system.
125
+ */
126
+ public String getObjectPath () {
127
+ return objectPath ;
128
+ }
129
+
102
130
}
0 commit comments