protected static Logfile theLog;
protected ArrayList streamedInput=null;
private static int instances = 0;
+ static {
+ theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Entity.Logfile"));
+ }
public AbstractEntity() {
- theLog = Logfile.getInstance(this.getClass().getName());
this.changed = false;
instances++;
- Integer i = new Integer(instances);
- System.err.println("New abstract entity instance: "+i.toString());
}
/**
public int getInstances() {
return instances;
}
+
+ protected void throwStorageObjectException (Exception e, String wo) throws StorageObjectException {
+ theLog.printError( e.toString() + " Funktion: "+ wo);
+ throw new StorageObjectException("Storage Object Exception in entity" +e.toString());
+ }
+
/**
* Gibt eine Instanz frei
*/
--- /dev/null
+package mir.media;
+
+import java.lang.*;
+
+/*
+ * MirMediaException -
+ *
+ * @version 29.1.2002
+ * @author mh
+ */
+
+public final class MirMediaException extends Exception
+{
+ String msg;
+
+ public MirMediaException(String msg) {
+ super(msg);
+ this.msg = msg;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+}
+
sqe.toString());
}
+ protected void _throwStorageObjectException (Exception e, String wo) throws StorageObjectException {
+ if (e != null) {
+ theLog.printError(e.toString()+ wo);
+ throw new StorageObjectException(wo + e.toString());
+ } else {
+ theLog.printError(wo);
+ throw new StorageObjectException(wo);
+ }
+
+ }
+
/**
* Loggt Fehlermeldung mit dem Parameter Message und wirft dannach eine StorageObjectException
* @param message Nachricht mit dem Fehler
* @exception StorageObjectException
*/
void throwStorageObjectException (String message) throws StorageObjectException {
- theLog.printError(message);
- throw new StorageObjectException(message);
+ _throwStorageObjectException(null, message);
}
}
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);
*
* @return freemarker.template.SimpleList
*/
- public SimpleList getComments() {
+ public SimpleList getComments() throws StorageObjectException {
return ((DatabaseContent)theStorageObject).getComments(this);
}
rs.close();
}
}
- catch (Exception e) {theLog.printDebugInfo("-- getImage gescheitert: "+e.toString());}
+ catch (Exception e) {throwStorageObjectException(e, "-- getImage gescheitert: ");}
finally {
try {con.setAutoCommit(true); } catch (Exception e) {;}
theStorageObject.freeConnection(con,stmt); }
pstmt.executeUpdate();
}
}
- catch (Exception e) {theLog.printDebugInfo("settimage :: setImage gescheitert: "+e.toString());}
+ catch (Exception e) {throwStorageObjectException(e, "settimage :: setImage gescheitert: ");}
finally {
try {con.setAutoCommit(true); } catch (Exception e) {;}
theStorageObject.freeConnection(con,pstmt); }
try {
theStorageObject.executeUpdate("update content set is_produced='0' where to_media="+getId());
} catch (SQLException e) {
- theLog.printError("EntityImages :: update :: failed!! "+ e.toString());
+ throwStorageObjectException(e, "EntityImages :: update :: failed!! ");
}
}
rs.close();
}
}
- catch (Exception e) {theLog.printDebugInfo("-- getIcon gescheitert: "+e.toString());}
+ catch (Exception e) {throwStorageObjectException(e, "-- getIcon gescheitert: ");}
finally {
try {con.setAutoCommit(true); } catch (Exception e) {;}
theStorageObject.freeConnection(con,stmt); }
*
* @return mir.entity.Entity
*/
- public Entity getMediaType() {
- return ((DatabaseUploadedMedia)theStorageObject).getMediaType(this);
+ public Entity getMediaType() throws StorageObjectException {
+ Entity ent = null;
+ try {
+ ent = ((DatabaseUploadedMedia)theStorageObject).getMediaType(this);
+ } catch (StorageObjectException e) {
+ throwStorageObjectException(e, "get MediaType failed -- ");
+ }
+ return ent;
}
setAdditional("special",specialHash);
} catch (Exception e) {
theLog.printError("ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString());
+ logHTML(htmlout,"ProducerTopics: problem with start special: "+currentContent.getId()+" "+e.toString());
}
}
EntityContent entContent = (EntityContent)mainModule.getById(idParam);
entContent.newswire();
}
- catch(ModuleException e) {
+ catch(Exception e) {
theLog.printError("smod content :: newswire :: could not get entityContent");
+ throw new ServletModuleException("smod content :: newswire :: could not get entityContent"+e.toString());
}
list(req, res);
}
stmt = con.createStatement();
executeUpdate(stmt,sql);
}
- catch (Exception e) {theLog.printDebugInfo("-- set unproduced failed");}
+ catch (Exception e) {_throwStorageObjectException(e, "-- set unproduced failed");}
finally { freeConnection(con,stmt);}
}
* returns the comments that belong to the article (via entityrelation)
* where db-flag is_published is true
*/
- public SimpleList getComments(EntityContent entC) {
+ public SimpleList getComments(EntityContent entC) throws StorageObjectException {
SimpleList comments=null;
try {
comments = relationComments.getManyAsSimpleList(entC,"webdb_create","is_published='1'");
}
catch (StorageObjectException e) {
- theLog.printError("DatabaseComments :: failed to get comments");
+ _throwStorageObjectException(e, "DatabaseComments :: failed to get comments");
}
return comments;
}
/**
* returns the features that belong to the article (via entityrelation)
*/
- public SimpleList getFeature(EntityContent entC) {
+ public SimpleList getFeature(EntityContent entC) throws StorageObjectException {
SimpleList feature=null;
try {
feature = relationFeature.getManyAsSimpleList(entC);
}
catch (StorageObjectException e) {
- theLog.printError("DatabaseComments :: failed to get features");
+ _throwStorageObjectException(e, "DatabaseComments :: failed to get features");
}
return feature;
}
* get all the media-files belonging to a content entity
*
*/
- public EntityList getMedia(EntityContent content) {
+ public EntityList getMedia(EntityContent content)
+ throws StorageObjectException {
EntityList returnList=null;
if (content != null) {
// get all to_topic from media_x_topic
returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,-1);
} catch (Exception e) {
theLog.printDebugInfo("-- get media failed " + e.toString());
+ throw new StorageObjectException("-- get media failed " + e.toString());
}
}
return returnList;
* get all the images belonging to a content entity
*
*/
- public EntityList getImages(EntityContent content) {
+ public EntityList getImages(EntityContent content)
+ throws StorageObjectException {
EntityList returnList=null;
if (content != null) {
// get all to_topic from media_x_topic
returnList = DatabaseImages.getInstance().selectByWhereClause(subselect,-1);
} catch (Exception e) {
theLog.printDebugInfo("-- get images failed " + e.toString());
+ throw new StorageObjectException("-- get images failed " + e.toString());
}
}
return returnList;
* get all the uploaded Media belonging to a content entity
*
*/
- public EntityList getUploadedMedia(EntityContent content) {
+ public EntityList getUploadedMedia(EntityContent content)
+ throws StorageObjectException {
EntityList returnList=null;
if (content != null) {
// get all to_topic from media_x_topic
returnList = DatabaseMedia.getInstance().selectByWhereClause(subselect,-1);
} catch (Exception e) {
theLog.printDebugInfo("-- get uploadedMedia failed " + e.toString());
+ throw new StorageObjectException("-- get uploadedMedia failed " + e.toString());
}
}
return returnList;
ResultSet rs = executeSql(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- set media failed -- delete");
+ throw new StorageObjectException("-- set media failed -- delete"+e.toString());
} finally {
freeConnection(con,stmt);
}
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- set topics failed -- insert");
+ throw new StorageObjectException("-- set topics failed -- insert "+e.toString());
} finally {
freeConnection(con,stmt);
}
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- add media failed -- insert");
+ throw new StorageObjectException("-- add media failed -- insert "
+ +e.toString());
} finally {
freeConnection(con,stmt);
}
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- set media failed -- delete");
+ throw new StorageObjectException("-- set media failed -- delete "
+ +e.toString());
} finally {
freeConnection(con,stmt);
}
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- set media failed -- insert");
+ throw new StorageObjectException("-- set media failed -- insert "
+ +e.toString());
} finally {
freeConnection(con,stmt);
}
stmt = con.createStatement();
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
- //theLog.printDebugInfo("-- delete topics failed ");
+ theLog.printDebugInfo("-- delete by contentId failed ");
+ throw new StorageObjectException("-- delete by content id failed -- delete "
+ +e.toString());
} finally {
freeConnection(con,stmt);
}
theLog.printDebugInfo("-- delete media success ");
} catch (Exception e) {
theLog.printDebugInfo("-- delete media failed ");
+ throw new StorageObjectException("-- delete by media id failed -- "
+ +e.toString());
} finally {
freeConnection(con,stmt);
}
theLog.printDebugInfo("-- delete content_x_media success ");
} catch (Exception e) {
theLog.printDebugInfo("-- delete content_x_media failed ");
+ throw new StorageObjectException("-- delete content_x_media failed -- "
+ +e.toString());
} finally {
freeConnection(con,stmt);
}
returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,-1);
}
}
- catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
+ catch (Exception e) {
+ theLog.printDebugInfo("-- get content failed");
+ throw new StorageObjectException("-- get content failed -- "
+ +e.toString());
+ }
finally { freeConnection(con,stmt);}
}
return returnList;
returnList = DatabaseContent.getInstance().selectByWhereClause(mediaSelect,"webdb_lastchange desc");
}
}
- catch (Exception e) {theLog.printDebugInfo("-- get content failed");}
+ catch (Exception e) {
+ theLog.printDebugInfo("-- get content failed");
+ throw new StorageObjectException("-- get content failed -- "
+ +e.toString());
+ }
finally { freeConnection(con,stmt);}
return returnList;
* @param EntityContent content
* @returns EntityList
*/
- public EntityList getTopics(EntityContent content) {
+ public EntityList getTopics(EntityContent content)
+ throws StorageObjectException {
EntityList returnList=null;
if (content != null) {
// get all to_topic from content_x_topic
returnList = DatabaseTopics.getInstance().selectByWhereClause(subselect,-1);
} catch (Exception e) {
theLog.printDebugInfo("-- get topics failed " + e.toString());
+ throw new StorageObjectException("-- get topics failed " + e.toString());
}
}
return returnList;
} catch (Exception e) {
theLog.printError(e.toString());
theLog.printError("-- get topicsofcontent failed");
+ throw new StorageObjectException("-- get topicsofcontent failed" + e.toString());
} finally {
freeConnection(con,stmt);
}
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- deleting topics failed");
+ throw new StorageObjectException("-- deleting topics failed" + e.toString());
} finally {
freeConnection(con,stmt);
}
int rs = executeUpdate(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- set topics failed -- insert laenge topicId" + topicId.length);
+ throw new StorageObjectException("-- set topics failed" + e.toString());
} finally {
freeConnection(con,stmt);
}
stmt = con.createStatement();
ResultSet rs = executeSql(stmt,sql);
} catch (Exception e) {
- //theLog.printDebugInfo("-- delete topics failed ");
+ theLog.printDebugInfo("-- delete topics by contentId failed ");
+ throw new StorageObjectException("-- delete topics by contentId failed" + e.toString());
} finally {
freeConnection(con,stmt);
}
ResultSet rs = executeSql(stmt,sql);
} catch (Exception e) {
theLog.printDebugInfo("-- delete topics failed ");
+ throw new StorageObjectException("-- delete topics by topicId failed" + e.toString());
} finally {
freeConnection(con,stmt);
}
returnList = DatabaseContent.getInstance().selectByWhereClause(topicSelect,-1);
}
}
- catch (Exception e) {theLog.printDebugInfo("-- get contetn failed");}
- finally { freeConnection(con,stmt);}
+ catch (Exception e) {
+ theLog.printDebugInfo("-- get content failed");
+ throw new StorageObjectException("-- get content failed" + e.toString());
+ } finally { freeConnection(con,stmt);}
}
return returnList;
}
* returns the comments that belong to the article (via entityrelation)
* where db-flag is_published is true
*/
- public Entity getMediaType(Entity ent) {
+ public Entity getMediaType(Entity ent) throws StorageObjectException {
Entity type=null;
try {
type = relationMediaType.getOne(ent);
}
catch (StorageObjectException e) {
theLog.printError("DatabaseUploadedMedia :: failed to get media_type");
+ throw new StorageObjectException("DatabaseUploadedMedia :: failed to get media_type"+ e.toString());
}
return type;
}