Skip to content

Commit 7f4563e

Browse files
committed
LL-1057
1 parent a14f03a commit 7f4563e

File tree

9 files changed

+1548
-1550
lines changed

9 files changed

+1548
-1550
lines changed

serv/jobs/ss-dataimport/ss-dataimport-impl/src/main/java/at/kc/tugraz/ss/serv/dataimport/impl/evernote/SSDataImportEvernoteNoteContentHandler.java

Lines changed: 85 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -139,93 +139,91 @@ public void handleNoteContent() throws Exception{
139139

140140
public static String parseXHTML(final String path) throws Exception{
141141

142-
return "";
142+
BufferedReader br = null;
143+
String result = SSStrU.empty;
143144

144-
// BufferedReader br = null;
145-
// String result = SSStrU.empty;
146-
//
147-
// try{
148-
//
149-
// String line, text, tag, tmpTag, href, title;
150-
// int tagIndex, tagEndIndex, hrefIndex, hrefEndIndex, titleIndex, titleEndIndex;
151-
//
152-
// br = new BufferedReader(new FileReader(new File(path)));
153-
//
154-
// while((line = br.readLine()) != null){
155-
//
156-
// line = line.trim();
157-
//
158-
// while(line.contains("<")){
159-
//
160-
// if(!line.contains(">")){
161-
// throw new Exception("xhtml invalid");
162-
// }
163-
//
164-
// tagIndex = line.indexOf("<");
165-
// tagEndIndex = line.indexOf(">");
166-
// tag = line.substring(tagIndex, tagEndIndex + 1);
167-
// tmpTag = line.substring(tagIndex, tagEndIndex + 1);
168-
//
169-
// if(tagIndex != 0){
170-
//
171-
// text = line.substring(0, tagIndex).replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty).trim();
172-
//
173-
// if(!text.isEmpty()){
174-
// result += text + SSStrU.backslashRBackslashN;
175-
// }
176-
// }
177-
//
178-
// while(tmpTag.contains("href=\"")){
179-
//
180-
// hrefIndex = tmpTag.indexOf("href=\"");
181-
// hrefEndIndex = tmpTag.indexOf("\"", hrefIndex + 6);
182-
// href = tmpTag.substring(hrefIndex + 6, hrefEndIndex);
183-
//
184-
// if(tmpTag.contains("title=\"")){
185-
//
186-
// titleIndex = tmpTag.indexOf("title=\"");
187-
// titleEndIndex = tmpTag.indexOf("\"", titleIndex + 7);
188-
// title = tmpTag.substring(titleIndex + 7, titleEndIndex);
189-
//
190-
// result += title.replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty) + ": " + SSStrU.backslashRBackslashN;
191-
//
192-
// tmpTag = tmpTag.substring(0, titleIndex) + tmpTag.substring(titleEndIndex + 1, tmpTag.length() - 1);
193-
//
194-
// hrefIndex = tmpTag.indexOf("href=\"");
195-
// hrefEndIndex = tmpTag.indexOf("\"", hrefIndex + 6);
196-
// href = tmpTag.substring(hrefIndex + 6, hrefEndIndex);
197-
//
198-
// tmpTag = tmpTag.substring(0, hrefIndex) + tmpTag.substring(hrefEndIndex + 1, tmpTag.length() - 1);
199-
//
200-
// result += href + SSStrU.backslashRBackslashN;
201-
//
202-
// }else{
203-
// result += "link" + ": " + href + SSStrU.backslashRBackslashN;
204-
//
205-
// tmpTag = tmpTag.substring(0, hrefIndex) + tmpTag.substring(hrefEndIndex + 1, tmpTag.length() - 1);
206-
// }
207-
// }
208-
//
209-
// line = line.replace(tag, SSStrU.empty).replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty).trim();
210-
// }
211-
//
212-
// line = line.replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty).trim();
213-
//
214-
// if(!line.isEmpty()){
215-
// result += line + SSStrU.backslashRBackslashN;
216-
// }
217-
// }
218-
//
219-
// return result;
220-
//
221-
// }catch(Exception error){
222-
// SSServErrReg.regErrThrow(error);
223-
// return null;
224-
// }finally{
225-
//
226-
// if(br != null){
227-
// br.close();
228-
// }
229-
// }
145+
try{
146+
147+
String line, text, tag, tmpTag, href, title;
148+
int tagIndex, tagEndIndex, hrefIndex, hrefEndIndex, titleIndex, titleEndIndex;
149+
150+
br = new BufferedReader(new FileReader(new File(path)));
151+
152+
while((line = br.readLine()) != null){
153+
154+
line = line.trim();
155+
156+
while(line.contains("<")){
157+
158+
if(!line.contains(">")){
159+
throw new Exception("xhtml invalid");
160+
}
161+
162+
tagIndex = line.indexOf("<");
163+
tagEndIndex = line.indexOf(">");
164+
tag = line.substring(tagIndex, tagEndIndex + 1);
165+
tmpTag = line.substring(tagIndex, tagEndIndex + 1);
166+
167+
if(tagIndex != 0){
168+
169+
text = line.substring(0, tagIndex).replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty).trim();
170+
171+
if(!text.isEmpty()){
172+
result += text + SSStrU.backslashRBackslashN;
173+
}
174+
}
175+
176+
while(tmpTag.contains("href=\"")){
177+
178+
hrefIndex = tmpTag.indexOf("href=\"");
179+
hrefEndIndex = tmpTag.indexOf("\"", hrefIndex + 6);
180+
href = tmpTag.substring(hrefIndex + 6, hrefEndIndex);
181+
182+
if(tmpTag.contains("title=\"")){
183+
184+
titleIndex = tmpTag.indexOf("title=\"");
185+
titleEndIndex = tmpTag.indexOf("\"", titleIndex + 7);
186+
title = tmpTag.substring(titleIndex + 7, titleEndIndex);
187+
188+
result += title.replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty) + ": " + SSStrU.backslashRBackslashN;
189+
190+
tmpTag = tmpTag.substring(0, titleIndex) + tmpTag.substring(titleEndIndex + 1, tmpTag.length() - 1);
191+
192+
hrefIndex = tmpTag.indexOf("href=\"");
193+
hrefEndIndex = tmpTag.indexOf("\"", hrefIndex + 6);
194+
href = tmpTag.substring(hrefIndex + 6, hrefEndIndex);
195+
196+
tmpTag = tmpTag.substring(0, hrefIndex) + tmpTag.substring(hrefEndIndex + 1, tmpTag.length() - 1);
197+
198+
result += href + SSStrU.backslashRBackslashN;
199+
200+
}else{
201+
result += "link" + ": " + href + SSStrU.backslashRBackslashN;
202+
203+
tmpTag = tmpTag.substring(0, hrefIndex) + tmpTag.substring(hrefEndIndex + 1, tmpTag.length() - 1);
204+
}
205+
}
206+
207+
line = line.replace(tag, SSStrU.empty).replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty).trim();
208+
}
209+
210+
line = line.replace("&amp;nbsp;", SSStrU.empty).replace("Â", SSStrU.empty).trim();
211+
212+
if(!line.isEmpty()){
213+
result += line + SSStrU.backslashRBackslashN;
214+
}
215+
}
216+
217+
return result;
218+
219+
}catch(Exception error){
220+
SSServErrReg.regErrThrow(error);
221+
return null;
222+
}finally{
223+
224+
if(br != null){
225+
br.close();
226+
}
227+
}
230228
}
231229
}

