Search in sources :

Example 1 with ExceptionException

use of org.wso2.carbon.core.commons.stub.loggeduserinfo.ExceptionException in project carbon-business-process by wso2.

the class AttachmentUploadClient method addUploadedFileItem.

/**
 * Upload the attachment and return the attachment id
 * @param fileItemData wrapper for the attachment
 * @return attachment id for the uploaded attachment
 * @throws AttachmentMgtException If an error occurred in the back-end component
 * @throws RemoteException if an error during the communication
 */
public String addUploadedFileItem(FileItemData fileItemData) throws AttachmentMgtException, RemoteException, ExceptionException {
    DataHandler handler = fileItemData.getDataHandler();
    TAttachment attachment = new TAttachment();
    attachment.setName(handler.getName());
    attachment.setContentType(handler.getContentType());
    attachment.setCreatedBy(getUserName());
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());
    attachment.setCreatedTime(calendar);
    attachment.setContent(handler);
    String attachmentID = stub.add(attachment);
    log.info("Attachment was uploaded with id:" + attachmentID);
    return attachmentID;
}
Also used : TAttachment(org.wso2.carbon.attachment.mgt.stub.types.TAttachment) Calendar(java.util.Calendar) DataHandler(javax.activation.DataHandler) Date(java.util.Date)

Example 2 with ExceptionException

use of org.wso2.carbon.core.commons.stub.loggeduserinfo.ExceptionException in project carbon-apimgt by wso2.

the class APIUtil method getLoggedInUserInfo.

/**
 * Gets the information of the logged in User.
 *
 * @param cookie     Cookie of the previously logged in session.
 * @param serviceUrl Url of the authentication service.
 * @return LoggedUserInfo object containing details of the logged in user.
 * @throws ExceptionException
 * @throws RemoteException
 */
public static LoggedUserInfo getLoggedInUserInfo(String cookie, String serviceUrl) throws RemoteException, ExceptionException {
    LoggedUserInfoAdminStub stub = new LoggedUserInfoAdminStub(null, serviceUrl + "LoggedUserInfoAdmin");
    ServiceClient client = stub._getServiceClient();
    Options options = client.getOptions();
    options.setManageSession(true);
    options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
    return stub.getUserInfo();
}
Also used : Options(org.apache.axis2.client.Options) ServiceClient(org.apache.axis2.client.ServiceClient) LoggedUserInfoAdminStub(org.wso2.carbon.core.commons.stub.loggeduserinfo.LoggedUserInfoAdminStub)

Aggregations

Calendar (java.util.Calendar)1 Date (java.util.Date)1 DataHandler (javax.activation.DataHandler)1 Options (org.apache.axis2.client.Options)1 ServiceClient (org.apache.axis2.client.ServiceClient)1 TAttachment (org.wso2.carbon.attachment.mgt.stub.types.TAttachment)1 LoggedUserInfoAdminStub (org.wso2.carbon.core.commons.stub.loggeduserinfo.LoggedUserInfoAdminStub)1