Beispiel #1
0
 /**
  * @param sendTo
  * @param subject
  * @param body
  * @throws NotesException
  */
 public static void sendSimpleEmail(String sendTo, String subject, String body)
     throws NotesException {
   Document mailDoc = thisDb.createDocument();
   mailDoc.replaceItemValue("SendTo", sendTo.split(","));
   mailDoc.replaceItemValue("Subject", subject);
   mailDoc.replaceItemValue("body", body);
   mailDoc.send();
 }
Beispiel #2
0
  public static void createAppDefinition(String appPath, boolean hideFromWS, boolean autoLaunch) {

    Session sessionAsSigner = null;
    Database dbUnplugged = null;
    Document docApp = null;

    try {

      String correctedPath = appPath.replace("\\", "/");

      Logger.debug("create unplugged application " + correctedPath);

      Configuration config = Configuration.get();

      // open unplugged db
      sessionAsSigner = Utils.getCurrentSessionAsSigner();
      dbUnplugged =
          sessionAsSigner.getDatabase(config.getServerName(), config.getUnpluggedDbPath());

      // check if an app document for this app already exists and create it if not
      DocumentCollection dcApp =
          dbUnplugged.search("Form=\"UserDatabase\" & Path=\"" + correctedPath + "\"");

      if (dcApp.getCount() == 0) {

        // create new app document
        Logger.debug("application not found: create new");

        docApp = dbUnplugged.createDocument();
        docApp.replaceItemValue("form", "UserDatabase");
        docApp.replaceItemValue("Path", correctedPath);

      } else {

        throw (new Exception("application for " + correctedPath + " already exists in Unplugged"));
      }

      docApp.replaceItemValue("Active", "1");
      docApp.replaceItemValue("ShowOnWS", (hideFromWS ? "no" : ""));
      docApp.replaceItemValue("AutoLaunchApp", (autoLaunch ? "yes" : ""));
      docApp.replaceItemValue("ReplAttachmentExts", ""); // send all attachments
      docApp.computeWithForm(true, true);
      docApp.save();

      Logger.debug("done");

    } catch (Exception e) {

      Logger.error(e);

    } finally {

      Utils.recycle(docApp, dbUnplugged);
    }
  }
Beispiel #3
0
 /**
  * RWFException constructor
  *
  * @param Database d the current database
  */
 public RWFException(Database d) {
   super();
   try {
     Document e = d.createDocument();
     e.replaceItemValue("Form", EXCEPTION_FORM);
     e.replaceItemValue(EXCEPTION_TYPE_FIELD, "Workflow Exception");
     e.save();
   } catch (NotesException e) {
     e.printStackTrace();
     System.out.println(e.text);
   }
 }
Beispiel #4
0
 /**
  * RWFException constructor
  *
  * @param - msg, String the error message to be used.
  * @param Database d the current database
  * @param Document doc the context document.
  */
 public RWFException(String msg, Database d, Document doc) {
   super(msg);
   try {
     Document e = d.createDocument();
     e.replaceItemValue("Form", EXCEPTION_FORM);
     e.replaceItemValue(EXCEPTION_TYPE_FIELD, "Workflow Exception");
     e.replaceItemValue(EXCEPTION_MSG_FIELD, msg);
     RichTextItem rt = e.createRichTextItem(EXCEPTION_DOCLINK_FIELD);
     rt.appendDocLink(doc);
     e.save();
   } catch (NotesException e) {
     e.printStackTrace();
     System.out.println(e.text);
   }
 }
Beispiel #5
0
  // create an Unplugged user
  private static void createUser(Database dbUnplugged, String userName, boolean isActive) {

    Document docUser = null;

    try {

      Logger.info("create user document for " + userName);

      docUser = dbUnplugged.createDocument();
      docUser.replaceItemValue("Form", "User");
      docUser.replaceItemValue("UserName", userName);
      docUser.replaceItemValue("Active", (isActive ? "1" : "0"));
      docUser.computeWithForm(true, true);
      docUser.save();

    } catch (Exception e) {
      Logger.error(e);
    } finally {

      Utils.recycle(docUser);
    }
  }
Beispiel #6
0
  /*
   * Create an Unplugged application definition in the Unplugged database
   * and add the specified user to it. The user is created if Unplugged
   * if he doesn't exist yet.
   */
  @SuppressWarnings("unchecked")
  public static boolean createApplication(String userName, String appPath, boolean isActive) {

    Session sessionAsSigner = null;
    Database dbUnplugged = null;
    Document docApp = null;
    Document docUser = null;
    View vwUsers = null;
    Name nmUser = null;

    try {

      String correctedPath = appPath.replace("\\", "/");

      Logger.debug("create unplugged application " + correctedPath + " for " + userName);

      Configuration config = Configuration.get();

      // open unplugged db
      sessionAsSigner = Utils.getCurrentSessionAsSigner();
      dbUnplugged =
          sessionAsSigner.getDatabase(config.getServerName(), config.getUnpluggedDbPath());

      // create notes name object for user
      nmUser = sessionAsSigner.createName(userName);

      // check if user already exists in Unplugged
      vwUsers = dbUnplugged.getView(USERS_VIEW);
      docUser = vwUsers.getDocumentByKey(nmUser.getAbbreviated(), true);

      if (docUser == null) {

        // user doesn't exist yet: create
        Unplugged.createUser(dbUnplugged, nmUser.getCanonical(), isActive);

      } else if (docUser.getItemValueString("Active").equals("1") && !isActive) {

        // mark user as inactive
        docUser.replaceItemValue("Active", "0");
        docUser.save();

      } else if (!docUser.getItemValueString("Active").equals("1") && isActive) {

        // mark user as active
        docUser.replaceItemValue("Active", "1");
        docUser.save();
      }

      // check if an app document for this app already exists and create it if not
      DocumentCollection dcApp =
          dbUnplugged.search("Form=\"UserDatabase\" & Path=\"" + correctedPath + "\"");

      if (dcApp.getCount() == 0) {

        // create new app document
        Logger.debug("application not found: create new");

        docApp = dbUnplugged.createDocument();
        docApp.replaceItemValue("form", "UserDatabase");
        docApp.replaceItemValue("Path", correctedPath);

      } else {

        // update existing app document
        docApp = dcApp.getFirstDocument();
      }

      Vector<String> appUsers = docApp.getItemValue("UserName");

      if (!appUsers.contains(nmUser.getCanonical())) {

        Logger.debug(nmUser.getCanonical() + " not in list of application users: adding");

        appUsers.add(nmUser.getCanonical());
        docApp.replaceItemValue("UserName", appUsers);
        docApp.replaceItemValue("Active", "1");
        docApp.computeWithForm(true, true);
        docApp.save();
      }

      Logger.debug("done");

    } catch (NotesException e) {

      Logger.error(e);
    } finally {

      Utils.recycle(docUser, docApp, nmUser, dbUnplugged);
    }

    return true;
  }