--- /dev/null
+/*
+ * ArticleTypeService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.ArticleType;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * ArticleTypeService
+ * @author idefix
+ * @version $Id: ArticleTypeService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class ArticleTypeService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public ArticleTypeService(SessionFactory factory) {
+ super(ArticleType.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * AudioService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Audio;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * AudioService
+ * @author idefix
+ * @version $Id: AudioService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class AudioService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public AudioService(SessionFactory factory) {
+ super(Audio.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * BreakingService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.BreakingNewsItem;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * BreakingService
+ * @author idefix
+ * @version $Id: BreakingService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class BreakingService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public BreakingService(SessionFactory factory) {
+ super(BreakingNewsItem.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * CommentService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Comment;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * CommentService
+ * @author idefix
+ * @version $Id: CommentService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class CommentService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public CommentService(SessionFactory factory) {
+ super(Comment.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * CommentStatusService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.CommentStatus;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * CommentStatusService
+ * @author idefix
+ * @version $Id: CommentStatusService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class CommentStatusService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public CommentStatusService(SessionFactory factory) {
+ super(CommentStatus.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * ContentService.java
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mir.core.service.storage;
+
+import mir.core.model.Content;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * ContentService
+ * @author idefix
+ * @version $Id: ContentService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class ContentService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public ContentService(SessionFactory factory) {
+ super(Content.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * ImageService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Image;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * ImageService
+ * @author idefix
+ * @version $Id: ImageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class ImageService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public ImageService(SessionFactory factory) {
+ super(Image.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * LanguageService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Language;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * LanguageService
+ * @author idefix
+ * @version $Id: LanguageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class LanguageService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public LanguageService(SessionFactory factory) {
+ super(Language.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * MediaFolderService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.MediaFolder;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * MediaFolderService
+ * @author idefix
+ * @version $Id: MediaFolderService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class MediaFolderService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public MediaFolderService(SessionFactory factory) {
+ super(MediaFolder.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * MessageService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Message;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * MessageService
+ * @author idefix
+ * @version $Id: MessageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class MessageService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public MessageService(SessionFactory factory) {
+ super(Message.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * OtherMediaService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.OtherMedia;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * OtherMediaService
+ * @author idefix
+ * @version $Id: OtherMediaService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class OtherMediaService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public OtherMediaService(SessionFactory factory) {
+ super(OtherMedia.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * StorageService.java
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+
+package mir.core.service.storage;
+
+import java.util.List;
+
+import net.sf.hibernate.Criteria;
+import net.sf.hibernate.HibernateException;
+import net.sf.hibernate.Session;
+import net.sf.hibernate.SessionFactory;
+import net.sf.hibernate.Transaction;
+import net.sf.hibernate.expression.Expression;
+
+/**
+ *
+ * StorageService
+ * @author idefix
+ * @version $Id: StorageService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public abstract class StorageService {
+ private Class objectClass;
+ private SessionFactory factory;
+
+ public StorageService(Class objectClass, SessionFactory factory){
+ this.objectClass = objectClass;
+ this.factory = factory;
+ }
+
+ public List list(int offset, int limit){
+ return list(offset, limit, null);
+ }
+
+ public List list(int offset, int limit, Expression expression){
+ try {
+ Session session = factory.openSession();
+ Transaction transaction = session.beginTransaction();
+ Criteria criteria = session.createCriteria(objectClass);
+ if(expression != null){
+ System.out.println(expression.toString());
+ criteria = criteria.add(expression);
+ }
+ criteria.setFirstResult(offset)
+ .setMaxResults(limit);
+ List returnList = criteria.list();
+ transaction.commit();
+ session.close();
+ return returnList;
+ } catch (HibernateException e) {
+ throw new StorageServiceFailure(e);
+ }
+ }
+
+ public Object load(Integer id){
+ try {
+ Session session = factory.openSession();
+ Transaction transaction = session.beginTransaction();
+ Object returnObject = session.load(objectClass, id);
+ transaction.commit();
+ session.close();
+ return returnObject;
+ } catch (HibernateException e) {
+ throw new StorageServiceFailure(e);
+ }
+ }
+
+ public Integer add(Object newObject){
+ try {
+ Session session = factory.openSession();
+ Transaction transaction = session.beginTransaction();
+ Integer newid = (Integer)session.save(newObject);
+ session.close();
+ return newid;
+ } catch (HibernateException e) {
+ throw new StorageServiceFailure(e);
+ }
+ }
+
+ public void update(Object toUpdate){
+ try {
+ Session session = factory.openSession();
+ Transaction transaction = session.beginTransaction();
+ session.update(toUpdate);
+ session.close();
+ } catch (HibernateException e) {
+ throw new StorageServiceFailure(e);
+ }
+ }
+
+ public void delete(Object toDelete){
+ try {
+ Session session = factory.openSession();
+ Transaction transaction = session.beginTransaction();
+ session.delete(toDelete);
+ session.close();
+ } catch (HibernateException e) {
+ throw new StorageServiceFailure(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * StorageServiceFailure.java
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import multex.Failure;
+
+/**
+ *
+ * StorageServiceFailure
+ * @author idefix
+ * @version $Id: StorageServiceFailure.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class StorageServiceFailure extends Failure {
+
+ /**
+ *
+ * @author idefix
+ *
+ * To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+ public StorageServiceFailure(Throwable throwable) {
+ super("A StorageFailure occured", throwable);
+ }
+
+}
--- /dev/null
+/*
+ * TopicService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Topic;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * TopicService
+ * @author idefix
+ * @version $Id: TopicService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class TopicService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public TopicService(SessionFactory factory) {
+ super(Topic.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * UploadedMediaService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.UploadedMedia;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * UploadedMediaService
+ * @author idefix
+ * @version $Id: UploadedMediaService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class UploadedMediaService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public UploadedMediaService(SessionFactory factory) {
+ super(UploadedMedia.class, factory);
+ }
+
+}
--- /dev/null
+/*
+ * UserService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+
+import java.util.List;
+
+import mir.core.model.MirUser;
+import net.sf.hibernate.SessionFactory;
+import net.sf.hibernate.expression.Expression;
+
+/**
+ * UserService
+ * @author idefix
+ * @version $Id: UserService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class UserService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public UserService(SessionFactory factory) {
+ super(MirUser.class, factory);
+ }
+
+ public MirUser loadUser(String user, String password){
+ List list = list(0, 1,
+ Expression.and(
+ Expression.and(
+ Expression.eq("login", user),
+ Expression.eq("password", password)
+ ),
+ Expression.eq("isAdmin", new Boolean(true))
+ )
+ );
+ return (MirUser)list.get(0);
+ }
+
+}
--- /dev/null
+/*
+ * VideoService.java created on 17.08.2003
+ *
+ * Copyright (C) 2001, 2002, 2003 The Mir-coders group
+ *
+ * This file is part of Mir.
+ *
+ * Mir is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Mir is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Mir; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * In addition, as a special exception, The Mir-coders gives permission to link
+ * the code of this program with any library licensed under the Apache Software License,
+ * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library
+ * (or with modified versions of the above that use the same license as the above),
+ * and distribute linked combinations including the two. You must obey the
+ * GNU General Public License in all respects for all of the code used other than
+ * the above mentioned libraries. If you modify this file, you may extend this
+ * exception to your version of the file, but you are not obligated to do so.
+ * If you do not wish to do so, delete this exception statement from your version.
+ */
+package mir.core.service.storage;
+
+import mir.core.model.Video;
+import net.sf.hibernate.SessionFactory;
+
+/**
+ * VideoService
+ * @author idefix
+ * @version $Id: VideoService.java,v 1.1 2003/08/17 19:11:49 idfx Exp $
+ */
+public class VideoService extends StorageService {
+
+ /**
+ * @param objectClass
+ * @param factory
+ */
+ public VideoService(SessionFactory factory) {
+ super(Video.class, factory);
+ }
+
+}