Tutorials > Content management > Create a content-managed resource > Integrate the new resource
Create NavCatExtendedCatalogUpdateControllerCmdImpl controller command
Procedure
- In the Enterprise Explorer view, navigate to Other Projects > WebSphereCommerceServerExtensionsLogic.
- Right-click src and select New > Class.
- In the Package field, type com.ibm.commerce.tools.catalog.commands.
- In the Name field, type NavCatExtendedCatalogUpdateControllerCmdImpl.
- Click the Browse button next to the Superclass field.
- In the Superclass Selection window, type NavCatCatalogUpdateControllerCmdImpl in the Choose a type field.
- In the Matching types box, select NavCatCatalogUpdateControllerCmdImpl.
- Click OK.
- Click the Add button next to the Interface box.
- In the Implemented Interfaces Selection window, type NavCatCatalogUpdateControllerCmd in the Choose interfaces field.
- Click OK.
- Clear the check box for Inherited abstract methods.
- Click Finish.
- Add the following imports into the class:
import java.sql.Timestamp; import java.util.Calendar; import java.util.Hashtable; import java.util.Vector; import com.ibm.commerce.command.CommandFactory; import com.ibm.commerce.tools.common.ECToolsConstants; import com.mycompany.catalog.commands.UpdateExtendedCatalogDescCmd;
- Add the following code into the class:
/* * The catalog ID of the catalog being managed in the accelerator. */ private String m_strCatalogId = null; /* * A collection of languages being managed in the accelerator. */ private Vector m_vLanguages = new Vector(); /** * Executes the command. */ public void performExecute() throws com.ibm.commerce.exception.ECException { final String METHODNAME = "performExecute"; if(ECTrace.isTraceEnabled()) { ECTrace.entry(ECTraceIdentifiers.COMPONENT_CATALOGTOOL, CLASSNAME, METHODNAME); } // Execute the original command logic. super.performExecute(); // Get the request properties from the parent controller command Hashtable xmlObject = (Hashtable) ((Hashtable) ((Vector) requestProperties .get(ECToolsConstants.EC_XMLOBJECT)).firstElement()).get("XML"); m_strCatalogId = (String) xmlObject.get("catalogId"); java.lang.Object obj = xmlObject.get("languages"); if (obj instanceof Hashtable) { m_vLanguages.addElement(obj); } else if (obj instanceof Vector) { m_vLanguages = (Vector) obj; } for (int i = 0; i < m_vLanguages.size(); i++) { Hashtable hLanguage = (Hashtable) m_vLanguages.elementAt(i); String frontImage = (String) hLanguage.get("frontimage"); String backImage = (String) hLanguage.get("backimage"); String topImage = (String) hLanguage.get("topimage"); String sideImage = (String) hLanguage.get("sideimage"); if((frontImage!=null && frontImage.trim().length()>0) || (backImage!=null && backImage.trim().length()>0) || (topImage!=null && topImage.trim().length()>0) || (sideImage!=null && sideImage.trim().length()>0)) { UpdateExtendedCatalogDescCmd updateExtendedCatalogDescCmd = null; updateExtendedCatalogDescCmd = (UpdateExtendedCatalogDescCmd) CommandFactory .createCommand(UpdateExtendedCatalogDescCmd.CLASSNAME, getStoreId()); Timestamp ts = new Timestamp(Calendar.getInstance().getTime() .getTime()); updateExtendedCatalogDescCmd.setCatalogId(new Long(m_strCatalogId)); updateExtendedCatalogDescCmd.setLanguageId(new Integer(hLanguage .get("languageId").toString())); updateExtendedCatalogDescCmd.setLastModified(ts); if (hLanguage.containsKey("frontimage")) { updateExtendedCatalogDescCmd.setFrontImg(frontImage); } if (hLanguage.containsKey("backimage")) { updateExtendedCatalogDescCmd.setBackImg(backImage); } if (hLanguage.containsKey("sideimage")) { updateExtendedCatalogDescCmd.setSideImg(topImage); } if (hLanguage.containsKey("topimage")) { updateExtendedCatalogDescCmd.setTopImg(sideImage); } updateExtendedCatalogDescCmd.setCommandContext(getCommandContext()); updateExtendedCatalogDescCmd.execute(); } } if(ECTrace.isTraceEnabled()) { ECTrace.exit(ECTraceIdentifiers.COMPONENT_CATALOGTOOL, CLASSNAME, METHODNAME); } }
- Save and close the file.