Home | History | Annotate | Download | only in errorReporting
      1 /*
      2  * Copyright 2000-2014 JetBrains s.r.o.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package org.jf.smalidea.errorReporting;
     17 
     18 import com.intellij.errorreport.bean.ErrorBean;
     19 import com.intellij.idea.IdeaLogger;
     20 import com.intellij.openapi.application.Application;
     21 import com.intellij.openapi.application.ApplicationManager;
     22 import com.intellij.openapi.application.ApplicationNamesInfo;
     23 import com.intellij.openapi.application.ex.ApplicationInfoEx;
     24 import com.intellij.openapi.diagnostic.Attachment;
     25 import com.intellij.openapi.updateSettings.impl.UpdateSettings;
     26 import com.intellij.openapi.util.text.StringUtil;
     27 import com.intellij.util.SystemProperties;
     28 import com.intellij.util.containers.ContainerUtil;
     29 
     30 import java.util.Calendar;
     31 import java.util.Map;
     32 
     33 /**
     34  * @author stathik
     35  * @since Aug 4, 2003
     36  */
     37 public class ITNProxy {
     38 
     39   public static Map<String, String> createParameters(ErrorBean error) {
     40     Map<String, String> params = ContainerUtil.newLinkedHashMap(40);
     41 
     42     params.put("protocol.version", "1");
     43 
     44     params.put("os.name", SystemProperties.getOsName());
     45     params.put("java.version", SystemProperties.getJavaVersion());
     46     params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
     47 
     48     ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
     49     ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
     50     Application application = ApplicationManager.getApplication();
     51     params.put("app.name", namesInfo.getProductName());
     52     params.put("app.name.full", namesInfo.getFullProductName());
     53     params.put("app.name.version", appInfo.getVersionName());
     54     params.put("app.eap", Boolean.toString(appInfo.isEAP()));
     55     params.put("app.internal", Boolean.toString(application.isInternal()));
     56     params.put("app.build", appInfo.getBuild().asString());
     57     params.put("app.version.major", appInfo.getMajorVersion());
     58     params.put("app.version.minor", appInfo.getMinorVersion());
     59     params.put("app.build.date", format(appInfo.getBuildDate()));
     60     params.put("app.build.date.release", format(appInfo.getMajorReleaseBuildDate()));
     61     params.put("app.compilation.timestamp", IdeaLogger.getOurCompilationTimestamp());
     62 
     63     UpdateSettings updateSettings = UpdateSettings.getInstance();
     64     params.put("update.channel.status", updateSettings.getSelectedChannelStatus().getCode());
     65     params.put("update.ignored.builds", StringUtil.join(updateSettings.getIgnoredBuildNumbers(), ","));
     66 
     67     params.put("plugin.name", error.getPluginName());
     68     params.put("plugin.version", error.getPluginVersion());
     69 
     70     params.put("last.action", error.getLastAction());
     71     params.put("previous.exception", error.getPreviousException() == null ? null : Integer.toString(error.getPreviousException()));
     72 
     73     params.put("error.message", error.getMessage());
     74     params.put("error.stacktrace", error.getStackTrace());
     75     params.put("error.description", error.getDescription());
     76 
     77     params.put("assignee.id", error.getAssigneeId() == null ? null : Integer.toString(error.getAssigneeId()));
     78 
     79     for (Attachment attachment : error.getAttachments()) {
     80       params.put("attachment.name", attachment.getName());
     81       params.put("attachment.value", attachment.getEncodedBytes());
     82     }
     83 
     84     return params;
     85   }
     86 
     87   private static String format(Calendar calendar) {
     88     return calendar == null ?  null : Long.toString(calendar.getTime().getTime());
     89   }
     90 }
     91