-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from indigo-dc/devel
Adapted to google chesktyle and SSL bugfix
- Loading branch information
Showing
31 changed files
with
2,338 additions
and
1,885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> | ||
<fileset name="all" enabled="true" check-config-name="Google Checks" local="false"> | ||
<file-match-pattern match-pattern="." include-pattern="true"/> | ||
</fileset> | ||
</fileset-config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/es/upv/i3m/grycap/file/EscapedNewLinesFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (C) GRyCAP - I3M - UPV | ||
* | ||
* <p>Licensed 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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 es.upv.i3m.grycap.file; | ||
|
||
import es.upv.i3m.grycap.im.exceptions.FileException; | ||
|
||
public final class EscapedNewLinesFile implements File { | ||
|
||
private final File file; | ||
|
||
public EscapedNewLinesFile(final File file) { | ||
this.file = file; | ||
} | ||
|
||
/** | ||
* Read the file specified and escapes all the new lines (i.e. replace all the | ||
* '\n' with '\\n'). | ||
* | ||
* @return : String with the newlines replaced | ||
* @throws FileException | ||
* : file related exception | ||
*/ | ||
@Override | ||
public String read() throws FileException { | ||
return this.file.read().replace("\n", "\\n"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (C) GRyCAP - I3M - UPV | ||
* | ||
* <p>Licensed 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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 es.upv.i3m.grycap.file; | ||
|
||
import es.upv.i3m.grycap.im.exceptions.FileException; | ||
|
||
public interface File { | ||
|
||
public String read() throws FileException; | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/main/java/es/upv/i3m/grycap/file/NoNullOrEmptyFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (C) GRyCAP - I3M - UPV | ||
* | ||
* <p>Licensed 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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 es.upv.i3m.grycap.file; | ||
|
||
import es.upv.i3m.grycap.im.exceptions.AuthorizationFileException; | ||
import es.upv.i3m.grycap.im.exceptions.FileException; | ||
import es.upv.i3m.grycap.im.lang.ImMessages; | ||
import es.upv.i3m.grycap.logger.ImJavaApiLogger; | ||
|
||
public final class NoNullOrEmptyFile implements File { | ||
|
||
private final File file; | ||
|
||
public NoNullOrEmptyFile(final File file) { | ||
this.file = file; | ||
} | ||
|
||
/** | ||
* Read the file specified and checks that the file is not null or empty. | ||
* | ||
* @return : String with the content of the file | ||
* @throws FileException | ||
* : file related exception | ||
*/ | ||
@Override | ||
public String read() throws FileException { | ||
String fileContent = this.file.read(); | ||
if (fileContent == null || fileContent.isEmpty()) { | ||
ImJavaApiLogger.severe(this.getClass(), | ||
ImMessages.EXCEPTION_AUTHORIZATION_NULL_OR_EMPTY); | ||
throw new AuthorizationFileException( | ||
ImMessages.EXCEPTION_AUTHORIZATION_NULL_OR_EMPTY); | ||
} | ||
return fileContent; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright (C) GRyCAP - I3M - UPV | ||
* | ||
* <p>Licensed 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 | ||
* | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* <p>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 es.upv.i3m.grycap.file; | ||
|
||
import es.upv.i3m.grycap.im.exceptions.FileException; | ||
import es.upv.i3m.grycap.im.lang.ImMessages; | ||
import es.upv.i3m.grycap.logger.ImJavaApiLogger; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
public final class Utf8File implements File { | ||
|
||
private String filePath; | ||
|
||
public Utf8File(final String filePath) { | ||
this.filePath = filePath; | ||
} | ||
|
||
/** | ||
* Read the file specified by the path parameter using the standard charset | ||
* UTF8. | ||
* | ||
* @return : String with the loaded file | ||
* @throws FileException | ||
* : file related exception | ||
*/ | ||
@Override | ||
public String read() throws FileException { | ||
try { | ||
return new String(Files.readAllBytes(Paths.get(this.filePath)), | ||
StandardCharsets.UTF_8); | ||
} catch (IOException ex) { | ||
ImJavaApiLogger.severe(this.getClass(), | ||
ImMessages.EXCEPTION_READING_AUTHORIZATION_FILE); | ||
throw new FileException(ImMessages.EXCEPTION_READING_AUTHORIZATION_FILE, | ||
ex); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,70 @@ | ||
/** | ||
* Copyright (C) GRyCAP - I3M - UPV | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* <p>Licensed 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 | ||
* <p>http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* <p>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 es.upv.i3m.grycap.im.api; | ||
|
||
import es.upv.i3m.grycap.im.exceptions.NoEnumFoundException; | ||
import es.upv.i3m.grycap.im.lang.ImMessages; | ||
|
||
/** | ||
* Enumerates static values related with the Infrastructure.<br> | ||
*/ | ||
public enum ImValues { | ||
|
||
START("start"), | ||
STOP("stop"), | ||
CONTMSG("contmsg"), | ||
RADL("radl"), | ||
STATE("state"), | ||
RECONFIGURE("reconfigure"); | ||
START("start"), | ||
STOP("stop"), | ||
CONTMSG("contmsg"), | ||
RADL("radl"), | ||
STATE("state"), | ||
RECONFIGURE("reconfigure"); | ||
|
||
private final String value; | ||
private final String value; | ||
|
||
ImValues(String value) { | ||
this.value = value; | ||
} | ||
ImValues(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getValue(); | ||
} | ||
@Override | ||
public String toString() { | ||
return getValue(); | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
public String getValue() { | ||
return value; | ||
} | ||
|
||
/** | ||
* Returns a ImValue if the String passed is the same as one of the states | ||
* of the enum<br> | ||
* | ||
* @param value | ||
* : string of the value to retrieve | ||
* @return A ImValue, null if not found. | ||
*/ | ||
public static ImValues getEnumFromValue(String value) { | ||
if (value != null) { | ||
for (ImValues imValue : ImValues.values()) { | ||
if (value.equalsIgnoreCase(imValue.getValue())) { | ||
return imValue; | ||
} | ||
} | ||
/** | ||
* Returns a ImValue if the String passed is the same as one of the states of | ||
* the enum<br> | ||
* | ||
* @param value | ||
* : string of the value to retrieve | ||
* @return A ImValue, null if not found. | ||
* @throws NoEnumFoundException | ||
* : No enumerator found | ||
*/ | ||
public static ImValues getEnumFromValue(String value) | ||
throws NoEnumFoundException { | ||
if (value != null) { | ||
for (ImValues imValue : ImValues.values()) { | ||
if (value.equalsIgnoreCase(imValue.getValue())) { | ||
return imValue; | ||
} | ||
return null; | ||
} | ||
} | ||
throw new NoEnumFoundException(ImMessages.EXCEPTION_NO_IM_VALUE_ENUM_FOUND); | ||
} | ||
} |
Oops, something went wrong.