com.sun.syndication.io.FeedException Java Examples

The following examples show how to use com.sun.syndication.io.FeedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElectricPowerUsageSummaryRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_ELECTRIC_POWER_USAGE_SUMMARY_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletRequest request, HttpServletResponse response,
		@PathVariable Long electricPowerUsageSummaryId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_ELECTRIC_POWER_USAGE_SUMMARY_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportElectricPowerUsageSummary_Root(subscriptionId,
				electricPowerUsageSummaryId, response.getOutputStream(),
				new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #2
Source File: ElectricPowerQualitySummaryRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ELECTRIC_POWER_QUALITY_SUMMARY_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletResponse response,
		@PathVariable Long subscriptionId, @PathVariable Long usagePointId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ELECTRIC_POWER_QUALITY_SUMMARY_COLLECTION, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);

	Long retailCustomerId = subscriptionService.findRetailCustomerId(
			subscriptionId, usagePointId);

	exportService.exportElectricPowerQualitySummarys(subscriptionId,
			retailCustomerId, usagePointId, response.getOutputStream(),
			new ExportFilter(params));
}
 
Example #3
Source File: ReadingTypeRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_READING_TYPE_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletResponse response,
		@PathVariable Long readingTypeId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_READING_TYPE_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	exportService.exportReadingType(readingTypeId,
			response.getOutputStream(), new ExportFilter(params));
}
 
Example #4
Source File: TimeConfigurationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_TIME_CONFIGURATION_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletResponse response,
		@PathVariable Long timeConfigurationId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_TIME_CONFIGURATION_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportTimeConfiguration(timeConfigurationId,
				response.getOutputStream(), new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #5
Source File: IntervalBlockRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_INTERVAL_BLOCK_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletRequest request, HttpServletResponse response,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_INTERVAL_BLOCK_COLLECTION, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	exportService.exportIntervalBlocks_Root(subscriptionId,
			response.getOutputStream(), new ExportFilter(params));
}
 
Example #6
Source File: ServiceStatusRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_SERVICE_STATUS, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletRequest request, HttpServletResponse response,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	DateTimeType updated = DateConverter.toDateTimeType(new Date());
	String temp = updated.getValue().toXMLFormat();
	String uuid = UUID.randomUUID().toString();

	response.getOutputStream().println(
			"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	response.getOutputStream()
			.println(
					"<ServiceStatus xmlns=\"http://naesb.org/espi\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://naesb.org/espi espiDerived.xsd\">");
	response.getOutputStream().println(
			"  <currentStatus>" + getApplicationStatus(request)
					+ "</currentStatus>\n</ServiceStatus>");

}
 
Example #7
Source File: SyndicationServlet.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get feed documents
 */
private SyndFeed getFeedDocuments(List<DashboardDocumentResult> result) throws FeedException, SQLException,
		IOException {
	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	SyndFeed feed = new SyndFeedImpl();

	for (DashboardDocumentResult item : result) {
		SyndEntry entry = new SyndEntryImpl();
		entry.setTitle(item.getDocument().getPath());
		entry.setAuthor(item.getDocument().getActualVersion().getAuthor());
		entry.setPublishedDate(item.getDate().getTime());
		entry.setLink(Config.APPLICATION_URL + "?docPath="
				+ URLEncoder.encode(item.getDocument().getPath(), "UTF-8"));
		entries.add(entry);
	}

	feed.setEntries(entries);
	return feed;
}
 
Example #8
Source File: SyndicationServlet.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get feed folders
 */
private SyndFeed getFeedFolders(List<DashboardFolderResult> result) throws FeedException, SQLException, IOException {
	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	SyndFeed feed = new SyndFeedImpl();

	for (DashboardFolderResult item : result) {
		SyndEntry entry = new SyndEntryImpl();
		entry.setTitle(item.getFolder().getPath());
		entry.setAuthor(item.getFolder().getAuthor());
		entry.setPublishedDate(item.getDate().getTime());
		entry.setLink(Config.APPLICATION_URL + "?fldPath=" + URLEncoder.encode(item.getFolder().getPath(), "UTF-8"));
		entries.add(entry);
	}

	feed.setEntries(entries);
	return feed;
}
 
