Skip to content

Instantly share code, notes, and snippets.

@aakash14goplani
Last active June 26, 2017 15:29
Show Gist options
  • Save aakash14goplani/26d1d485dba5334bae437435b2be32dc to your computer and use it in GitHub Desktop.
Save aakash14goplani/26d1d485dba5334bae437435b2be32dc to your computer and use it in GitHub Desktop.
DELETE operation using Asset API

General steps to follow

  1. Get handle for AssetDataManager which will act as a gateway to interact with Assets.
  2. Create unique AssetIdInstance using AssetIdImpl and AssetId from c and cid parameters, basis on which read operation would be performed.
  3. Call delete() method of AssetDataManager which actually performs delete operation.
<%@page import="com.openmarket.xcelerate.asset.AssetIdImpl"%>
<%@page import="java.util.Arrays"%>
<%@page import="com.fatwire.system.SessionFactory"%>
<%@page import="com.fatwire.system.Session"%>
<%@ taglib prefix="cs" uri="futuretense_cs/ftcs1_0.tld"
%><%@ taglib prefix="asset" uri="futuretense_cs/asset.tld"
%><%@ taglib prefix="assetset" uri="futuretense_cs/assetset.tld"
%><%@ taglib prefix="commercecontext" uri="futuretense_cs/commercecontext.tld"
%><%@ taglib prefix="ics" uri="futuretense_cs/ics.tld"
%><%@ taglib prefix="listobject" uri="futuretense_cs/listobject.tld"
%><%@ taglib prefix="render" uri="futuretense_cs/render.tld"
%><%@ taglib prefix="searchstate" uri="futuretense_cs/searchstate.tld"
%><%@ taglib prefix="siteplan" uri="futuretense_cs/siteplan.tld"
%><%@ page import="COM.FutureTense.Interfaces.*,
                   COM.FutureTense.Util.ftMessage,
                   com.fatwire.assetapi.data.*,
                   com.fatwire.assetapi.*,
                   COM.FutureTense.Util.ftErrors"
%>
<cs:ftcs>
	<%-- Record dependencies for the SiteEntry and the CSElement --%>
	<ics:if condition='<%=ics.GetVar("seid") != null%>'>
		<ics:then>
			<render:logdep cid='<%=ics.GetVar("seid")%>' c="SiteEntry" />
		</ics:then>
	</ics:if>
	<ics:if condition='<%=ics.GetVar("eid") != null%>'>
		<ics:then>
			<render:logdep cid='<%=ics.GetVar("eid")%>' c="CSElement" />
		</ics:then>
	</ics:if>
<%
	try{
		Session sessionFactory = SessionFactory.getSession();
		AssetDataManager assetDataManager = (AssetDataManager)sessionFactory.getManager(AssetDataManager.class.getName());
		String assetType = "Article_C", assetId = "1374098706334";
        assetDataManager.delete(Arrays.<AssetId>asList( new AssetIdImpl(assetType, Long.valueOf(assetId)))); 
	}
	catch(Exception e){
		out.println("Exception Occured : " + e.getMessage() + "<br/>" + e);
	}
 %>
</cs:ftcs>

Refrence

Fatwiredev Blog - CURD
Fatwiredev Blog - API
Asset API Tutorial - Developer's Guide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment