-
-
Notifications
You must be signed in to change notification settings - Fork 57
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 #20 from jhipster/master
Update from upstream
- Loading branch information
Showing
18 changed files
with
453 additions
and
12 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
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
31 changes: 31 additions & 0 deletions
31
generators/server/templates/quarkus/src/main/java/package/config/JHipsterInfo.java.ejs
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,31 @@ | ||
<%# | ||
Copyright 2013-2020 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
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 | ||
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 <%=packageName%>.config; | ||
|
||
import io.quarkus.arc.config.ConfigProperties; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
|
||
@ConfigProperties(prefix = "jhipster.info") | ||
public interface JHipsterInfo { | ||
|
||
@ConfigProperty(name = "swagger.enable", defaultValue = "true") | ||
Boolean isEnable(); | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
generators/server/templates/quarkus/src/main/java/package/config/LocalDateProvider.java.ejs
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 2013-2020 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
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 | ||
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 <%=packageName%>.config; | ||
|
||
import javax.ws.rs.ext.ParamConverter; | ||
import javax.ws.rs.ext.ParamConverterProvider; | ||
import javax.ws.rs.ext.Provider; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
@Provider | ||
public class LocalDateProvider implements ParamConverterProvider { | ||
|
||
public static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(Constants.LOCAL_DATE_FORMAT); | ||
|
||
@Override | ||
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) { | ||
if(!rawType.equals(LocalDate.class)){ | ||
return null; | ||
} | ||
return new ParamConverter<>() { | ||
@Override | ||
public T fromString(String value) { | ||
return (T) LocalDate.parse(value, dateFormatter); | ||
} | ||
|
||
@Override | ||
public String toString(T value) { | ||
return ((LocalDate) value).format(dateFormatter); | ||
} | ||
}; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...ors/server/templates/quarkus/src/main/java/package/service/ManagementInfoService.java.ejs
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 2013-2020 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
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 | ||
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 <%=packageName%>.service; | ||
|
||
import io.quarkus.runtime.configuration.ProfileManager; | ||
import <%=packageName%>.config.JHipsterInfo; | ||
import <%=packageName%>.service.dto.ManagementInfoDTO; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
/** | ||
* Provides information for management/info resource | ||
*/ | ||
@ApplicationScoped | ||
public class ManagementInfoService { | ||
|
||
private final JHipsterInfo JHipsterInfo; | ||
|
||
@Inject | ||
public ManagementInfoService(JHipsterInfo JHipsterInfo) { | ||
this.JHipsterInfo = JHipsterInfo; | ||
} | ||
|
||
public ManagementInfoDTO getManagementInfo(){ | ||
var info = new ManagementInfoDTO(); | ||
if(JHipsterInfo.isEnable()){ | ||
info.activeProfiles.add("swagger"); | ||
} | ||
info.activeProfiles.add(ProfileManager.getActiveProfile()); | ||
info.displayRibbonOnProfiles = ProfileManager.getActiveProfile(); | ||
return info; | ||
} | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
...ors/server/templates/quarkus/src/main/java/package/service/dto/ManagementInfoDTO.java.ejs
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,38 @@ | ||
<%# | ||
Copyright 2013-2020 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
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 | ||
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 <%=packageName%>.service.dto; | ||
|
||
import io.quarkus.runtime.annotations.RegisterForReflection; | ||
|
||
import javax.json.bind.annotation.JsonbProperty; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* DTO to emulate /management/info response | ||
*/ | ||
@RegisterForReflection | ||
public class ManagementInfoDTO { | ||
|
||
public List<String> activeProfiles = new ArrayList<>(); | ||
|
||
@JsonbProperty("display-ribbon-on-profiles") | ||
public String displayRibbonOnProfiles; | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...s/server/templates/quarkus/src/main/java/package/web/rest/ManagementInfoResource.java.ejs
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,49 @@ | ||
<%# | ||
Copyright 2013-2020 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
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 | ||
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 <%=packageName%>.web.rest; | ||
|
||
import <%=packageName%>.service.ManagementInfoService; | ||
|
||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
@Path("/management/info") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@RequestScoped | ||
public class ManagementInfoResource { | ||
|
||
private final ManagementInfoService managementInfoService; | ||
|
||
@Inject | ||
public ManagementInfoResource(ManagementInfoService managementInfoService) { | ||
this.managementInfoService = managementInfoService; | ||
} | ||
|
||
@GET | ||
public Response info(){ | ||
return Response.ok(managementInfoService.getManagementInfo()).build(); | ||
} | ||
} |
Oops, something went wrong.