Example #9
Source File: SyndicationServlet.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get feed mails
 */
private SyndFeed getFeedMails(List<DashboardMailResult> result) throws FeedException, SQLException, IOException {
	List<SyndEntry> entries = new ArrayList<SyndEntry>();
	SyndFeed feed = new SyndFeedImpl();

	for (DashboardMailResult item : result) {
		SyndEntry entry = new SyndEntryImpl();
		entry.setTitle(item.getMail().getPath());
		entry.setAuthor(item.getMail().getFrom());
		entry.setPublishedDate(item.getDate().getTime());
		entry.setLink(Config.APPLICATION_URL + "?docPath=" + URLEncoder.encode(item.getMail().getPath(), "UTF-8"));
		entries.add(entry);
	}

	feed.setEntries(entries);
	return feed;
}
 
Example #10
Source File: ApplicationInformationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_APPLICATION_INFORMATION_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletResponse response,
		@PathVariable Long applicationInformationId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_APPLICATION_INFORMATION_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportApplicationInformation(
				applicationInformationId, response.getOutputStream(),
				new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}

}
 
Example #11
Source File: ElectricPowerQualitySummaryRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ELECTRIC_POWER_QUALITY_SUMMARY_MEMBER, method = RequestMethod.DELETE)
public void delete(HttpServletResponse response,
		@PathVariable Long subscriptionId, @PathVariable Long usagePointId,
		@PathVariable Long electricPowerQualitySummaryId,
		@RequestParam Map<String, String> params, InputStream stream)
		throws IOException, FeedException {

	try {
		Long retailCustomerId = subscriptionService.findRetailCustomerId(
				subscriptionId, usagePointId);

		resourceService.deleteByXPathId(retailCustomerId, usagePointId,
				electricPowerQualitySummaryId,
				ElectricPowerQualitySummary.class);

	} catch (Exception e) {

		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #12
Source File: IntervalBlockRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_INTERVAL_BLOCK_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletRequest request, HttpServletResponse response,
		@PathVariable Long intervalBlockId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_INTERVAL_BLOCK_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportIntervalBlock_Root(subscriptionId,
				intervalBlockId, response.getOutputStream(),
				new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #13
Source File: ElectricPowerUsageSummaryRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ELECTRIC_POWER_USAGE_SUMMARY_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletResponse response,
		@PathVariable Long subscriptionId, @PathVariable Long usagePointId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ELECTRIC_POWER_USAGE_SUMMARY_COLLECTION, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);

	Long retailCustomerId = subscriptionService.findRetailCustomerId(
			subscriptionId, usagePointId);

	exportService.exportElectricPowerUsageSummarys(subscriptionId,
			retailCustomerId, usagePointId, response.getOutputStream(),
			new ExportFilter(params));
}
 
Example #14
Source File: MeterReadingRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_METER_READING_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletRequest request, HttpServletResponse response,
		@PathVariable Long meterReadingId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_METER_READING_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportMeterReading_Root(subscriptionId,
				meterReadingId, response.getOutputStream(),
				new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #15
Source File: ElectricPowerUsageSummaryRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_ELECTRIC_POWER_USAGE_SUMMARY_MEMBER, method = RequestMethod.PUT, consumes = "application/atom+xml", produces = "application/atom+xml")
@ResponseBody
public void update(HttpServletResponse response,
		@PathVariable Long electricPowerUsageSummaryId,
		@RequestParam Map<String, String> params, InputStream stream)
		throws IOException, FeedException {

	ElectricPowerUsageSummary electricPowerUsageSummary = electricPowerUsageSummaryService
			.findById(electricPowerUsageSummaryId);

	if (electricPowerUsageSummary != null) {
		try {
			ElectricPowerUsageSummary newElectricPowerUsageSummary = electricPowerUsageSummaryService
					.importResource(stream);
			electricPowerUsageSummary.merge(newElectricPowerUsageSummary);
		} catch (Exception e) {
			response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
		}
	}
}
 
Example #16
Source File: MeterReadingRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.METER_READING_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletResponse response,
		@PathVariable Long subscriptionId, @PathVariable Long usagePointId,
		@PathVariable Long meterReadingId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.METER_READING_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		Long retailCustomerId = subscriptionService.findRetailCustomerId(
				subscriptionId, usagePointId);
		exportService.exportMeterReading(subscriptionId, retailCustomerId,
				usagePointId, meterReadingId, response.getOutputStream(),
				new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #17
Source File: ApplicationInformationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_APPLICATION_INFORMATION_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletResponse response,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_APPLICATION_INFORMATION_COLLECTION, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	exportService.exportApplicationInformations(response.getOutputStream(),
			new ExportFilter(params));
}
 
Example #18
Source File: ElectricPowerUsageSummaryRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_ELECTRIC_POWER_USAGE_SUMMARY_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletRequest request, HttpServletResponse response,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_ELECTRIC_POWER_USAGE_SUMMARY_COLLECTION, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	exportService.exportElectricPowerUsageSummarys_Root(subscriptionId,
			response.getOutputStream(), new ExportFilter(params));
}
 
