/**
   * Create new Meeting Workspace on Alfresco server
   *
   * @param soapRequest Vti soap request ({@link VtiSoapRequest})
   * @param soapResponse Vti soap response ({@link VtiSoapResponse})
   */
  public void execute(VtiSoapRequest soapRequest, VtiSoapResponse soapResponse) throws Exception {
    if (logger.isDebugEnabled())
      logger.debug("Soap Method with name " + getName() + " is started.");
    // mapping xml namespace to prefix
    SimpleNamespaceContext nc = new SimpleNamespaceContext();
    nc.addNamespace(prefix, namespace);
    nc.addNamespace(soapUriPrefix, soapUri);

    Element requestElement = soapRequest.getDocument().getRootElement();

    // getting title parameter from request
    if (logger.isDebugEnabled()) logger.debug("Getting title from request.");
    XPath titlePath = new Dom4jXPath(buildXPath(prefix, "/CreateWorkspace/title"));
    titlePath.setNamespaceContext(nc);
    Element title = (Element) titlePath.selectSingleNode(requestElement);

    if (title.getText() == null || title.getText().length() < 1) {
      throw new RuntimeException("Site name is not specified. Please fill up subject field.");
    }

    // getting templateName parameter from request
    if (logger.isDebugEnabled()) logger.debug("Getting templateName from request.");
    XPath templateNamePath = new Dom4jXPath(buildXPath(prefix, "/CreateWorkspace/templateName"));
    templateNamePath.setNamespaceContext(nc);
    Element templateName = (Element) templateNamePath.selectSingleNode(requestElement);

    // getting lcid parameter from request
    if (logger.isDebugEnabled()) logger.debug("Getting lcid from request.");
    XPath lcidPath = new Dom4jXPath(buildXPath(prefix, "/CreateWorkspace/lcid"));
    lcidPath.setNamespaceContext(nc);
    Element lcid = (Element) lcidPath.selectSingleNode(requestElement);

    String siteName =
        handler.createWorkspace(
            title.getText(),
            templateName.getText(),
            Integer.parseInt(lcid.getText()),
            getTimeZoneInformation(requestElement),
            (SessionUser)
                soapRequest.getSession().getAttribute(SharepointConstants.USER_SESSION_ATTRIBUTE));

    // creating soap response
    Element root = soapResponse.getDocument().addElement("CreateWorkspaceResponse", namespace);
    root.addElement("CreateWorkspaceResult")
        .addElement("CreateWorkspace")
        .addAttribute(
            "Url", getHost(soapRequest) + soapRequest.getAlfrescoContextName() + "/" + siteName);

    if (logger.isDebugEnabled()) {
      logger.debug("SOAP method with name " + getName() + " is finished.");
    }
  }
Пример #2
0
  /**
   * Check in file
   *
   * @param soapRequest Vti soap request ({@link VtiSoapRequest})
   * @param soapResponse Vti soap response ({@link VtiSoapResponse})
   */
  public void execute(VtiSoapRequest soapRequest, VtiSoapResponse soapResponse) throws Exception {
    if (logger.isDebugEnabled())
      logger.debug("Soap Method with name " + getName() + " is started.");

    // mapping xml namespace to prefix
    SimpleNamespaceContext nc = new SimpleNamespaceContext();
    nc.addNamespace(prefix, namespace);
    nc.addNamespace(soapUriPrefix, soapUri);

    String host = getHost(soapRequest);
    String context = soapRequest.getAlfrescoContextName();

    // getting pageUrl parameter from request
    XPath xpath = new Dom4jXPath(buildXPath(prefix, "/CheckInFile/pageUrl"));
    xpath.setNamespaceContext(nc);
    Element docE = (Element) xpath.selectSingleNode(soapRequest.getDocument().getRootElement());
    if (docE == null || docE.getTextTrim().length() == 0) {
      throw new VtiSoapException("pageUrl must be supplied", 0x82000001l);
    }

    String docPath = URLDecoder.decode(docE.getTextTrim(), "UTF-8");
    if (docPath.indexOf(host) == -1 || docPath.indexOf(context) == -1) {
      throw new VtiSoapException("Invalid URI: The format of the URI could not be determined", -1);
    }
    docPath = docPath.substring(host.length() + context.length());

    // Get the comment
    xpath = new Dom4jXPath(buildXPath(prefix, "/CheckInFile/comment"));
    xpath.setNamespaceContext(nc);
    String comment =
        ((Element) xpath.selectSingleNode(soapRequest.getDocument().getRootElement()))
            .getTextTrim();

    // Get the checkin type
    xpath = new Dom4jXPath(buildXPath(prefix, "/CheckInFile/CheckinType"));
    xpath.setNamespaceContext(nc);
    Element typeE = (Element) xpath.selectSingleNode(soapRequest.getDocument().getRootElement());

    VersionType type = VersionType.MAJOR;
    if (typeE != null && typeE.getTextTrim().length() > 0) {
      String typeS = typeE.getTextTrim();
      if ("0".equals(typeS)) {
        type = VersionType.MINOR;
      } else if ("1".equals(typeS)) {
        type = VersionType.MAJOR;
      } else if ("2".equals(typeS)) {
        type = VersionType.MAJOR;
      } else {
        throw new VtiSoapException("Invalid Checkin Type '" + typeS + "' received", -1);
      }
    }

    // Good to go
    if (logger.isDebugEnabled()) {
      logger.debug("item parameter for this request: " + docPath);
    }

    NodeRef originalNode;
    boolean lockAfterSucess = true;

    // Do not lock original node if we work with Office 2008/2011 for Mac
    if (VtiUtils.isMacClientRequest(soapRequest)) {
      lockAfterSucess = false;
    }

    try {
      originalNode = handler.checkInDocument(docPath, type, comment, lockAfterSucess);
    } catch (FileNotFoundException fnfe) {
      throw new VtiSoapException("File not found", -1, fnfe);
    }

    // creating soap response
    Element responseElement =
        soapResponse.getDocument().addElement("CheckInFileResponse", namespace);
    Element result = responseElement.addElement("CheckInFileResult");
    result.setText(originalNode != null ? "true" : "false");

    soapResponse.setContentType("text/xml");
    if (logger.isDebugEnabled()) {
      logger.debug("Soap Method with name " + getName() + " is finished.");
    }
  }