TODO: GSM 0338 pattern needs to be checked. It is used as an alternative for jcharset cause it is a gpl library and cannot be used.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5e87c96c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5e87c96c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5e87c96c Branch: refs/heads/master Commit: 5e87c96cda830cb73c5910d79092beabee9e6aa5 Parents: 4f8c9c9 Author: oalles <oal...@neivi.es> Authored: Mon Mar 21 13:59:31 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Mar 23 18:46:10 2016 +0100 ---------------------------------------------------------------------- .../apache/camel/component/cm/CMConstants.java | 82 ++++++++++---------- .../org/apache/camel/component/cm/CMUtils.java | 60 +++++++------- 2 files changed, 73 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/5e87c96c/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMConstants.java ---------------------------------------------------------------------- diff --git a/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMConstants.java b/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMConstants.java index ad8bfc4..138f75f 100644 --- a/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMConstants.java +++ b/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMConstants.java @@ -1,39 +1,43 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.cm; - -public interface CMConstants { - - String DEFAULT_SCHEME = "https://"; - - int DEFAULT_MULTIPARTS = 8; - - int MAX_UNICODE_MESSAGE_LENGTH = 70; - int MAX_GSM_MESSAGE_LENGTH = 160; - int MAX_UNICODE_MESSAGE_LENGTH_PER_PART_IF_MULTIPART = 67; - int MAX_GSM_MESSAGE_LENGTH_PER_PART_IF_MULTIPART = 153; - - // status code 200 - Error substrings - checkk it contains. - String ERROR_UNKNOWN = "Unknown error"; - String ERROR_NO_ACCOUNT = "No account found"; - String ERROR_INSUFICIENT_BALANCE = "Insufficient balance"; - String ERROR_UNROUTABLE_MESSAGE = "Message is unroutable"; - String ERROR_INVALID_PRODUCT_TOKEN = "Invalid product token"; - - String GSM_CHARACTERS_REGEX = "^[A-Za-z0-9 \\r\\n@£$¥èéùìòÃÃøà å\u0394_\u03A6\u0393\u039B\u03A9" - + "\u03A0\u03A8\u03A3\u0398\u039EÃæÃÃ!\"#$%&'()*+,\\-./:;<=>?¡ÃÃÃç¿äöñüà ^{}\\\\\\[~\\]|\u20AC]*$"; -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.cm; + +public interface CMConstants { + + String DEFAULT_SCHEME = "https://"; + + int DEFAULT_MULTIPARTS = 8; + + int MAX_UNICODE_MESSAGE_LENGTH = 70; + int MAX_GSM_MESSAGE_LENGTH = 160; + int MAX_UNICODE_MESSAGE_LENGTH_PER_PART_IF_MULTIPART = 67; + int MAX_GSM_MESSAGE_LENGTH_PER_PART_IF_MULTIPART = 153; + + // status code 200 - Error substrings - check it contains. + String ERROR_UNKNOWN = "Unknown error"; + String ERROR_NO_ACCOUNT = "No account found"; + String ERROR_INSUFICIENT_BALANCE = "Insufficient balance"; + String ERROR_UNROUTABLE_MESSAGE = "Message is unroutable"; + String ERROR_INVALID_PRODUCT_TOKEN = "Invalid product token"; + + // TODO: Review this pattern. + // or it should be foundnd an alternative to jcharset to check if a message is GSM 03.38 encodable + // See: + // https://en.wikipedia.org/wiki/GSM_03.38 + // http://frightanic.com/software-development/regex-for-gsm-03-38-7bit-character-set/ + String GSM_0338_REGEX = "^[A-Za-z0-9 \\r\\n@£$¥èéùìòÃÃøà å\u0394_\u03A6\u0393\u039B\u03A9\u03A0\u03A8\u03A3\u0398\u039EÃæÃÃ!\"#$%&'()*+,\\-./:;<=>?¡ÃÃÃç¿äöñüà ^{}\\\\\\[~\\]|\u20AC]*$"; +} http://git-wip-us.apache.org/repos/asf/camel/blob/5e87c96c/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMUtils.java ---------------------------------------------------------------------- diff --git a/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMUtils.java b/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMUtils.java index 932e99f..f0581da 100644 --- a/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMUtils.java +++ b/components/camel-cm/src/main/java/org/apache/camel/component/cm/CMUtils.java @@ -1,30 +1,30 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.cm; - -public final class CMUtils { - - private CMUtils() { - } - - public static boolean isGsm0338Encodeable(final String message) { - return message.matches(CMConstants.GSM_CHARACTERS_REGEX); - } - - // TODO: Have a look at - // https:// github.com/apache/camel/blob/master/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppUtils.java -} +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.cm; + +public final class CMUtils { + + private CMUtils() { + } + + public static boolean isGsm0338Encodeable(final String message) { + return message.matches(CMConstants.GSM_0338_REGEX); + } + + // TODO: Have a look at + // https:// github.com/apache/camel/blob/master/components/camel-smpp/src/main/java/org/apache/camel/component/smpp/SmppUtils.java +}