*/
-public class EntityContent extends AbstractEntity implements Entity
+public class EntityContent extends Entity
{
private static int instances;
stmt = con.createStatement();
theStorageObject.executeUpdate(stmt,sql);
} catch (StorageObjectException e) {
- theLog.printDebugInfo(e.toString() + "\n -- set produced failed");
+ throwStorageObjectException(e, "\n -- set produced failed");
} catch (SQLException e) {
- theLog.printDebugInfo(e.toString() + "\n -- set produced failed");
+ throwStorageObjectException(e, "\n -- set produced failed");
} finally {
theStorageObject.freeConnection(con,stmt);
}
* make openposting to newswire
*/
- public void newswire()
+ public void newswire() throws StorageObjectException
{
String sql = "update content set to_article_type='1', is_produced='0' where id='" + getId()+"'";
try {
theStorageObject.executeUpdate(sql);
} catch (StorageObjectException e) {
- theLog.printError(e.toString() + "newswire failed");
+ throwStorageObjectException(e, "\n -- newswire failed");
} catch (SQLException e) {
- theLog.printError(e.toString() + "newswire failed");
+ throwStorageObjectException(e, "\n -- newswire failed");
}
}
/**
* dettach from media
*/
-
public void dettach(String cid,String mid) throws StorageObjectException
{
if (mid!=null){
try{
DatabaseContentToMedia.getInstance().delete(cid,mid);
} catch (Exception e){
- theLog.printError("failed to get instance");
+ throwStorageObjectException(e, "\n -- failed to get instance");
}
//set Content to unproduced
setProduced(false);
try{
DatabaseContentToMedia.getInstance().addMedia(getId(),mid);
} catch(StorageObjectException e){
- theLog.printError("attach: could not get the instance");
+ throwStorageObjectException(e, "attach: could not get the instance");
}
//set Content to unproduced
setProduced(false);
}
/**
- * overridden method getValues to include formatted date into every
+ * overridden method getValue to include formatted date into every
* entityContent
*/
- public HashMap getValues() {
- HashMap returnHash = super.getValues();
- String date=null;
-
- if ((date=(String)returnHash.get("date"))!=null)
- returnHash.put("date_formatted", StringUtil.webdbDate2readableDate(date));
- if ((date=(String)returnHash.get("webdb_create"))!=null)
- returnHash.put("webdb_create_formatted", StringUtil.dateToReadableDate(date));
- if ((date=(String)returnHash.get("webdb_lastchange"))!=null)
- returnHash.put("webdb_lastchange_formatted", StringUtil.dateToReadableDate(date));
- return returnHash;
+ public String getValue(String field)
+ {
+ if (field!=null && field.equals("date_formatted"))
+ {
+ if (hasValueForField("date"))
+ return StringUtil.webdbDate2readableDate(getValue("date"));
+ else return null;
+ }
+ else
+ return super.getValue(field);
}
/**
*
* @return freemarker.template.SimpleList
*/
- public SimpleList getComments() {
+ public SimpleList getComments() throws StorageObjectException {
return ((DatabaseContent)theStorageObject).getComments(this);
}