-
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.
- Loading branch information
Showing
31 changed files
with
393 additions
and
55 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
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
6 changes: 6 additions & 0 deletions
6
Backend/ai-labar/src/main/java/com/capgemini/ailabar/AiLabarApplication.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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
package com.capgemini.ailabar; | ||
|
||
import com.capgemini.ailabar.commons.utils.AccessPom; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
|
||
@SpringBootApplication | ||
@EnableScheduling | ||
public class AiLabarApplication { | ||
private static final Logger logger = LogManager.getLogger(AiLabarApplication.class); | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(AiLabarApplication.class, args); | ||
logger.info(AccessPom.showAppVersion()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Backend/ai-labar/src/main/java/com/capgemini/ailabar/commons/utils/AccessPom.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,37 @@ | ||
package com.capgemini.ailabar.commons.utils; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.w3c.dom.Document; | ||
import org.w3c.dom.Element; | ||
import org.w3c.dom.Node; | ||
import org.w3c.dom.NodeList; | ||
|
||
import javax.xml.parsers.DocumentBuilder; | ||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import java.io.File; | ||
|
||
@Component | ||
public final class AccessPom { | ||
private AccessPom() {} | ||
public static String showAppVersion() { | ||
try { | ||
File pomFile = new File("pom.xml"); | ||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); | ||
|
||
Document document = documentBuilder.parse(pomFile); | ||
Element rootElement = document.getDocumentElement(); | ||
NodeList versionNodeList = rootElement.getElementsByTagName("version"); | ||
|
||
if (versionNodeList.getLength() > 0) { | ||
Node versionNode = versionNodeList.item(0); | ||
return "AiLabar " + versionNode.getTextContent(); | ||
} else { | ||
return "No se encontró la versión en el pom.xml"; | ||
} | ||
|
||
} catch (Exception e) { | ||
return e.getMessage(); | ||
} | ||
} | ||
} |
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
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
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
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
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
24 changes: 24 additions & 0 deletions
24
...rc/main/java/com/capgemini/ailabar/users/application/usecases/AdminAccessUseCaseImpl.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,24 @@ | ||
package com.capgemini.ailabar.users.application.usecases; | ||
|
||
import com.capgemini.ailabar.users.domain.exceptions.AdminAccessException; | ||
import com.capgemini.ailabar.users.domain.models.UsersModel; | ||
import com.capgemini.ailabar.users.domain.ports.in.AdminAccessUseCase; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class AdminAccessUseCaseImpl implements AdminAccessUseCase { | ||
@Value("${admin.access}") | ||
private String adminPass; | ||
|
||
@Override | ||
public void adminAccess(UsersModel usersModel) { | ||
if(usersModel.getPassword().isBlank()) { | ||
throw new AdminAccessException("Password is required"); | ||
} | ||
|
||
if (Boolean.FALSE.equals(usersModel.getPassword().equals(adminPass))) { | ||
throw new AdminAccessException("Wrong Password"); | ||
} | ||
} | ||
} |
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
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
7 changes: 7 additions & 0 deletions
7
...bar/src/main/java/com/capgemini/ailabar/users/domain/exceptions/AdminAccessException.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,7 @@ | ||
package com.capgemini.ailabar.users.domain.exceptions; | ||
|
||
public class AdminAccessException extends RuntimeException { | ||
public AdminAccessException(String message) { | ||
super(message); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...i-labar/src/main/java/com/capgemini/ailabar/users/domain/ports/in/AdminAccessUseCase.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,7 @@ | ||
package com.capgemini.ailabar.users.domain.ports.in; | ||
|
||
import com.capgemini.ailabar.users.domain.models.UsersModel; | ||
|
||
public interface AdminAccessUseCase { | ||
void adminAccess(UsersModel usersModel); | ||
} |
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
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
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
Oops, something went wrong.