ss-adapter/ss-adapter-rest-v1/src/main/java/at/kc/tugraz/ss/adapter/rest/v1/SSRestMainV1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public SSRestMainV1() throws Exception{
6666
resourceConfig.register(MultiPartFeature.class);
6767

6868
// SSLogU.info("rest enter");
69-
SSAdapterRestConf.instSet (SSFileU.dirCatalinaBase() + SSVocConf.dirNameConf + "ss-adapter-rest-conf.yaml");
69+
SSAdapterRestConf.instSet (SSFileU.dirCatalinaBase() + SSVocConf.dirNameConf + "ss-adapter-rest-conf-bp-3.yaml");
7070

7171
/* util */
7272
SSMimeTypeU.init();

ss-adapter/ss-adapter-rest-v1/src/main/webapp/api-docs/SSAdapterRESTFile.json

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,73 @@
44
"basePath" : "http://test-ll.know-center.tugraz.at/bp-3/SSAdapterRest",
55
"resourcePath" : "/SSAdapterRESTFile",
66
"apis" : [ {
7-
"path" : "/fileCanWrite",
7+
"path" : "/fileUserFileWrites",
88
"operations" : [ {
99
"method" : "POST",
10-
"summary" : "query whether given file can be downloaded with write access",
10+
"summary" : "retrieve files user currently could replace when uploading respective file again as he is writer",
1111
"notes" : "",
12-
"type" : "SSFileCanWriteRet",
13-
"nickname" : "fileCanWrite",
12+
"type" : "SSFileGetEditingFilesRet",
13+
"nickname" : "fileUserFileWrites",
1414
"produces" : [ "application/json" ],
1515
"consumes" : [ "application/json" ],
1616
"parameters" : [ {
1717
"name" : "body",
1818
"required" : false,
19-
"type" : "SSFileCanWritePar",
19+
"type" : "SSFileUserFileWritesPar",
2020
"paramType" : "body",
2121
"allowMultiple" : false
2222
} ]
2323
} ]
2424
}, {
25-
"path" : "/fileExtGet",
25+
"path" : "/fileSetReaderOrWriter",
2626
"operations" : [ {
2727
"method" : "POST",
28-
"summary" : "retrieve a file's extension",
28+
"summary" : "set user being writer or reaader for given file",
2929
"notes" : "",
30-
"type" : "SSFileExtGetRet",
31-
"nickname" : "fileExtGet",
30+
"type" : "SSFileSetReaderOrWriterRet",
31+
"nickname" : "fileSetReaderOrWriter",
3232
"produces" : [ "application/json" ],
3333
"consumes" : [ "application/json" ],
3434
"parameters" : [ {
3535
"name" : "body",
3636
"required" : false,
37-
"type" : "SSFileExtGetPar",
37+
"type" : "SSFileSetReaderOrWriterPar",
3838
"paramType" : "body",
3939
"allowMultiple" : false
4040
} ]
4141
} ]
4242
}, {
43-
"path" : "/fileSetReaderOrWriter",
43+
"path" : "/fileCanWrite",
4444
"operations" : [ {
4545
"method" : "POST",
46-
"summary" : "set user being writer or reaader for given file",
46+
"summary" : "query whether given file can be downloaded with write access",
4747
"notes" : "",
48-
"type" : "SSFileSetReaderOrWriterRet",
49-
"nickname" : "fileSetReaderOrWriter",
48+
"type" : "SSFileCanWriteRet",
49+
"nickname" : "fileCanWrite",
5050
"produces" : [ "application/json" ],
5151
"consumes" : [ "application/json" ],
5252
"parameters" : [ {
5353
"name" : "body",
5454
"required" : false,
55-
"type" : "SSFileSetReaderOrWriterPar",
55+
"type" : "SSFileCanWritePar",
5656
"paramType" : "body",
5757
"allowMultiple" : false
5858
} ]
5959
} ]
6060
}, {
61-
"path" : "/fileUserFileWrites",
61+
"path" : "/fileExtGet",
6262
"operations" : [ {
6363
"method" : "POST",
64-
"summary" : "retrieve files user currently could replace when uploading respective file again as he is writer",
64+
"summary" : "retrieve a file's extension",
6565
"notes" : "",
66-
"type" : "SSFileGetEditingFilesRet",
67-
"nickname" : "fileUserFileWrites",
66+
"type" : "SSFileExtGetRet",
67+
"nickname" : "fileExtGet",
6868
"produces" : [ "application/json" ],
6969
"consumes" : [ "application/json" ],
7070
"parameters" : [ {
7171
"name" : "body",
7272
"required" : false,
73-
"type" : "SSFileUserFileWritesPar",
73+
"type" : "SSFileExtGetPar",
7474
"paramType" : "body",
7575
"allowMultiple" : false
7676
} ]
@@ -137,7 +137,7 @@
137137
"SSFileSetReaderOrWriterPar" : {
138138
"id" : "SSFileSetReaderOrWriterPar",
139139
"description" : "",
140-
"required" : [ "file", "write", "key", "op", "user" ],
140+
"required" : [ "file", "write", "key", "user", "op" ],
141141
"properties" : {
142142
"file" : {
143143
"type" : "string",
@@ -151,39 +151,39 @@
151151
"type" : "string",
152152
"description" : "the user's access tocken"
153153
},
154-
"op" : {
155-
"type" : "string",
156-
"description" : "operation to be executed"
157-
},
158154
"user" : {
159155
"type" : "string",
160156
"description" : "the user's identifier"
157+
},
158+
"op" : {
159+
"type" : "string",
160+
"description" : "operation to be executed"
161161
}
162162
}
163163
},
164164
"SSFileUserFileWritesPar" : {
165165
"id" : "SSFileUserFileWritesPar",
166166
"description" : "",
167-
"required" : [ "key", "op", "user" ],
167+
"required" : [ "key", "user", "op" ],
168168
"properties" : {
169169
"key" : {
170170
"type" : "string",
171171
"description" : "the user's access tocken"
172172
},
173-
"op" : {
174-
"type" : "string",
175-
"description" : "operation to be executed"
176-
},
177173
"user" : {
178174
"type" : "string",
179175
"description" : "the user's identifier"
176+
},
177+
"op" : {
178+
"type" : "string",
179+
"description" : "operation to be executed"
180180
}
181181
}
182182
},
183183
"SSFileCanWritePar" : {
184184
"id" : "SSFileCanWritePar",
185185
"description" : "",
186-
"required" : [ "file", "key", "op", "user" ],
186+
"required" : [ "file", "key", "user", "op" ],
187187
"properties" : {
188188
"file" : {
189189
"type" : "string",
@@ -193,13 +193,13 @@
193193
"type" : "string",
194194
"description" : "the user's access tocken"
195195
},
196-
"op" : {
197-
"type" : "string",
198-
"description" : "operation to be executed"
199-
},
200196
"user" : {
201197
"type" : "string",
202198
"description" : "the user's identifier"
199+
},
200+
"op" : {
201+
"type" : "string",
202+
"description" : "operation to be executed"
203203
}
204204
}
205205
},
@@ -220,7 +220,7 @@
220220
"SSFileExtGetPar" : {
221221
"id" : "SSFileExtGetPar",
222222
"description" : "",
223-
"required" : [ "file", "key", "op", "user" ],
223+
"required" : [ "file", "key", "user", "op" ],
224224
"properties" : {
225225
"file" : {
226226
"type" : "string",
@@ -230,13 +230,13 @@
230230
"type" : "string",
231231
"description" : "the user's access tocken"
232232
},
233-
"op" : {
234-
"type" : "string",
235-
"description" : "operation to be executed"
236-
},
237233
"user" : {
238234
"type" : "string",
239235
"description" : "the user's identifier"
236+
},
237+
"op" : {
238+
"type" : "string",
239+
"description" : "operation to be executed"
240240
}
241241
}
242242
}

0 commit comments

Comments
 (0)