Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions org.abapgit.adt.backend/src/org/abapgit/adt/backend/IObject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.abapgit.adt.backend;

import java.util.List;

public interface IObject {

public String getObjType();

public String getObjName();

public String getObjStatus();

public String getPackage();

public String getMsgType();

public String getMsgText();

public List<IObject> listMessages();

public Object getMsgParent();

public void setObjType(String type);

public void setObjName(String name);

public void setObjStatus(String status);

public void setPackage(String pckg);

public void setMsgType(String msg_type);

public void setMsgText(String msg_text);

public void addChild(IObject abapLogObject);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.abapgit.adt.backend;

import java.util.List;

public interface IObjects {
List<IObject> getObjects();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ public interface IRepositoryService {

IRepositories getRepositories(IProgressMonitor monitor);

void cloneRepository(String url, String branch, String targetPackage, String transportRequest, String user,
IObjects cloneRepository(String url, String branch, String targetPackage, String transportRequest, String user,
String password, IProgressMonitor monitor);

void unlinkRepository(String key, IProgressMonitor monitor);

void pullRepository(IRepository existingRepository, String branch, String transportRequest, String user, String password,
IObjects pullRepository(IRepository existingRepository, String branch, String transportRequest, String user, String password,
IProgressMonitor monitor);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package org.abapgit.adt.backend.internal;

//import java.net.URI;
import java.util.ArrayList;
//import java.util.HashMap;
import java.util.List;
//import java.util.Map;

import org.abapgit.adt.backend.IObject;

public class AbapObject implements IObject {

private String type;
private String name;
private String status;
private String pckg;
private String msg_type;
private String msg_text;
// private final Map<String, URI> links = new HashMap<>();

private final List<IObject> abapLogObjectChildren = new ArrayList<IObject>();

@Override
public void addChild(IObject abapLogObject) {
this.abapLogObjectChildren.add(abapLogObject);
}

@Override
public String getObjType() {
return this.type;
}

@Override
public String getObjName() {
return this.name;
}

@Override
public String getObjStatus() {
return this.status;
}

@Override
public String getPackage() {
return this.pckg;
}

@Override
public String getMsgType() {
return this.msg_type;
}

@Override
public String getMsgText() {
return this.msg_text;
}

@Override
public void setObjType(String type) {
this.type = type;
}

@Override
public void setObjName(String name) {
this.name = name;
}

@Override
public void setObjStatus(String status) {
this.status = status;
}

@Override
public void setPackage(String pckg) {
this.pckg = pckg;
}

@Override
public void setMsgType(String msg_type) {
this.msg_type = msg_type;
}


@Override
public void setMsgText(String msg_text) {
this.msg_text = msg_text;
}

@Override
public List<IObject> listMessages() {
return this.abapLogObjectChildren;
}

@Override
public Object getMsgParent() {
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.abapgit.adt.backend.internal;

import java.io.IOException;
import java.nio.charset.Charset;

import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.abapgit.adt.backend.IObjects;

import com.sap.adt.communication.content.ContentHandlerException;
import com.sap.adt.communication.content.IContentHandler;
import com.sap.adt.communication.message.IMessageBody;

public class AbapObjectContentHandlerV1 implements IContentHandler<IObjects> {
private static final String CONTENT_TYPE_V1 = "application/abapgit.adt.repo.object.v1+xml"; //$NON-NLS-1$

@Override
public IObjects deserialize(IMessageBody body, Class<? extends IObjects> dataType) {
try {
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(body.getContent());
return new AbapObjectsSerializer().deserializeAbapObjects(xmlStreamReader, getSupportedContentType());
} catch (IOException | XMLStreamException e) {
throw new ContentHandlerException("Error parsing repositories", e); //$NON-NLS-1$
}
}

@Override
public String getSupportedContentType() {
return CONTENT_TYPE_V1;
}

@Override
public Class<IObjects> getSupportedDataType() {
return IObjects.class;
}

@Override
public IMessageBody serialize(IObjects arg0, Charset arg1) {
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.abapgit.adt.backend.internal;

import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.abapgit.adt.backend.IObject;

public class AbapObjectSerializer {
public IObject deserializeAbapObject(XMLStreamReader xmlReader, String contentType) throws XMLStreamException {
IObject object = new AbapObject();
IObject object_msg = new AbapObject();
boolean message_exists = false;

int depth = 0;
loop: while (xmlReader.hasNext()) {
int next = xmlReader.next();
switch (next) {
case XMLStreamConstants.START_ELEMENT:
switch (xmlReader.getLocalName()) {
case "obj_type": //$NON-NLS-1$
object.setObjType(xmlReader.getElementText());
object_msg.setObjType("Message"); //$NON-NLS-1$
message_exists = false;
break;
case "obj_name": //$NON-NLS-1$
object.setObjName(xmlReader.getElementText());
break;
case "obj_status": //$NON-NLS-1$
object.setObjStatus(xmlReader.getElementText());
break;
case "package": //$NON-NLS-1$
object.setPackage(xmlReader.getElementText());
break;
case "msg_type": //$NON-NLS-1$
// object.setMsgType(xmlReader.getElementText());
object_msg.setMsgType(xmlReader.getElementText());
message_exists = true;
break;
case "msg_text": //$NON-NLS-1$
// object.setMsgText(xmlReader.getElementText());
object_msg.setMsgText(xmlReader.getElementText());
if (message_exists) {
object.addChild(object_msg);
}
break;
default:
depth++;
break;
}
break;
case XMLStreamConstants.END_ELEMENT:
if (depth == 0) {
break loop;
}
depth--;
break;
default:
break;
}
}

return object;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.abapgit.adt.backend.internal;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.abapgit.adt.backend.IObject;
import org.abapgit.adt.backend.IObjects;

public class AbapObjects implements IObjects {

private final List<IObject> objects = new LinkedList<>();

public void addList(List<IObject> objects) {
this.objects.addAll(objects);
}

@Override
public List<IObject> getObjects() {
return Collections.unmodifiableList(this.objects);
}

public void add(IObject object) {
this.objects.add(object);
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Objects [objects="); //$NON-NLS-1$
builder.append(this.objects);
builder.append("]"); //$NON-NLS-1$
return builder.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.abapgit.adt.backend.internal;

import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

import org.abapgit.adt.backend.IObjects;

public class AbapObjectsSerializer {
public IObjects deserializeAbapObjects(XMLStreamReader xmlReader, String contentType) throws XMLStreamException {
AbapObjects objects = new AbapObjects();

while (xmlReader.hasNext()) {
int next = xmlReader.next();
switch (next) {
case XMLStreamConstants.START_ELEMENT:
switch (xmlReader.getLocalName()) {
case "object": //$NON-NLS-1$
objects.add(new AbapObjectSerializer().deserializeAbapObject(xmlReader, contentType));
break;
default:
break;
}
break;
default:
break;
}
}

return objects;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public IRepository deserializeRepository(XMLStreamReader xmlReader, String conte
repository.setPackage(xmlReader.getElementText());
break;
case "link": //$NON-NLS-1$
repository.addLink(xmlReader.getAttributeValue(null, "rel"), URI.create(xmlReader.getAttributeValue(null, "href")));
repository.addLink(xmlReader.getAttributeValue(null, "rel"), URI.create(xmlReader.getAttributeValue(null, "href"))); //$NON-NLS-1$ //$NON-NLS-2$
break;
default:
depth++;
Expand Down
Loading