@ -6,6 +6,8 @@
package ru.ulstu.extractor.heuristic.controller ;
import org.eclipse.jgit.api.errors.GitAPIException ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
import org.springframework.web.bind.annotation.GetMapping ;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.RestController ;
@ -13,13 +15,16 @@ import ru.ulstu.extractor.heuristic.model.BusinessLogicUnit;
import ru.ulstu.extractor.heuristic.model.EntityUnit ;
import ru.ulstu.extractor.heuristic.model.ResourceUnit ;
import ru.ulstu.extractor.service.GitRepositoryService ;
import ru.ulstu.extractor.util.HttpUtils ;
import javax.servlet.http.HttpServletRequest ;
import java.io.IOException ;
import java.util.List ;
@RestController
@RequestMapping ( "StructuralUnitController" )
public class StructuralUnitController {
private final static Logger LOG = LoggerFactory . getLogger ( StructuralUnitController . class ) ;
private final GitRepositoryService gitRepositoryService ;
public StructuralUnitController ( GitRepositoryService gitRepositoryService ) {
@ -27,17 +32,26 @@ public class StructuralUnitController {
}
@GetMapping ( "get-entities" )
public List < EntityUnit > getEntities ( String repositoryUrl , String branchName ) throws IOException , GitAPIException {
public List < EntityUnit > getEntities ( String repositoryUrl ,
String branchName ,
HttpServletRequest request ) throws IOException , GitAPIException {
LOG . debug ( "Get entities {} {}. User ip {}" , repositoryUrl , branchName , HttpUtils . getUserIp ( request ) ) ;
return gitRepositoryService . getEntities ( repositoryUrl , branchName ) ;
}
@GetMapping ( "get-business-logic" )
public List < BusinessLogicUnit > getBusinessLogic ( String repositoryUrl , String branchName ) throws IOException , GitAPIException {
public List < BusinessLogicUnit > getBusinessLogic ( String repositoryUrl ,
String branchName ,
HttpServletRequest request ) throws IOException , GitAPIException {
LOG . debug ( "Get business logic {} {}. User ip {}" , repositoryUrl , branchName , HttpUtils . getUserIp ( request ) ) ;
return gitRepositoryService . getBusinessLogic ( repositoryUrl , branchName ) ;
}
@GetMapping ( "get-resources" )
public List < ResourceUnit > getResource ( String repositoryUrl , String branchName ) throws IOException , GitAPIException {
public List < ResourceUnit > getResource ( String repositoryUrl ,
String branchName ,
HttpServletRequest request ) throws IOException , GitAPIException {
LOG . debug ( "Get resources {} {}. User ip {}" , repositoryUrl , branchName , HttpUtils . getUserIp ( request ) ) ;
return gitRepositoryService . getResource ( repositoryUrl , branchName ) ;
}
}