0

您好我正在尝试使用 jsp 开发我的 Web 应用程序。我有6个jsp页面。页面分别是registration.jsp、login.jsp、r1.jsp、welcome.jsp、createroom.jsp和showroom.jsp。我的目标是当我登录登录页面时,页面应该重定向到 openmeeting 服务器。为此,我创建了像 omRestService 这样的 web 服务。为了调用此服务,我分别创建了两个 java 类 omGateWay 和 OmPluginSettings。一切正常,但在下面提到的 ompluginSetting class.error 中发生错误。

import com.atlassian.sal.api.pluginsettings.PluginSettings;
import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
 (The import com.atlassian cannot be resolved)

在这里,我向您提供我的 OmPluginSeeting.java 文件,该文件有错误。PluginSettingsFactory 出现很多错误。

        package restService;

   import com.atlassian.sal.api.pluginsettings.PluginSettings;
   import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
   import org.slf4j.Logger;
   import org.slf4j.LoggerFactory;

   public class OmPluginSettings
   {
 private static final Logger log = (Logger) LoggerFactory.getLogger(OmPluginSettings.class);
     final PluginSettingsFactory pluginSettingsFactory;

     public OmPluginSettings(PluginSettingsFactory pluginSettingsFactory)
     {
     this.pluginSettingsFactory = pluginSettingsFactory;
     }

     public void storeSomeInfo(String key, String value)
     {
   this.pluginSettingsFactory.createGlobalSettings().put("openmeetings:" + key, value);
     }

     public Object getSomeInfo(String key)
        {
    return this.pluginSettingsFactory.createGlobalSettings().get("openmeetings:" + key);
        }

     public void storeSomeInfo(String projectKey, String key, String value)
     {
     this.pluginSettingsFactory.createSettingsForKey(projectKey).put("openmeetings:" + key, 
     value);
     }

     public Object getSomeInfo(String projectKey, String key) {
    return this.pluginSettingsFactory.createSettingsForKey(projectKey).get("openmeetings:" 
     + key);
     }
   }

