2013-07-30 48 views
0

你好,我正在尝试使用jsp开发我的web应用程序。我有6个jsp页面。分别为registration.jsp,login.jsp,r1.jsp,welcome.jsp,createroom.jsp和showroom.jsp。我的目标是当我在登录页面登录时,页面应该在openmeeting服务器中重定向。为此,我创建了类似omRestService的webservice。为了调用这个服务,我分别创建了两个java类omGateWay和OmPluginSettings。一切正常,但错误发生在ompluginSetting class.error下面提到。如何解决导入com.atlassian无法解决?

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); 
    } 
    } 

我还提供了我的restservice这是给定下面,完全没有错误。

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; 
       } 
      } 

After 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。先谢谢你。

+0

您是否已经在项目中导入了所需的库? – Abubakkar

+0

哪个库需要? – Kapil

+0

@Rajan如果说“com.atlassian无法解析”,则需要包含该库。如果要将应用程序部署到应用程序服务器,请将库添加到构建路径或部署程序集。 – q99

回答