id
stringlengths
36
36
text
stringlengths
1
1.25M
dfdc8350-4768-4b4e-bc54-540dd1350540
@Test public void matchingCall() throws Exception { final String message = "<ROWSET><ROW><DATA>my sample content</DATA></ROW></ROWSET>"; System.out.println(System.currentTimeMillis() + " - Request started."); String response = partnerGatewaySend.sendMessage(message); System.out.println(System.currentTimeMillis() + " - Reply timeout reached."); // don't expect response as 'sample content' is sent assertThat(response, is(nullValue())); }
1c360e14-51cd-4aa1-b259-65b3e453d573
@Test public void nonMatchingContent() throws Exception { final String message = "<ROWSET><ROW><USER_ORGANIZATION>1991919</USER_ORGANIZATION><USERTOKEN>nothing</USERTOKEN></ROW></ROWSET>"; String response = partnerGatewaySend.sendMessage(message); // expect response as message doesn't match the filter assertThat(response, notNullValue()); // make sure the response equals the message send assertThat(String.valueOf(response), equalTo(message)); }
84f5a0d7-07f0-4629-9c99-a23a61312be0
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { out.println("This is a servlet...just to illustrate we know how it works"); } finally { out.close(); } }
d637d7f0-3df2-4c94-9d5f-097f1cdaf386
public void setPassword(String pass){ this.pass = pass; }
cc441eff-d3ad-4a76-86ec-5b13ab9e3b7e
public String getPassword(){ return pass; }
fcca6fe4-6027-414b-920f-0aabe8b836dd
public boolean validate(String pas){ if (pas.length() > 10) return true; else return false; }
7332e7c6-f20e-401d-b2c8-b5fac6e743ac
@Transactional public void persist(Person person) { em.persist(person); }
fc54ba0a-93ab-4999-9ec1-16e871e612f0
public Person getPersonByID(int id){ Person person = em.find(Person.class, id); if (person !=null){ return person; } return null; }
f6570a03-15b5-48cf-a93d-cc5817a4d669
public List<Person> getAllPersons() { TypedQuery<Person> query = em.createQuery( "SELECT p FROM Person p", Person.class); return query.getResultList(); }
ecf7d770-a921-48d0-90d7-fe6d7a5016cf
public Person getPersonByName(String name){ try { Query q = em.createNamedQuery("Person.findByName"); q.setParameter("name", name); return (Person) q.getResultList().get(0); } catch(NoResultException e) { return null; } }
d0625f91-997d-4bfe-8337-a09bd83b291e
@RequestMapping(method = RequestMethod.GET) public String showForm(Map model) { Person person = new Person(); model.put("validationForm", person); return "validationForm"; }
a82f5def-bc91-4ff5-97a0-f77fbb85af4d
@RequestMapping(method = RequestMethod.POST) public String processValidatinForm(@ModelAttribute("validationForm") Person person, BindingResult result,SessionStatus status) { validator.validate(person, result); if (result.hasErrors()){ return "validationForm"; } else { status.setComplete(); //persist Data data1 = new Data("zip"); Role role1 = new Role("admin"); data1.setPerson(person); List<Data> datas = new ArrayList<Data>(); datas.add(data1); List<Role> roles = new ArrayList<Role>(); roles.add(role1); person.setDatas(datas); person.setRoles(roles); personDao.persist(person); } return "redirect:person.htm"; }
549cd212-cc0d-4fa6-a446-dade243bba99
@RequestMapping(value="/person") public ModelAndView getData(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("persons", personDao.getAllPersons()); //ModelAndView(String viewName, String modelName, Object modelObject) return new ModelAndView("person", "model", myModel); }
e70b415d-a8f7-4f98-a1e6-3799cfbf1cad
public boolean supports(@SuppressWarnings("rawtypes") Class clazz) { return Person.class.isAssignableFrom(clazz); }
d6171b09-b8c2-4b0d-aeaa-62c621d5be11
public void validate(Object target, Errors errors) { Person person = (Person) target; if (person !=null){ if (person.getName() != null){ if (person.getName().length() < MIN_NAME){ errors.rejectValue("name","validation.name", new Object[] {new Integer(MIN_NAME)},"You're too young for this service"); } } else { errors.rejectValue("name","validation.name", new Object[] {new Integer(MIN_NAME)},"You're too young for this service"); } if (person.getAge() != null){ if (person.getAge() < MIN_AGE){ errors.rejectValue("age","validation.age", new Object[] {new Integer(MIN_AGE)},"You're too young for this service"); } } else { errors.rejectValue("age","validation.age", new Object[] {new Integer(MIN_AGE)},"You're too young for this service"); } } }
4eb1ed91-3ace-4ffc-b496-5568f35fdbf9
public Role(){ }
1e22ab98-1777-4c6a-b0ec-e844a4ecfe90
public Role(String roleName){ this.roleName = roleName; }
2a6103d6-dbef-4a24-988d-9ae83f86f554
public int getID() { return id; }
2fa4014d-7a48-45c4-8433-993c353a8e88
public void setID(int id) { this.id = id; }
a1ec69b8-98cd-4200-af0e-9b6d90c7a430
public String getRoleName() { return roleName; }
6e5ce062-009f-4d26-9fe5-3dce8ffe9981
public void setRoleName(String roleName) { this.roleName = roleName; }
7a390a47-8b00-4d02-8a51-6e5bba308f71
@XmlTransient public List<Person> getPersonList(){ return personList; }
020fc65b-1144-41af-9265-7ee8ba09c18b
public void setPersonList(List<Person> list){ this.personList = list; }
63c4d79d-90b2-4cb7-a09d-810dd8882c2a
public void setId(int id){ this.id = id; }
6d3afdac-5a39-441f-9417-e6f71d8b3741
public Person(){ }
16dd4691-d40c-45be-af69-9f16b4f6dfe9
public Person(String name, int age){ this.name = name; this.age = age; }
a9db2342-5915-4ac0-a6a1-73e72e5a307d
public int getID(){ return id; }
04b56ee4-9f44-4d57-8f19-db380e354228
public String getName() { return name; }
0ee3aaaf-9cd7-4ff9-bc51-7cb4cca0d94e
public void setName(String name) { this.name = name; }
2967d3c3-6116-44a7-a367-3b84e9cd82a9
public Integer getAge() { return age; }
c505b7c1-9996-4cf9-bdc6-18111c0bfcad
public void setAge(Integer age) { this.age = age; }
e44cf5f1-0f57-4455-af49-5e055b0d0f2d
public List<Role> getRoles(){ return roles; }
d2b724e1-107d-4a1a-82b3-362e473895f3
public void setRoles(List<Role> roles){ this.roles = roles; }
5a179537-8d39-41a7-a7e1-6d03e63bffb5
public void setDatas(List<Data> datas){ this.datas = datas; }
2e2c442d-e3c0-448c-a1cd-ede6dc707cc5
public List<Data> getDatas(){ return datas; }
c451ac13-d155-4aee-9383-3916c9d2f250
@Override public String toString() { return "Person [name=" + name + ", age=" + age + "]"; }
b7614003-0d85-4a9c-bc48-2791de2032d3
public Data(){ }
a12562c5-9ae6-47b8-b679-b4a1f633eb09
public Data(String fileName){ //this.id = id; this.fileName = fileName; }
dc270e4b-9c19-4078-aa6c-b8d2ab4d311a
public int getID(){ return id; }
7634bca7-151d-40bd-be68-3873f496818f
public String getFileName() { return fileName; }
9b7cdcde-006f-4ebf-895a-c777e586d2e8
public void setFileName(String fileName) { this.fileName = fileName; }
d0ff07c6-c7fc-4128-b9b8-a8f27438e5f8
@XmlTransient public Person getPerson(){ return person; }
b16b8073-a602-4662-a0b2-248b6c116537
public void setPerson(Person person){ this.person = person; }
d236c623-9fb1-4dba-8635-bd8eb3811223
@Override public String toString() { return "File [name=" + fileName +"]"; }
335f81fd-f00f-4d4b-a023-0096b48c0591
public ResourceNotFoundException(String message){ super(message); }
873cae4b-ab8c-4c3b-a061-dcdf16f15b70
@RequestMapping(value = "/{name}", method = RequestMethod.GET) @ResponseBody public Person randomPerson(@PathVariable String name) throws ResourceNotFoundException { Person person = (Person) repo.getPersonByName(name); if (person==null){ throw new ResourceNotFoundException("Id not found in the request"); } else { return person; } }
c0cc0b9b-7d81-40f1-940a-3d5b2b2ca37c
@RequestMapping(value = "/person/{id}.json", method = RequestMethod.GET) @ResponseBody public Person getByIdJSON(@PathVariable("id") int id) { Person person = (Person) repo.getPersonByID(id); if (person==null) throw new ResourceNotFoundException("Id not found in the request"); return person; }
1d259e28-28af-47e7-8e16-8e3f31d5136a
@RequestMapping(value = "/person/{id}.xml", method = RequestMethod.GET) @ResponseBody public Person getByIdXML(@PathVariable("id") int id) { Person person = (Person) repo.getPersonByID(id); if (person==null) throw new ResourceNotFoundException("Id not found in the request"); return person; }
7c26d09a-fb14-4f40-82ad-8695b765c2f0
@RequestMapping(value="/personalt/{id}") @ResponseBody public Person getByIdFromParam(@PathVariable("id") int id) { return repo.getPersonByID(id); }
a947900a-b74f-4d78-a5e2-529fb8c45c5f
@Override public Descriptor getDescriptor() { return TTC13ParseController.getDescriptor(); }
a66cf697-9388-408f-898c-076c6b70819a
public static Activator getInstance() { if(sPlugin == null) return new Activator(); return sPlugin; }
6f1b53de-200e-4c63-8c7a-f694ef99b46a
public Activator () { super(); sPlugin = this; }
d0849080-a115-4d0c-993b-ae547ef7b57e
@Override public void start(BundleContext context) throws Exception { super.start(context); }
5d30ff31-e335-4aa7-b716-e35dff32b690
@Override public String getID() { return kPluginID; }
5efe0e2e-e84b-4b9c-853c-df28238e2b83
@Override public String getLanguageID() { return kLanguageName; }
dc04f1a8-b575-4bec-8177-6ffa70e51c4b
public static synchronized Descriptor getDescriptor() { if(notLoadingCause != null) throw new RuntimeException(notLoadingCause); if(descriptor == null) createDescriptor(); return descriptor; }
58364b4e-2418-487e-9e57-aeab825cff63
protected static synchronized void setDescriptor(Descriptor descriptor) { TTC13ParseControllerGenerated.descriptor = descriptor; }
2d1a4dcb-7064-4776-8614-d29a6c08b814
protected static void createDescriptor() { try { InputStream descriptorStream = TTC13ParseControllerGenerated.class.getResourceAsStream(DESCRIPTOR); InputStream table = TTC13ParseControllerGenerated.class.getResourceAsStream(TABLE); boolean filesystem = false; if(descriptorStream == null && new File("./" + DESCRIPTOR).exists()) { descriptorStream = new FileInputStream("./" + DESCRIPTOR); filesystem = true; } if(table == null && new File("./" + TABLE).exists()) { table = new FileInputStream("./" + TABLE); filesystem = true; } if(descriptorStream == null) throw new BadDescriptorException("Could not load descriptor file from " + DESCRIPTOR + " (not found in plugin: " + getPluginLocation() + ")"); if(table == null) throw new BadDescriptorException("Could not load parse table from " + TABLE + " (not found in plugin: " + getPluginLocation() + ")"); descriptor = DescriptorFactory.load(descriptorStream, table, filesystem ? Path.fromPortableString("./") : null); descriptor.setAttachmentProvider(TTC13ParseControllerGenerated.class); } catch(BadDescriptorException exc) { notLoadingCause = exc; Environment.logException("Bad descriptor for " + LANGUAGE + " plugin", exc); throw new RuntimeException("Bad descriptor for " + LANGUAGE + " plugin", exc); } catch(IOException exc) { notLoadingCause = exc; Environment.logException("I/O problem loading descriptor for " + LANGUAGE + " plugin", exc); throw new RuntimeException("I/O problem loading descriptor for " + LANGUAGE + " plugin", exc); } }
56bc0a67-47d2-41a2-a8c5-f7f0e5f556f2
private static String getPluginLocation() { return TTC13ParseController.class.getProtectionDomain().getCodeSource().getLocation().getFile(); }
2a9533aa-f6d6-46d2-bc44-4ab924751c30
@Override public IParseController getWrapped() { if(!isInitialized()) { if(notLoadingCause != null) throw new RuntimeException(notLoadingCause); try { initialize(this, getDescriptor().getLanguage()); } catch(BadDescriptorException exc) { notLoadingCause = exc; throw new RuntimeException(exc); } } return super.getWrapped(); }
19e0fe5a-4698-4294-b448-f7bcd830d4db
@Override protected void setNotLoadingCause(Throwable value) { notLoadingCause = value; super.setNotLoadingCause(value); }
affe5ac9-7909-4afd-948f-f63f25f9c8a0
public static void init(Context context) { // Called when the editor is being initialized }
9a1599b4-76a5-4256-ab16-a12d850b7405
public InteropRegisterer() { super(new Strategy[] { java_strategy_0_0.instance }); }
1e7d7332-f963-4222-8745-95f91b37884f
@Override public IStrategoTerm invoke(Context context, IStrategoTerm current) { context.getIOAgent().printError("Input for java-strategy: " + current); ITermFactory factory = context.getFactory(); return factory.makeString("Regards from java-strategy"); }
f5f9afdc-82a8-4cb2-908b-7d228caaf28a
public String liveStatus(String streamname) { String liveStatus = "Offline"; BufferedReader readurl = null; try { URL url = new URL("http://api.justin.tv/api/stream/list.json?jsonp=&channel=" + streamname); readurl = new BufferedReader(new InputStreamReader(url.openStream())); String wir = readurl.readLine(); String compare = "[]"; if (wir.equals(compare)) { liveStatus = "Offline"; } else { liveStatus = "Online"; } } catch (IOException ex) { Logger.getLogger(StreamStatus.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(StreamStatus.class.getName()).log(Level.SEVERE, null, ex); } finally { try { readurl.close(); } catch (IOException ex) { Logger.getLogger(StreamStatus.class.getName()).log(Level.SEVERE, null, ex); } } return liveStatus; }
6642d925-ed9e-4903-9555-bb626b17c053
@Override public void run() { for (Map.Entry<String, String> entry : Main.channels.entrySet()) { StreamStatus m = new StreamStatus(); String key = entry.getKey(); String status = entry.getValue(); if (status.equalsIgnoreCase("Online")) { Bukkit.getServer().broadcastMessage(Main.prefix + key + " is currently LiveStreaming!" + ChatColor.GOLD+" To watch " + key + ", click: http://keicraft.us/live.php"); } } }
77ffa401-4e49-4629-8e41-bc020bca6dbc
@Override public void onEnable() { this.log = getLogger(); PluginDescriptionFile pdf = this.getDescription(); channels.put("keiaxx", "Offline"); channels.put("rushnett", "Offline"); channels.put("walrusthefluffy", "Offline"); log.info(pdf.getName() + " version " + pdf.getVersion() + " has been enabled!"); //checkUpdates(); Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Broadcaster(), 20L, 6000L); Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new StatusUpdater(), 20L, 2400L); }
c716d163-9705-4bb0-baf9-c3b98edf8a56
@Override public void onDisable() { Bukkit.getServer().getScheduler().cancelTask(broadID); Bukkit.getServer().getScheduler().cancelTask(statID); log.info("[KCLiveStream] has been disabled!"); }
b3361584-ba2b-46ca-801e-257f1201d0f7
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("stream")) { try{ if(args[0].equalsIgnoreCase("debug")){ if(Main.Debug == true){ Main.Debug = false; sender.sendMessage(prefix + "Disabled debug mode."); }else{ Main.Debug = true; sender.sendMessage(prefix + "Enabled debug mode."); } }else if (channels.containsKey(args[0]) || channels.containsKey(args[0].toLowerCase())) { sender.sendMessage(prefix + "Click to view: http://twitch.tv/" + args[0].toLowerCase()); return true; } else { sender.sendMessage(prefix + "Channel not found! Valid channels: " + channels.keySet()); return true; } }catch(ArrayIndexOutOfBoundsException ae){ sender.sendMessage(prefix+" Incorrect syntax! /stream <Channel> "); return true; } } return false; }
2c015e2b-0f67-482e-9ff8-b9c01b4da084
@Override public void run() { if (Main.Debug) { System.out.println("Parsing..."); } for (Map.Entry<String, String> entry : Main.channels.entrySet()) { StreamStatus m = new StreamStatus(); String key = entry.getKey(); //before Check String value = entry.getValue(); //after Check String stat = m.liveStatus(key); if (value.equalsIgnoreCase(stat)) { if (Main.Debug) { System.out.println("Channel " + key + " is still " + stat); } } else { if (Main.Debug) { System.out.println("Channel " + key + " is now " + stat); } if (stat.equalsIgnoreCase("offline")) { Bukkit.getServer().broadcastMessage(Main.prefix + key + " is now offline!"); } if (stat.equalsIgnoreCase("online")) { Bukkit.getServer().broadcastMessage(Main.prefix + key + " is now online!" +ChatColor.GOLD+" To watch " + key + ", click: http://keicraft.us/live.php"); } Main.channels.put(key, stat); } } if (Main.Debug) { System.out.println(Main.channels); } }
857d209f-56fe-490f-b18a-258a35dd4423
public AppTest( String testName ) { super( testName ); }
bd668f44-a9e7-4074-a984-4e360c250d0b
public static Test suite() { return new TestSuite( AppTest.class ); }
0e02c716-0991-42a2-aa4c-9e1f74616122
public void testApp() { assertTrue( true ); }
b16cb36d-63fb-4b68-96d9-828e65ca06de
public RequestCore(String url) { this.requestUrl = url; this.method = HttpMethod.HTTP_GET; this.requestHeaders = new HashMap<String, String>(); this.requestBody = ""; }
bcd25c1a-68f1-4c30-939a-abd8976cfe5f
public RequestCore addHeader(String headerKey, String headerValue) { this.requestHeaders.put(headerKey, headerValue); return this; }
964dc019-89be-4e77-8b98-381b0ec17f18
public RequestCore removeHeader(String key) { if (requestHeaders.containsKey(key)) { requestHeaders.remove(key); } return this; }
b8333d91-7685-479c-891f-bbc2152b7875
public RequestCore setMethod(HttpMethod method) { this.method = method; return this; }
283f1077-596e-43c0-ace5-5aa42507b219
public RequestCore setUseragent(String ua) { this.useragent = ua; return this; }
4a663ed2-21fe-4006-913f-1fe10195fda9
public RequestCore setBody(String body) { this.requestBody = body; return this; }
315af997-b5c9-4af9-81aa-86d9b8ab7fd6
public RequestCore setConnectionOption(ConnectionOption connOption) { this.connectionOption = connOption; return this; }
1cb16e28-6e3f-4524-a1f5-81e69c38739c
public RequestCore setRequestUrl(String url) { this.requestUrl = url; return this; }
1cad2aed-efac-4684-b27f-49266e4be255
public void sendRequest() { executeRequest(); }
64d2dbe2-0a75-44db-89ee-91f37c3e1d48
private void executeRequest() { HttpClient client = new HttpClient(); HttpConnectionManagerParams hcManagerParams = client.getHttpConnectionManager().getParams(); hcManagerParams.setConnectionTimeout(connectionOption.connectionTimeout); hcManagerParams.setSoTimeout(connectionOption.optTimeout); PostMethod post = new PostMethod(requestUrl); if (requestHeaders != null && !requestHeaders.isEmpty()) { Set<String> headerKeySet = requestHeaders.keySet(); for (String headerKey : headerKeySet) { String headerValue = requestHeaders.get(headerKey); post.addRequestHeader(headerKey, headerValue); } } post.setRequestEntity(new StringRequestEntity(requestBody)); try { responseCode = client.executeMethod(post); responseBody = post.getResponseBodyAsString(); logger.info(responseBody); Header[] rspHeaders = post.getResponseHeaders(); responseHeaders = new HashMap<String, String>(); for (Header rspHeader : rspHeaders) { responseHeaders.put(rspHeader.getName(), rspHeader.getValue()); } } catch (IOException ex) { logger.error(ex); } }
c1d2f213-3f7a-4649-a977-b2a67171a3d1
public Map<String, String> getResponseHeader() { return Collections.unmodifiableMap(this.responseHeaders); }
55d1a1a0-8612-4b86-b8bc-798b51a93442
public Map<String, String> getResponseHeader(String header) { return Collections.singletonMap(header, this.responseHeaders.get(header)); }
b59b4c96-06e4-4f37-90d3-39550c641adb
public String getResponseBody() { return this.responseBody; }
b09dc50d-c50c-43be-a039-fa64642e96a8
public int getResponseCode() { return this.responseCode; }
f6522aff-aeb6-4aa9-8bd0-cdbc00ecb64a
private HttpMethod(String method) { this.method = method; }
becaf580-b900-4abd-9ba9-3e80fe94e44e
@Override public String toString() { return method; }
dd8470a5-cab2-49f2-9b07-134d9d4005b6
public ConnectionOption(int optTimeout, int connectionTimeout) { this.optTimeout = optTimeout; this.connectionTimeout = connectionTimeout; }
e3d86320-adf2-4c64-8948-b18e10db4ef6
public ChannelException(String msg, int code) { super(msg); this.code = code; }
bcc17e02-4f97-4e0b-99cc-0d4fa5cd694f
public static void main(String[] args) { System.out.println("Baidu Cloud Push for Java Version 1.0"); }
1c1e073c-0161-4619-960c-5033d3d3228f
public void initialize(String apiKey, String secretKey, ConnectionOption option) { if (checkString(apiKey, 1, 64)) { this.apiKey = apiKey; } else { throw new ChannelException("invalid param - apiKey["+apiKey+"]," + "which must be a 1 - 64 length string", CHANNEL_SDK_INIT_FAIL ); } if (checkString(secretKey, 1, 64)) { this.secretKey = secretKey; } else { throw new ChannelException("invalid param - secretKey["+secretKey+"]," + "which must be a 1 - 64 length string", CHANNEL_SDK_INIT_FAIL ); } if (option != null) { this.connOption = option; } resetErrorStatus(); }
764763bb-afa9-47b6-b718-1ffb47941c8d
public boolean setApiKey(String apiKey) { this.resetErrorStatus(); try { if (this.checkString(apiKey, 1, 64)) { this.apiKey = apiKey; } else { throw new ChannelException("invaid apiKey ( "+ apiKey + " ), which must be a 1 - 64 length string", CHANNEL_SDK_INIT_FAIL); } } catch (ChannelException ex) { this.channelExceptionHandler(ex); return false; } return true; }
ab183bdf-00ee-4dce-b9c6-0d274fe8b98f
public boolean setSecretKey(String secretKey) { this.resetErrorStatus(); try { if (this.checkString(secretKey, 1, 64)) { this.secretKey = secretKey; } else { throw new ChannelException("invaid secretKey ( "+ secretKey + " ), which must be a 1 - 64 length string", CHANNEL_SDK_INIT_FAIL); } } catch (ChannelException ex) { this.channelExceptionHandler(ex); return false; } return true; }
b1b0b157-5234-4c16-a819-d7e00b7ca56d
public int getRequestId ( ) { return this.requestId; }
511ff328-183e-4873-9d1f-1cfdcf8ec2dc
public JSONObject queryBindList (String userId, Map<String, String> optional) { this.resetErrorStatus( ); try { Map<String, String> args = new HashMap<String, String>(optional); args.put(USER_ID, userId); String[] needArray = {USER_ID}; args = prepareArgs(needArray, args); args.put(METHOD, "query_bindlist"); return this.commonProcess(args); } catch (ChannelException ex ) { this.channelExceptionHandler (ex); return null; } }
c49f4d7e-75e4-44c1-9d14-b3dc689601c6
public JSONObject pushMessage(int pushType, String messages, String msgKeys, Map<String, String> optional) { this.resetErrorStatus(); try { Map<String, String> args = new HashMap<String, String>(optional); args.put(PUSH_TYPE, String.valueOf(pushType)); args.put(MESSAGES, messages); args.put(MSG_KEYS, msgKeys); String[] needArray = {PUSH_TYPE, MESSAGES, MSG_KEYS}; args = prepareArgs(needArray, args); args.put(METHOD, "push_msg"); switch (pushType) { case PUSH_TO_USER: if (!args.containsKey(USER_ID) || args.get(USER_ID) == null || args.get(USER_ID).isEmpty()) { throw new ChannelException("userId should be specified in optional when pushType is PUSH_TO_USER", CHANNEL_SDK_PARAM); } break; case PUSH_TO_TAG: if (!args.containsKey(TAG_NAME) || args.get(TAG_NAME) == null || args.get(TAG_NAME).isEmpty()) { throw new ChannelException("tag should be specified in optional[] when pushType is PUSH_TO_TAG", CHANNEL_SDK_PARAM); } break; case PUSH_TO_ALL: break; case PUSH_TO_DEVICE: if (!args.containsKey(CHANNEL_ID)) { throw new ChannelException("channelId should be specified in optional[] when pushType is PUSH_TO_DEVICE", CHANNEL_SDK_PARAM); } break; default: throw new ChannelException("pushType value is not supported or not specified", CHANNEL_SDK_PARAM); } return this.commonProcess(args); } catch (ChannelException ex) { this.channelExceptionHandler (ex); return null; } }
5635a45d-f017-459b-8a51-bd377e00591e
private boolean checkString(String str, int min, int max) { if (str!=null && str.length() >= min && str.length() <= max) { return true; } return false; }
7ab1822d-2cce-40f6-9818-b2c537797eca
private void channelExceptionHandler(ChannelException ex) { int tmpCode = ex.code; if (0 == tmpCode) { tmpCode = CHANNEL_SDK_SYS; } this.errcode = tmpCode; if (this.errcode >= 30000) { this.errmsg = ex.getMessage(); } else { this.errmsg = arrayErrorMap[this.errcode] ; } }