use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class SearchComponent method deriveScope.
private HippoBean[] deriveScope(HstRequest request) {
SearchArea areaParam = getAreaOption(request);
final HippoBean base = RequestContextProvider.get().getSiteContentBaseBean();
final HippoBean newsAndEventsFolder = base.getBean(FOLDER_NEWS_AND_EVENTS);
final HippoBean publicationsFolder = base.getBean(FOLDER_PUBLICATIONS);
final HippoBean servicesFolder = base.getBean(FOLDER_SERVICES);
final HippoBean dataAndInformationFolder = base.getBean(FOLDER_DATAANDINFORMATION);
final HippoBean nationalIndicatorLibraryFolder = base.getBean(FOLDER_NIL);
List<HippoBean> scopeBeans = new ArrayList<HippoBean>();
switch(areaParam) {
case NEWS_AND_EVENTS:
scopeBeans.add(newsAndEventsFolder);
break;
case DATA:
scopeBeans.add(publicationsFolder);
scopeBeans.add(nationalIndicatorLibraryFolder);
scopeBeans.add(dataAndInformationFolder);
break;
case SERVICES:
scopeBeans.add(servicesFolder);
break;
case ALL:
scopeBeans.add(request.getRequestContext().getSiteContentBaseBean());
break;
default:
scopeBeans.add(request.getRequestContext().getSiteContentBaseBean());
}
return scopeBeans.toArray(new HippoBean[0]);
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class HeroComponent method doBeforeRender.
@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
super.doBeforeRender(request, response);
HeroComponentInfo componentInfo = getComponentParametersInfo(request);
final String size = componentInfo.getSize();
final String textAlignment = componentInfo.getTextAlignment();
final Boolean colourBar = componentInfo.getColourBar();
HippoBean document = getHippoBeanForPath(componentInfo.getDocument(), HippoBean.class);
String colour = componentInfo.getColour();
if ("Dark Blue".equalsIgnoreCase(colour)) {
request.setAttribute("colour", "Dark Blue Multicolour");
} else {
request.setAttribute("colour", colour);
}
request.setAttribute("document", document);
request.setAttribute("size", size);
request.setAttribute("textAlignment", textAlignment);
request.setAttribute("displayColourBar", colourBar);
request.setAttribute("stripTagsContentRewriter", stripTagsContentRewriter);
request.setAttribute("brContentRewriter", brContentRewriter);
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class ApiCatalogueComponentTest method internalLinkToDocTaggedWith.
private Internallink internalLinkToDocTaggedWith(final String... taxonomyKeys) {
final HippoBean bean = mock(HippoBean.class);
given(bean.getProperties()).willReturn(Collections.singletonMap("hippotaxonomy:keys", taxonomyKeys));
final Internallink link = mock(Internallink.class);
given(link.getLinkType()).willReturn("internal");
given(link.getLink()).willReturn(bean);
given(link.toString()).willReturn("Internallink of a doc tagged with: " + String.join(", ", taxonomyKeys));
return link;
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class CyberAlertResource method fetchAllThreatIds.
@GET
@Path("/getAllThreatIds/")
public ThreatIds fetchAllThreatIds(@Context HttpServletRequest request, @Context HttpServletResponse servletResponse) {
ThreatIds threatId = new ThreatIds();
List<ThreatIdDate> threatIdDateList = new ArrayList<ThreatIdDate>();
try {
final HstQuery query = createQuery(new DefaultRestContext(this, request), CyberAlert.class, Subtypes.INCLUDE);
query.setLimit(100);
final HstQueryResult result = query.execute();
HippoBeanIterator iterator = result.getHippoBeans();
while (iterator.hasNext()) {
CyberAlert cyberAlert = (CyberAlert) iterator.nextHippoBean();
List<Calendar> calList = new ArrayList<Calendar>();
ThreatIdDate threDate = new ThreatIdDate();
if (cyberAlert != null) {
List<HippoBean> cyberAcknowledgementList = (List<HippoBean>) cyberAlert.getCyberAcknowledgements();
for (HippoBean cyberAckn : cyberAcknowledgementList) {
if (cyberAckn instanceof CyberAcknowledgement) {
CyberAcknowledgement cybAck = (CyberAcknowledgement) cyberAckn;
calList.add(cybAck.getResponseDatetime());
}
}
threDate.setResponsedates(calList);
threDate.setThreatid(cyberAlert.getThreatId());
}
threatIdDateList.add(threDate);
}
} catch (Exception e) {
log.error("Error finding beans", e);
}
threatId.setThreatids(threatIdDateList);
return threatId;
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class SvgSection method getSvgXmlFromRepository.
public String getSvgXmlFromRepository() throws RepositoryException, IOException {
HippoBean imageBean = getLinkedBean("website:link", CorporateWebsiteImageset.class);
HippoBean imageTypeBean = imageBean.getBean(IMAGE_TYPE_ORIGINAL);
boolean hasBinaryData = ResourceUtils.hasBinaryProperty(imageTypeBean.getNode(), JcrConstants.JCR_DATA);
if (hasBinaryData) {
LOG.debug("Fetching binary data from {}.", this.getParentBean().getParentBean().getName());
InputStream svgBinaryStream = imageTypeBean.getNode().getProperty(JcrConstants.JCR_DATA).getBinary().getStream();
return IOUtils.toString(svgBinaryStream, StandardCharsets.UTF_8.name());
} else {
LOG.warn("Could not find Binary data from the SVG section of the document.");
return null;
}
}
Aggregations