Example #19
Source File: IntervalBlockRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.INTERVAL_BLOCK_MEMBER, method = RequestMethod.DELETE)
public void delete(HttpServletResponse response,
		@PathVariable Long subscriptionId, @PathVariable Long usagePointId,
		@PathVariable Long meterReadingId,
		@PathVariable Long intervalBlockId,
		@RequestParam Map<String, String> params, InputStream stream)
		throws IOException, FeedException {
	try {
		Long retailCustomerId = subscriptionService.findRetailCustomerId(
				subscriptionId, usagePointId);

		resourceService.deleteByXPathId(retailCustomerId, usagePointId,
				meterReadingId, intervalBlockId, IntervalBlock.class);

	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #20
Source File: FragmentMarshallerTests.java    From OpenESPI-Common-java with Apache License 2.0 6 votes vote down vote up
private String newXML(IdentifiedObject resource)
		throws DatatypeConfigurationException, FeedException {
	ByteArrayOutputStream os = new ByteArrayOutputStream();
	EntryType entry = new EntryType();
	entry.getLinks().add(new LinkType(LinkType.SELF, "self"));
	entry.setTitle("entry");
	entry.setId("id");
	entry.setPublished(new DateTimeType());
	entry.setUpdated(new DateTimeType());
	ContentType content = new ContentType();
	content.setResources(Lists.<IdentifiedObject> newArrayList(resource));
	entry.setContent(content);

	fragmentMarshaller.marshal(entry, new StreamResult(os));

	return os.toString();
}
 
Example #21
Source File: UsagePointRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_USAGE_POINT_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletRequest request, HttpServletResponse response,
		@PathVariable Long usagePointId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_USAGE_POINT_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportUsagePoint_Root(subscriptionId, usagePointId,
				response.getOutputStream(), new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #22
Source File: IntervalBlockRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_INTERVAL_BLOCK_MEMBER, method = RequestMethod.PUT, consumes = "application/atom+xml", produces = "application/atom+xml")
@ResponseBody
public void update(HttpServletResponse response,
		@PathVariable Long intervalBlockId,
		@RequestParam Map<String, String> params, InputStream stream)
		throws IOException, FeedException {

	IntervalBlock intervalBlock = intervalBlockService
			.findById(intervalBlockId);

	if (intervalBlock != null) {
		try {
			intervalBlock
					.merge(intervalBlockService.importResource(stream));
			intervalBlockService.persist(intervalBlock);
		} catch (Exception e) {
			response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
		}
	}
}
 
Example #23
Source File: UsagePointRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_USAGE_POINT_COLLECTION, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void index(HttpServletRequest request, HttpServletResponse response,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_USAGE_POINT_COLLECTION, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	Long subscriptionId = getSubscriptionId(request);

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {

		exportService.exportUsagePoints_Root(subscriptionId,
				response.getOutputStream(), new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}

}
 
Example #24
Source File: EspiEntry.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public EspiEntry(T espiObject) throws FeedException {
	this.espiObject = espiObject;
	this.setTitle(espiObject.getDescription());
	this.setId(espiObject.getMRID());
	this.setPublished(espiObject.getPublished().getTime());
	this.setUpdated(espiObject.getUpdated().getTime());

	selfLink.setRel("self");
	selfLink.setHref(getSelfHref());
	upLink.setRel("up");
	upLink.setHref(getUpHref());

	getOtherLinks().add(selfLink);
	getOtherLinks().add(upLink);

	buildRelatedLinks();

	Content content = new Content();
	content.setValue(EspiMarshaller.marshal(espiObject));
	this.getContents().add(content);
}
 
Example #25
Source File: AuthorizationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.AUTHORIZATION_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletResponse response,
		@PathVariable Long retailCustomerId,
		@PathVariable Long authorizationId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.AUTHORIZATION_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportAuthorization(retailCustomerId,
				authorizationId, response.getOutputStream(),
				new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #26
Source File: AuthorizationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_AUTHORIZATION_MEMBER, method = RequestMethod.DELETE)
public void delete(HttpServletResponse response,
		@PathVariable Long authorizationId,
		@RequestParam Map<String, String> params, InputStream stream)
		throws IOException, FeedException {
	try {
		Authorization authorization = resourceService.findById(
				authorizationId, Authorization.class);
		String accessToken = authorization.getAccessToken();

		authorizationService.delete(authorization);
		tokenService.revokeToken(accessToken);
		authorizationService.delete(authorization);

	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #27
Source File: AuthorizationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_AUTHORIZATION_MEMBER, method = RequestMethod.PUT, consumes = "application/atom+xml", produces = "application/atom+xml")
@ResponseBody
public void update(HttpServletResponse response,
		@PathVariable Long authorizationId,
		@RequestParam Map<String, String> params, InputStream stream)
		throws IOException, FeedException {
	Authorization authorization = authorizationService
			.findById(authorizationId);

	if (authorization != null) {
		try {

			Authorization newAuthorization = authorizationService
					.importResource(stream);
			authorization.merge(newAuthorization);
		} catch (Exception e) {
			response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
		}
	}
}
 
Example #28
Source File: AuthorizationRESTController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.ROOT_AUTHORIZATION_MEMBER, method = RequestMethod.GET, produces = "application/atom+xml")
@ResponseBody
public void show(HttpServletResponse response,
		@PathVariable Long authorizationId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	// Verify request contains valid query parameters
	if(!VerifyURLParams.verifyEntries(Routes.ROOT_AUTHORIZATION_MEMBER, params)) {

		response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Request contains invalid query parameter values!");
		return;
	}

	response.setContentType(MediaType.APPLICATION_ATOM_XML_VALUE);
	try {
		exportService.exportAuthorization(authorizationId,
				response.getOutputStream(), new ExportFilter(params));
	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #29
Source File: CustomerDownloadMyDataController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.RETAIL_CUSTOMER_DOWNLOAD_MY_DATA_COLLECTION, method = RequestMethod.GET)
public void downloadMyDataCollection(HttpServletResponse response,
		@PathVariable Long retailCustomerId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {

	response.setContentType(MediaType.TEXT_HTML_VALUE);
	response.addHeader("Content-Disposition",
			"attachment; filename=GreenButtonDownload.xml");
	try {
		// TODO -- need authorization hook
		exportService.exportUsagePointsFull(0L, retailCustomerId,
				response.getOutputStream(), new ExportFilter(params));

	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}
 
Example #30
Source File: CustomerDownloadMyDataController.java    From OpenESPI-DataCustodian-java with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = Routes.RETAIL_CUSTOMER_DOWNLOAD_MY_DATA, method = RequestMethod.GET)
public void downloadMyData(HttpServletResponse response,
		@PathVariable Long retailCustomerId,
		@PathVariable Long usagePointId,
		@RequestParam Map<String, String> params) throws IOException,
		FeedException {
	response.setContentType(MediaType.TEXT_HTML_VALUE);
	response.addHeader("Content-Disposition",
			"attachment; filename=GreenButtonDownload.xml");
	try {

		exportService.exportUsagePointFull(0L, retailCustomerId,
				usagePointId, response.getOutputStream(), new ExportFilter(
						params));

	} catch (Exception e) {
		response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
	}
}