我还提供了我的休息服务,它在下面给出并且完全没有错误。

    package restService;
            import java.io.BufferedReader;
            import java.io.ByteArrayInputStream;
            import java.io.IOException;
            import java.io.InputStream;
            import java.io.InputStreamReader;
            import java.io.UnsupportedEncodingException;
            import java.net.MalformedURLException;
            import java.net.URI;
            import java.net.URL;
            import java.util.Iterator;
            import java.util.LinkedHashMap;
      import javax.ws.rs.core.UriBuilder;
            import org.apache.commons.httpclient.HttpClient;
            import org.apache.commons.httpclient.HttpException;
            import org.apache.commons.httpclient.methods.GetMethod;
            import org.dom4j.Document;
            import org.dom4j.DocumentException;
            import org.dom4j.Element;
            import org.dom4j.io.SAXReader;
            import org.slf4j.Logger;
            import org.slf4j.LoggerFactory;

            public class omRestService
            {
            private static final Logger log = (Logger) 
            LoggerFactory.getLogger(omRestService.class);

              private URI getURI(String url) {
              return UriBuilder.fromUri(
                url).build(new Object[0]);
              }

              private String getEncodetURI(String url) throws MalformedURLException
              {
              return new URL(url).toString().replaceAll(" ", "%20");
              }

              public LinkedHashMap<String, Element> call(String request, Object param) 
              throws Exception
              {
              HttpClient client = new HttpClient();
              GetMethod method = null;
                try
                {
                method = new GetMethod(getEncodetURI(request).toString());
                }
                catch (MalformedURLException e) {
                e.printStackTrace();
                }
                int statusCode = 0;
                try {
                statusCode = client.executeMethod(method);
                }
                catch (HttpException e)
                {
                throw new Exception("Connection to OpenMeetings refused. Please check your  
                OpenMeetings configuration.");
                }
                catch (IOException e)
                {
                throw new Exception("Connection to OpenMeetings refused. Please check your  
                 OpenMeetings configuration.");
                }

              switch (statusCode)
                {
                case 200:
                break;
                case 400:
                throw new Exception("Bad request. The parameters passed to the service did 
                not match 
                as expected. The Message should tell you what was missing or incorrect.");
                case 403:
               throw new Exception("Forbidden. You do not have permission to access this 
                resource, or 
                are over your rate limit.");
                case 503:
               throw new Exception("Service unavailable. An internal problem prevented us 
                   from 
                 returning data to you.");
                default:
               throw new Exception("Your call to OpenMeetings! Web Services returned an 
               unexpected  
                HTTP status of: " + statusCode);
                }

             InputStream rstream = null;
                try
                {
               rstream = method.getResponseBodyAsStream();
                }
                catch (IOException e) {
               e.printStackTrace();
               throw new Exception("No Response Body");
                }

             BufferedReader br = new BufferedReader(new InputStreamReader(rstream));

             SAXReader reader = new SAXReader();

            Document document = null;
                String line;
                try
                {
                 // String line;
              while ((line = br.readLine()) != null)
                  {
                  //  String line;
                 document = reader.read(new ByteArrayInputStream(line.getBytes("UTF-8")));
                  }

                }
                catch (UnsupportedEncodingException e)
                {
              e.printStackTrace();
              throw new Exception("UnsupportedEncodingException by SAXReader");
                }
                catch (IOException e) {
               e.printStackTrace();
               throw new Exception("IOException by SAXReader in REST Service");
                }
                catch (DocumentException e) {
              e.printStackTrace();
               throw new Exception("DocumentException by SAXReader in REST Service");
                } finally {
              br.close();
                }

            Element root = document.getRootElement();

             LinkedHashMap elementMap = new LinkedHashMap();

            for (Iterator i = root.elementIterator(); i.hasNext(); )
                {
              Element item = (Element)i.next();

               if (item.getNamespacePrefix() == "soapenv") {
                throw new Exception(item.getData().toString());
                  }
               String nodeVal = item.getName();
              elementMap.put(nodeVal, item);
                }

             return elementMap;
              }
            }

在此 RestService 之后,我制作了 OmGateWay 类,该类具有许多与 openmeetings 集成的方法。下面给出:

          package org.openmeetings.jira.plugin.gateway;

          import java.util.LinkedHashMap;
          import org.dom    j.Element;
          import org.openmeetings.jira.plugin.ao.adminconfiguration.OmPluginSettings;
          import org.slf    j.Logger;
          import org.slf    j.LoggerFactory;

          public class OmGateway
          {
                  private static final Logger log =      
            LoggerFactory.getLogger(OmGateway.class);
            private OmRestService omRestService;
            private OmPluginSettings omPluginSettings;
            private String sessionId;

            public OmGateway(OmRestService omRestService, OmPluginSettings omPluginSettings)
            {
                    this.omRestService = omRestService;
                    this.omPluginSettings = omPluginSettings;
            }

            public Boolean loginUser() throws Exception
            {
                    LinkedHashMap result = null;

                    String url = (String)this.omPluginSettings.getSomeInfo("url");
                    String port = (String)this.omPluginSettings.getSomeInfo("port");
                    String userpass = (String)this.omPluginSettings.getSomeInfo("userpass");
                    String omusername = 
                    (String)this.omPluginSettings.getSomeInfo("username");

                    String sessionURL = "http://" + url + ":" + port + "/openmeetings
                     /services/      
                    UserService/getSession";

                    LinkedHashMap elementMap = this.omRestService.call(sessionURL, null);

                    Element item = (Element)elementMap.get("return");

                    setSessionId(item.elementText("session_id"));

                    log.info(item.elementText("session_id"));

                    result = this.omRestService.call("http://" + url + ":" + port + 
                    "/openmeetings/
                     services/UserService/loginUser?SID=" + getSessionId() + "&username=" + 
                     omusername 
                     + "&userpass=" + userpass, null);
                    if 

      (Integer.valueOf(((Element)result.get("return")).getStringValue()).intValue() >     
   )   {
                      return Boolean.valueOf(true);
              }
                    return Boolean.valueOf(false);
            }

            public Long addRoomWithModerationExternalTypeAndTopBarOption(Boolean 
            isAllowedRecording,   
            Boolean isAudioOnly, Boolean isModeratedRoom, String name, Long 
            numberOfParticipent, Long 
             roomType, String externalRoomType)
              throws Exception
            {
                    String url = (String)this.omPluginSettings.getSomeInfo("url");
                    String port = (String)this.omPluginSettings.getSomeInfo("port");

                    String roomId = "";

                    String restURL = "http://" + url + ":" + port + "/openmeetings/services/
                     RoomService/addRoomWithModerationExternalTypeAndTopBarOption?" + 
                      "SID=" + getSessionId() + 
                      "&name=" + name + 
                      "&roomtypes_id=" + roomType.toString() + 
                      "&comment=jira" + 
                      "&numberOfPartizipants=" + numberOfParticipent.toString() + 
                      "&ispublic=false" + 
                      "&appointment=false" + 
                      "&isDemoRoom=false" + 
                      "&demoTime=" + 
                      "&isModeratedRoom=" + isModeratedRoom.toString() + 
                      "&externalRoomType=" + externalRoomType + 
                      "&allowUserQuestions=" + 
                      "&isAudioOnly=" + isAudioOnly.toString() + 
                      "&waitForRecording=false" + 
                     "&allowRecording=" + isAllowedRecording.toString() + 
                     "&hideTopBar=false";

                   LinkedHashMap result = this.omRestService.call(restURL, null);

                   roomId = ((Element)result.get("return")).getStringValue();
                   return Long.valueOf(roomId);
            }

            public Long updateRoomWithModerationAndQuestions(Boolean isAllowedRecording, 
            Boolean 
             isAudioOnly, Boolean isModeratedRoom, String roomname, Long 
             numberOfParticipent, Long 
             roomType, Long roomId)
              throws Exception
            {
                   String url = (String)this.omPluginSettings.getSomeInfo("url");
                   String port = (String)this.omPluginSettings.getSomeInfo("port");
                   String updateRoomId = "";

                   String restURL = "http://" + url + ":" + port + "/openmeetings/services
                 /RoomService/
                   updateRoomWithModerationAndQuestions?" + 
                     "SID=" + getSessionId() + 
                     "&room_id=" + roomId.toString() + 
                     "&name=" + roomname.toString() + 
                     "&roomtypes_id=" + roomType.toString() + 
                     "&comment=" + 
                     "&numberOfPartizipants=" + numberOfParticipent.toString() + 
                     "&ispublic=false" + 
                     "&appointment=false" + 
                     "&isDemoRoom=false" + 
                     "&demoTime=" + 
                     "&isModeratedRoom=" + isModeratedRoom.toString() + 
                     "&allowUserQuestions=";

                   LinkedHashMap result = this.omRestService.call(restURL, null);

                   log.info("addRoomWithModerationExternalTypeAndTopBarOption with ID: ", 
                   ((Element)result.get("return")).getStringValue());

                   updateRoomId = ((Element)result.get("return")).getStringValue();

                   return Long.valueOf(updateRoomId);
            }

            public String setUserObjectAndGenerateRoomHash(String username, String 
            firstname, String 
            lastname, String profilePictureUrl, String email, String externalUserId, String 
              externalUserType, Long room_id, int becomeModeratorAsInt, int 
             showAudioVideoTestAsInt)
              throws Exception
            {
                   String url = (String)this.omPluginSettings.getSomeInfo("url");
                   String port = (String)this.omPluginSettings.getSomeInfo("port");
                   String roomHash = null;

                   String restURL = "http://" + url + ":" + port + "/openmeetings/services
               /UserService/
                    setUserObjectAndGenerateRoomHash?" + 
                     "SID=" + getSessionId() + 
                     "&username=" + username + 
                     "&firstname=" + firstname + 
                     "&lastname=" + lastname + 
                     "&profilePictureUrl=" + profilePictureUrl + 
                     "&email=" + email + 
                     "&externalUserId=" + externalUserId + 
                     "&externalUserType=" + externalUserType + 
                     "&room_id=" + room_id + 
                     "&becomeModeratorAsInt=" + becomeModeratorAsInt + 
                     "&showAudioVideoTestAsInt=" + showAudioVideoTestAsInt;

                   LinkedHashMap result = this.omRestService.call(restURL, null);

                   roomHash = ((Element)result.get("return")).getStringValue();

                   return roomHash;
            }

            public String getSessionId() {
                   return this.sessionId;
            }

            public void setSessionId(String sessionId) {
                   this.sessionId = sessionId;
            }
          }

我想在 Jsp 按钮单击事件上从 OmGateway 类调用 loginuser 方法。请帮我解决这个错误。并帮助重定向和集成到 openmeetings。先感谢您。

4

2 回答 2

-1

访问Atlassian 开发人员寻求帮助

于 2013-07-30T07:05:34.313 回答
-1

您是否尝试过来自网站的 Jira 插件:http: //openmeetings.apache.org/JiraPlugin.html

或者这实际上是您在此处发布的插件代码?

于 2013-07-30T07:27:37.640 回答