- Timestamp:
- 10/12/11 12:23:55 (7 months ago)
- Location:
- ssme/trunk
- Files:
-
- 1 added
- 16 modified
-
src/com/kh/ssme/rest/BasicServlet.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/CalendarServlet.java (modified) (1 diff)
-
src/com/kh/ssme/rest/EventingPartServlet.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/EventingServlet.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/GroupServlet.java (modified) (1 diff)
-
src/com/kh/ssme/rest/MeetingRequestServlet.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/parsers/AbstractEntityCreator.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/parsers/EntityParserTools.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/parsers/JSONEntityCreator.java (modified) (17 diffs)
-
src/com/kh/ssme/rest/parsers/RDFEntityCreator.java (added)
-
src/com/kh/ssme/rest/RepeatTypeServlet.java (modified) (1 diff)
-
src/com/kh/ssme/rest/TagServlet.java (modified) (2 diffs)
-
src/com/kh/ssme/rest/TimeFrameServlet.java (modified) (1 diff)
-
src/com/kh/ssme/rest/UserServlet.java (modified) (1 diff)
-
src/com/kh/ssme/rest/util/Params.java (modified) (1 diff)
-
src/com/kh/ssme/rest/util/ResponseType.java (modified) (2 diffs)
-
web/WEB-INF/tags/page.tag (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ssme/trunk/src/com/kh/ssme/rest/BasicServlet.java
r4101 r4130 83 83 * @throws Exception 84 84 */ 85 protected abstract JSONObject getJSON(BasicData data, int recursionLevel); 86 85 protected abstract JSONObject getJSON(BasicData data, int recursionLevel); 86 87 protected abstract String getRDF(BasicData data, int recursionLevel); 88 87 89 protected JSONObject getJSONCollection(List<BasicData> list, int recursionLevel){ 88 90 JSONObject result = new JSONObject(); … … 129 131 } 130 132 respondWithJSON(response, object, "application/json", true); 131 break; 133 break; 134 135 case RDF: 136 String rdf = ""; 137 if( data!=null && !data.isDeleted() ){ 138 rdf = getRDF(data, recursionLevel); 139 } 140 respondWithText(response, rdf, "application/rdf+xml", true); 141 break; 132 142 133 143 default: -
ssme/trunk/src/com/kh/ssme/rest/CalendarServlet.java
r4071 r4130 162 162 } 163 163 164 164 @Override 165 protected String getRDF(BasicData data, int recursionLevel) { 166 StringBuilder builder = new StringBuilder(); 167 try { 168 EntityParserTools.getCreator(EntityParserTools.CreatorType.RDF_CREATOR).create((Calendar)data, builder, recursionLevel); 169 } catch (Exception e) { 170 e.printStackTrace(); 171 } 172 return builder.toString(); 173 } 165 174 166 175 } -
ssme/trunk/src/com/kh/ssme/rest/EventingPartServlet.java
r4081 r4130 5 5 * Contribution from: Gdansk University of Technology, Poland 6 6 * Invented by: Sebastian R. Kruk 7 * Implemented by: Micha� Szopi� , Mariusz Cygan7 * Implemented by: Micha� Szopi�ski, Mariusz Cygan 8 8 * 9 9 * This program is free software: you can redistribute it and/or modify … … 138 138 } 139 139 140 140 @Override 141 protected String getRDF(BasicData data, int recursionLevel) { 142 StringBuilder builder = new StringBuilder(); 143 try { 144 EntityParserTools.getCreator(EntityParserTools.CreatorType.RDF_CREATOR).create((EventingPart)data, builder, recursionLevel); 145 } catch (Exception e) { 146 e.printStackTrace(); 147 } 148 return builder.toString(); 149 } 141 150 142 151 } -
ssme/trunk/src/com/kh/ssme/rest/EventingServlet.java
r4101 r4130 5 5 * Contribution from: Gdansk University of Technology, Poland 6 6 * Invented by: Sebastian R. Kruk 7 * Implemented by: Micha� Szopi� , Mariusz Cygan7 * Implemented by: Micha� Szopi�ski, Mariusz Cygan 8 8 * 9 9 * This program is free software: you can redistribute it and/or modify … … 158 158 } 159 159 160 160 @Override 161 protected String getRDF(BasicData data, int recursionLevel) { 162 StringBuilder builder = new StringBuilder(); 163 try { 164 EntityParserTools.getCreator(EntityParserTools.CreatorType.RDF_CREATOR).create((Eventing)data, builder, recursionLevel); 165 } catch (Exception e) { 166 e.printStackTrace(); 167 } 168 return builder.toString(); 169 } 161 170 162 171 } -
ssme/trunk/src/com/kh/ssme/rest/GroupServlet.java
r4075 r4130 140 140 } 141 141 142 @Override 143 protected String getRDF(BasicData data, int recursionLevel) { 144 StringBuilder builder = new StringBuilder(); 145 try { 146 EntityParserTools.getCreator(EntityParserTools.CreatorType.RDF_CREATOR).create((Group)data, builder, recursionLevel); 147 } catch (Exception e) { 148 e.printStackTrace(); 149 } 150 return builder.toString(); 151 } 142 152 143 153 } -
ssme/trunk/src/com/kh/ssme/rest/MeetingRequestServlet.java
r4101 r4130 5 5 * Contribution from: Gdansk University of Technology, Poland 6 6 * Invented by: Sebastian R. Kruk 7 * Implemented by: Micha� Szopi� , Mariusz Cygan7 * Implemented by: Micha� Szopi�ski, Mariusz Cygan 8 8 * 9 9 * This program is free software: you can redistribute it and/or modify … … 179 179 } 180 180 181 181 @Override 182 protected String getRDF(BasicData data, int recursionLevel) { 183 StringBuilder builder = new StringBuilder(); 184 try { 185 EntityParserTools.getCreator(EntityParserTools.CreatorType.RDF_CREATOR).create((MeetingRequest)data, builder, recursionLevel); 186 } catch (Exception e) { 187 e.printStackTrace(); 188 } 189 return builder.toString(); 190 } 182 191 183 192 } -
ssme/trunk/src/com/kh/ssme/rest/parsers/AbstractEntityCreator.java
r4116 r4130 24 24 25 25 import com.kh.ssme.model.ifc.*; 26 import org.json.JSONObject;27 28 import java.util.List;29 26 30 27 … … 38 35 * Create object for respond from common BasicData entity 39 36 * @param basicData 40 * @param json37 * @param result 41 38 * @param recursionLevel 42 39 * @throws Exception 43 40 */ 44 public void create(BasicData basicData, JSONObject json, int recursionLevel) throws Exception;41 public void create(BasicData basicData, Object result, int recursionLevel) throws Exception; 45 42 46 43 /** 47 44 * Create object for respond from Calendar entity 48 45 * @param calendar 49 * @param json46 * @param result 50 47 * @param recursionLevel 51 48 * @throws Exception 52 49 */ 53 public void create(Calendar calendar, JSONObject json, int recursionLevel) throws Exception;50 public void create(Calendar calendar, Object result, int recursionLevel) throws Exception; 54 51 55 52 /** 56 53 * Create object for respond from Eventing entity 57 54 * @param eventing 58 * @param json55 * @param result 59 56 * @param recursionLevel 60 57 * @throws Exception 61 58 */ 62 public void create(Eventing eventing, JSONObject json, int recursionLevel) throws Exception;59 public void create(Eventing eventing, Object result, int recursionLevel) throws Exception; 63 60 64 61 /** 65 62 * Create object for respond from EventingPart entity 66 63 * @param eventingPart 67 * @param json64 * @param result 68 65 * @param recursionLevel 69 66 * @throws Exception 70 67 */ 71 public void create(EventingPart eventingPart, JSONObject json, int recursionLevel) throws Exception;68 public void create(EventingPart eventingPart, Object result, int recursionLevel) throws Exception; 72 69 73 70 /** 74 71 * Create object for respond from Group entity 75 72 * @param group 76 * @param json73 * @param result 77 74 * @param recursionLevel 78 75 * @throws Exception 79 76 */ 80 public void create(Group group, JSONObject json, int recursionLevel) throws Exception;77 public void create(Group group, Object result, int recursionLevel) throws Exception; 81 78 82 79 /** 83 80 * Create object for respond from MeetingRequest entity 84 81 * @param meetingRequest 85 * @param json82 * @param result 86 83 * @param recursionLevel 87 84 * @throws Exception 88 85 */ 89 public void create(MeetingRequest meetingRequest, JSONObject json, int recursionLevel) throws Exception;86 public void create(MeetingRequest meetingRequest, Object result, int recursionLevel) throws Exception; 90 87 91 88 /** 92 89 * Create object for respond from RepeatType entity 93 90 * @param repeatType 94 * @param json91 * @param result 95 92 * @param recursionLevel 96 93 * @throws Exception 97 94 */ 98 public void create(RepeatType repeatType, JSONObject json, int recursionLevel) throws Exception;95 public void create(RepeatType repeatType, Object result, int recursionLevel) throws Exception; 99 96 100 97 /** 101 98 * Create object for respond from Role entity 102 99 * @param role 103 * @param json100 * @param result 104 101 * @param recursionLevel 105 102 * @throws Exception 106 103 */ 107 public void create(Role role, JSONObject json, int recursionLevel) throws Exception;104 public void create(Role role, Object result, int recursionLevel) throws Exception; 108 105 109 106 /** 110 107 * Create object for respond from Tag entity 111 108 * @param tag 112 * @param json109 * @param result 113 110 * @param recursionLevel 114 111 * @throws Exception 115 112 */ 116 public void create(Tag tag, JSONObject json, int recursionLevel) throws Exception;113 public void create(Tag tag, Object result, int recursionLevel) throws Exception; 117 114 118 115 /** 119 116 * Create object for respond from TimeFrame entity 120 117 * @param timeFrame 121 * @param json118 * @param result 122 119 * @param recursionLevel 123 120 * @throws Exception 124 121 */ 125 public void create(TimeFrame timeFrame, JSONObject json, int recursionLevel) throws Exception;122 public void create(TimeFrame timeFrame, Object result, int recursionLevel) throws Exception; 126 123 127 124 /** 128 125 * Create object for respond from User entity 129 126 * @param user 130 * @param json127 * @param result 131 128 * @param recursionLevel 132 129 * @throws Exception 133 130 */ 134 public void create(User user, JSONObject json, int recursionLevel) throws Exception;131 public void create(User user, Object result, int recursionLevel) throws Exception; 135 132 136 133 } -
ssme/trunk/src/com/kh/ssme/rest/parsers/EntityParserTools.java
r4027 r4130 38 38 */ 39 39 public enum CreatorType { 40 JSON_CREATOR; 40 JSON_CREATOR, 41 RDF_CREATOR 41 42 } 42 43 … … 57 58 return JSONEntityCreator.getInstance(); 58 59 } 60 if(type == CreatorType.RDF_CREATOR){ 61 return RDFEntityCreator.getInstance(); 62 } 59 63 return null; 60 64 } -
ssme/trunk/src/com/kh/ssme/rest/parsers/JSONEntityCreator.java
r4117 r4130 54 54 */ 55 55 @Override 56 public void create(BasicData basicData, JSONObject json, int recursionLevel) throws JSONException {56 public void create(BasicData basicData, Object jsonResult, int recursionLevel) throws JSONException { 57 57 // protected Long id_; 58 58 // protected Date createDate_; … … 60 60 // protected Boolean deleted_; 61 61 // protected String uuid_; 62 JSONObject json = (JSONObject)jsonResult; 62 63 63 64 if (basicData.getCreateDate() != null) { … … 79 80 */ 80 81 @Override 81 public void create(Calendar calendar, JSONObject json, int recursionLevel) throws JSONException {82 public void create(Calendar calendar, Object jsonResult, int recursionLevel) throws JSONException { 82 83 // private String name_ = ""; 83 84 // private Set<TimeFrame> timeFrames_ = new TreeSet<TimeFrame>(); 84 85 // private User user_; 86 JSONObject json = (JSONObject)jsonResult; 85 87 86 88 create((BasicData) calendar, json, recursionLevel); … … 131 133 */ 132 134 @Override 133 public void create(Eventing eventing, JSONObject json, int recursionLevel) throws JSONException {135 public void create(Eventing eventing, Object jsonResult, int recursionLevel) throws JSONException { 134 136 //private ParticipationTypeEnum participantType_; 135 137 //private MeetingRequest request_; … … 137 139 //private List<EventingPart> parts_; 138 140 //private StateEnum state_; 141 JSONObject json = (JSONObject)jsonResult; 139 142 140 143 create((BasicData) eventing, json, recursionLevel); … … 199 202 */ 200 203 @Override 201 public void create(EventingPart eventingPart, JSONObject json, int recursionLevel) throws JSONException {204 public void create(EventingPart eventingPart, Object jsonResult, int recursionLevel) throws JSONException { 202 205 //private StateEnum state_; 203 206 //private Eventing eventing_; 204 207 //private Date day_; 205 208 //private String map_; 209 JSONObject json = (JSONObject)jsonResult; 206 210 207 211 create((BasicData) eventingPart, json, recursionLevel); … … 238 242 */ 239 243 @Override 240 public void create(Group group, JSONObject json, int recursionLevel) throws JSONException {244 public void create(Group group, Object jsonResult, int recursionLevel) throws JSONException { 241 245 // private String name_ = ""; 242 246 // private Set<User> users_ = new TreeSet<User>(); 243 247 // private User owner_ = new User(); 248 JSONObject json = (JSONObject)jsonResult; 244 249 245 250 create((BasicData) group, json, recursionLevel); … … 296 301 */ 297 302 @Override 298 public void create(MeetingRequest meetingRequest, JSONObject json, int recursionLevel) throws JSONException {303 public void create(MeetingRequest meetingRequest, Object jsonResult, int recursionLevel) throws JSONException { 299 304 //private String title; 300 305 //private String description; … … 305 310 //private List<TimeFrame> decidedTimes_; 306 311 //private Eventing eventings_; private RepeatType repeatType_; 312 JSONObject json = (JSONObject)jsonResult; 307 313 308 314 create((BasicData) meetingRequest, json, recursionLevel); … … 391 397 */ 392 398 @Override 393 public void create(RepeatType repeatType, JSONObject json, int recursionLevel) throws JSONException {399 public void create(RepeatType repeatType, Object jsonResult, int recursionLevel) throws JSONException { 394 400 //private Integer count_; 395 401 //private Integer frequency_; … … 401 407 //private TimeFrame prototype_; 402 408 //private MeetingRequest request_; 409 JSONObject json = (JSONObject)jsonResult; 403 410 404 411 create((BasicData) repeatType, json, recursionLevel); … … 474 481 */ 475 482 @Override 476 public void create(Role role, JSONObject json, int recursionLevel) throws JSONException { 483 public void create(Role role, Object jsonResult, int recursionLevel) throws JSONException { 484 JSONObject json = (JSONObject)jsonResult; 477 485 478 486 create((BasicData) role, json, recursionLevel); … … 505 513 506 514 @Override 507 public void create(Tag tag, JSONObject json, int recursionLevel) throws JSONException { 515 public void create(Tag tag, Object jsonResult, int recursionLevel) throws JSONException { 516 JSONObject json = (JSONObject)jsonResult; 508 517 509 518 create((BasicData) tag, json, recursionLevel); … … 546 555 */ 547 556 @Override 548 public void create(TimeFrame timeFrame, JSONObject json, int recursionLevel) throws JSONException {557 public void create(TimeFrame timeFrame, Object jsonResult, int recursionLevel) throws JSONException { 549 558 //private Date from_; 550 559 //private Date to_; … … 560 569 //private List<Tag> tags_; 561 570 562 571 JSONObject json = (JSONObject)jsonResult; 572 563 573 create((BasicData) timeFrame, json, recursionLevel); 564 574 … … 668 678 */ 669 679 @Override 670 public void create(User user, JSONObject json, int recursionLevel) throws JSONException {680 public void create(User user, Object jsonResult, int recursionLevel) throws JSONException { 671 681 // private String login_ = ""; 672 682 // private String name_ = ""; … … 679 689 // TreeSet<com.kh.ssme.model.ifc.Calendar>(); 680 690 // private Set<Group> ownedGroups_ = new TreeSet<Group>(); 691 JSONObject json = (JSONObject)jsonResult; 681 692 682 693 create((BasicData) user, json, recursionLevel); -
ssme/trunk/src/com/kh/ssme/rest/RepeatTypeServlet.java
r4071 r4130 143 143 } 144 144 145 @Override 146 protected String getRDF(BasicData data, int recursionLevel) { 147 StringBuilder builder = new StringBuilder(); 148 try { 149 EntityParserTools.getCreator(CreatorType.RDF_CREATOR).create((RepeatType)data, builder, recursionLevel); 150 } catch (Exception e) { 151 e.printStackTrace(); 152 } 153 return builder.toString(); 154 } 155 145 156 } -
ssme/trunk/src/com/kh/ssme/rest/TagServlet.java
r4117 r4130 5 5 * Contribution from: Gdansk University of Technology, Poland 6 6 * Invented by: Sebastian R. Kruk 7 * Implemented by: Micha� Szopi� , Mariusz Cygan7 * Implemented by: Micha� Szopi�ski, Mariusz Cygan 8 8 * 9 9 * This program is free software: you can redistribute it and/or modify … … 154 154 return object; 155 155 } 156 157 @Override 158 protected String getRDF(BasicData data, int recursionLevel) { 159 StringBuilder builder = new StringBuilder(); 160 try { 161 EntityParserTools.getCreator(EntityParserTools.CreatorType.RDF_CREATOR).create((Tag)data, builder, recursionLevel); 162 } catch (Exception e) { 163 e.printStackTrace(); 164 } 165 return builder.toString(); 166 } 156 167 } -
ssme/trunk/src/com/kh/ssme/rest/TimeFrameServlet.java
r4071 r4130 146 146 } 147 147 148 @Override 149 protected String getRDF(BasicData data, int recursionLevel) { 150 StringBuilder builder = new StringBuilder(); 151 try { 152 EntityParserTools.getCreator(CreatorType.RDF_CREATOR).create((TimeFrame)data, builder, recursionLevel); 153 } catch (Exception e) { 154 e.printStackTrace(); 155 } 156 return builder.toString(); 157 } 158 148 159 } -
ssme/trunk/src/com/kh/ssme/rest/UserServlet.java
r4075 r4130 155 155 } 156 156 157 @Override 158 protected String getRDF(BasicData data, int recursionLevel) { 159 StringBuilder builder = new StringBuilder(); 160 try { 161 EntityParserTools.getCreator(CreatorType.RDF_CREATOR).create((User)data, builder, recursionLevel); 162 } catch (Exception e) { 163 e.printStackTrace(); 164 } 165 return builder.toString(); 166 } 157 167 158 168 -
ssme/trunk/src/com/kh/ssme/rest/util/Params.java
r4117 r4130 61 61 FLEX_APPLICATION("flexApp"), 62 62 JSON("json"), 63 RDF("rdf"), 63 64 LOGIN_ERROR("loginError"), 64 65 METHOD("_method"), -
ssme/trunk/src/com/kh/ssme/rest/util/ResponseType.java
r4071 r4130 107 107 } 108 108 } 109 }, 109 }, 110 111 RDF("application/rdf+xml"){ 112 @Override 113 public boolean accepts(HttpServletRequest request) { 114 boolean result = false; 115 116 if(!result) 117 result = "true".equals(request.getParameter( Params.RequestParams.RDF.paramName() )); 118 119 if(!result) 120 result = _accepts(request); 121 122 return result; 123 } 124 125 @Override 126 public void sendError(HttpServletResponse response, SSMEException ex) throws IOException { 127 response.sendError(ex.getStatus(), ex.getMessage()); 128 } 129 130 @Override 131 public void sendExceptionError(HttpServletResponse response, int status, String message) throws IOException{ 132 response.sendError(status, message); 133 } 134 }, 110 135 111 136 HTML{ … … 114 139 return false; 115 140 } 116 117 @Override 118 public void sendError(HttpServletResponse response, SSMEException ex) throws IOException { 119 response.sendError(ex.getStatus(), ex.getMessage()); 120 } 121 141 142 @Override 143 public void sendError(HttpServletResponse response, SSMEException ex) throws IOException { 144 response.sendError(ex.getStatus(), ex.getMessage()); 145 } 146 122 147 @Override 123 148 public void sendExceptionError(HttpServletResponse response, int status, String message) throws IOException{ 124 response.sendError(status, message); 125 } 126 }; 127 149 response.sendError(status, message); 150 } 151 }; 128 152 129 153 -
ssme/trunk/web/WEB-INF/tags/page.tag
r4124 r4130 1 1 <%@ tag language="java" pageEncoding="UTF-8" description="main template ssme" %> 2 2 3 <%@ taglib prefix="ssme" tagdir="/WEB-INF/tags /" %>3 <%@ taglib prefix="ssme" tagdir="/WEB-INF/tags" %> 4 4 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 5 5
