<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%> <%@ page import="com.flashline.registry.openapi.entity.Asset" %> <%@ page import="com.flashline.cmee.entity.asset.AssetType" %> <%@ page import="com.flashline.cmee.openapi.query.AssetCriteria" %> <%@ page import="com.flashline.registry.openapi.service.v300.FlashlineRegistry" %> <%@ page import="com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator" %> <%@ page import="com.flashline.registry.openapi.entity.AuthToken" %> <%@ page import="java.net.URL" %> <%@ page import="com.flashline.registry.openapi.base.OpenAPIException" %> <%@ page import="java.io.IOException" %> <%@ page import="java.io.InputStream" %> <%@ page import="javax.xml.rpc.ServiceException" %> <%@ page import="java.util.Properties" %> <%@ page import="com.flashline.crypto.EncodeDecode" %> <%@ taglib uri="/skintags" prefix="skin" %> Delete Unsubmitted Asset
Delete Unsubmitted Asset  
<% cmeeSession.init(request, response, session); out.println(""); out.println("DeleteAsset"); out.println(""); if (request.getParameter("assetid") == null) { out.println("

No assetId provided

"); } else { // Process Request try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = new Properties() ; // Look for property file in WEB-INF/classes of OER app InputStream is = classLoader.getResourceAsStream("/OERSelfService.properties"); if(is == null) out.println("Unable to read OERSelfService.properties file"); else { properties.load(is); //get the property values String username = properties.getProperty("adminUsername"); String password = properties.getProperty("adminPassword"); if(password.startsWith("\"") && password.endsWith("\"")) { password = password.substring(1, password.length() - 1); System.out.println("Password is " + password); EncodeDecode enc = new EncodeDecode(); password = enc.decode(password); } is.close(); // Create a URL for the Repository URL oerRepURL = new URL( cmeeSession.buildServletLink("/") + "services/FlashlineRegistry"); FlashlineRegistry repository = new FlashlineRegistryServiceLocator().getFlashlineRegistry(oerRepURL); // connect as user with Admin rights AuthToken adminAuthToken = repository.authTokenCreate(username, password); // Read Request long assetid = Long.parseLong(request.getParameter("assetid")); // Retrieve the target Asset Asset myAsset = repository.assetRead(adminAuthToken, assetid); if(myAsset == null) { out.println("

Asset could not be located

" + assetid + " Deleted."); } else { if(myAsset.getCreatedByName().equals(cmeeSession.getUserDisplayName())) { repository.assetDelete(adminAuthToken, assetid); out.println("

Asset " + assetid + " Deleted.

"); } else out.println("

Asset will not be deleted, target Asset was not created by requesting user.

"); } } } // try catch (ServiceException eex) { out.println("ServiceException: " + String.valueOf(eex.getMessage())); } catch (OpenAPIException ex) { out.println("

DeleteAsset: Unable to locate Asset. " + "

"); out.println("

OpenAPIException: " + ex.getFaultString() + "

"); } } %>
Delete Unsubmitted Asset