mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-63546: Add Trac support in the Task/Context support [currently disabled]
This commit is contained in:
@@ -106,6 +106,8 @@
|
||||
<tasks.repositoryType implementation="com.intellij.tasks.pivotal.PivotalTrackerRepositoryType"/>
|
||||
<tasks.repositoryType implementation="com.intellij.tasks.github.GitHubRepositoryType"/>
|
||||
<tasks.repositoryType implementation="com.intellij.tasks.redmine.RedmineRepositoryType"/>
|
||||
<!--<tasks.repositoryType implementation="com.intellij.tasks.trac.TracRepositoryType"/>-->
|
||||
|
||||
<!--<tasks.repositoryType implementation="com.intellij.tasks.mantis.MantisRepositoryType"/>-->
|
||||
</extensions>
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tasks.trac;
|
||||
|
||||
import com.intellij.tasks.Task;
|
||||
import com.intellij.tasks.impl.BaseRepository;
|
||||
import com.intellij.tasks.impl.BaseRepositoryImpl;
|
||||
import com.intellij.tasks.impl.LocalTaskImpl;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.apache.xmlrpc.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class TracRepository extends BaseRepositoryImpl implements XmlRpcTransportFactory {
|
||||
|
||||
@Override
|
||||
public Task[] getIssues(@Nullable String query, int max, long since) throws Exception {
|
||||
final XmlRpcClient client = getRpcClient();
|
||||
Object[] result = (Object[])client.execute("ticket.query", new Vector<Object>(Arrays.asList(query == null ? "" : query)));
|
||||
|
||||
if (result == null) throw new Exception("Cannot connect to " + getUrl());
|
||||
|
||||
List<Task> tasks = ContainerUtil.mapNotNull(result, new NullableFunction<Object, Task>() {
|
||||
@Override
|
||||
public Task fun(Object o) {
|
||||
try {
|
||||
return getTask((Integer)o, client);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
return tasks.toArray(new Task[tasks.size()]);
|
||||
}
|
||||
|
||||
private XmlRpcClient getRpcClient() throws MalformedURLException {
|
||||
return new XmlRpcClient(new URL(getUrl()), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task findTask(String id) throws Exception {
|
||||
return getTask(Integer.parseInt(id), getRpcClient());
|
||||
}
|
||||
|
||||
private static Task getTask(int id, XmlRpcClient client) throws IOException, XmlRpcException {
|
||||
Object response = client.execute("ticket.get", new Vector(Arrays.asList(id)));
|
||||
LocalTaskImpl task = new LocalTaskImpl();
|
||||
return task;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testConnection() throws Exception {
|
||||
getIssues("", 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseRepository clone() {
|
||||
return new TracRepository(this);
|
||||
}
|
||||
|
||||
public TracRepository(TracRepositoryType repositoryType) {
|
||||
super(repositoryType);
|
||||
}
|
||||
|
||||
private TracRepository(TracRepository other) {
|
||||
super(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlRpcTransport createTransport() throws XmlRpcClientException {
|
||||
try {
|
||||
return new CommonsXmlRpcTransport(new URL(getUrl()), getHttpClient());
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
throw new XmlRpcClientException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String propertyName, Object value) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.tasks.trac;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.tasks.TaskRepository;
|
||||
import com.intellij.tasks.impl.BaseRepositoryType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
*/
|
||||
public class TracRepositoryType extends BaseRepositoryType<TracRepository> {
|
||||
|
||||
private static final Icon ICON = IconLoader.getIcon("/com/intellij/tasks/trac/trac.png");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Trac";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return ICON;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TaskRepository createRepository() {
|
||||
return new TracRepository(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<TracRepository> getRepositoryClass() {
|
||||
return TracRepository.class;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 851 B |
@@ -27,6 +27,7 @@
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" exported="" name="http-client-3.1" level="project" />
|
||||
<orderEntry type="library" name="XmlRPC" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user