Error in loading file with same name - rest

I am using below script for uploading a file in alfresco but it refuses to create stating conflict.
"<?xml version='1.0' encoding='utf-8'?>\n" +
"<entry xmlns='http://www.w3.org/2005/Atom' xmlns:app=\"http://www.w3.org/2007/app\" xmlns:cmisra=\"http://docs.oasis-open.org/ns/cmis/restatom/200908/\" xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\" xmlns:alf=\"http://www.alfresco.org\">\n" +
"<title>" + fileName + "</title>\n" +
"<summary>" + fileDescrption + "</summary>\n" +
"<author>" + author + "</author>\n" +
"<content type='" + mimeType.toString() + "'>" + encoder.encode(bytes) + "</content>\n" +
"<cmisra:object>\n"+
"<cmis:properties>\n" +
"<cmis:propertyId propertyDefinitionId=\"cmis:objectTypeId\">\n"+
"<cmis:value>D:hs:doc</cmis:value>\n"+
"</cmis:propertyId>\n" +
"<cmis:propertyId propertyDefinitionId=\"cmis:versionable\">\n"+
"<cmis:value>TRUE</cmis:value>\n"+
"</cmis:propertyId>\n" +
"</cmis:properties>\n" +
"</cmisra:object>\n" +
"</entry>\n";
how can i enable versioning using cmis rest .

I agree with Gagravarr that you will save yourself a lot of time and frustration by using one of the libraries available at http://chemistry.apache.org or some other source.
However, the answer to your question is that it sounds like you are trying to create a new object with the same name in the same folder as an existing object. Alfresco does not allow this, hence the error.
Instead, what you need to do is update the existing object. You are using the AtomPub Binding so if what you want to do is update the content stream, you can do a PUT on the content stream's URL.
If instead you are trying to update the properties, you can do a PUT on the object's URL.
This will change the object without creating a new version. If you instead want to create a new version, you need to check out the object (POST the object to the checked out collection) which will return the Private Working Copy (PWC). You can then set the content stream and update the properties on the PWC as noted above, then you can do a checkin. This will create a new version.
Note that if Alfresco hands you a change token you need to hand it back when performing these kinds of updates or you will get an update conflict exception.
If you need specifics on how to do any of this, read the spec. If you want a friendly API to do this rather than dealing with low-level AtomPub XML, PUTs, POSTs, and DELETEs, then grab a CMIS library.

Related

Is there any way to replace some part of code in Github repository dynamically?

I have a simple code on my Github repository that I want to make it changeable on the fly!
for example it's my code:
var name = "Reza";
alert("Hello " + name + "!");
my code is javascript and it will show an alert to the user Like "Hello Reza!" here.
I want to give some access to everyone to be able to change my code parameters before doing clone.
for example in my current code, I need to do something like this:
var name = {{your_name}};
alert("Hello " + name + "!");
And other users, should pass their name when they are sending their request to clone my project; then they will get cloned code customized by their name.
I want to know is there any way to do this using Github repository?

create change request of type "Risk" using OSLC-java client api

I am using eclipse lyo java api to create work item in RTC , I am able to create the work items of type task/defect using the below code:
CreationFactory taskCreation = client.lookupCreationFactoryResource(serviceProviderUrl,
OSLCConstants.OSLC_CM_V2, task.getRdfTypes()[0].toString(), OSLCConstants.OSLC_CM_V2 + "task");
CreationFactory taskCreation = client.lookupCreationFactoryResource(serviceProviderUrl,
OSLCConstants.OSLC_CM_V2, task.getRdfTypes()[0].toString(), OSLCConstants.OSLC_CM_V2 + "defect");
But I am unable to create the change request of type Risk, Please help

Is there any way to embed the GitHub Issue Tracker in a webpage?

I'd like to put it in the Progress section of my project's webpage. I tried using an iframe, and I tried using $.load(), but neither of these work.
Any ideas?
If you don't need all the feature from the native GitHub issues page, you could consider listing those issue to generate your own include/presentation.
See "possible to embed Github list of issues (with specific tag) on website?"
Kasper Souren proposes below in the comments the following fiddle:
var urlToGetAllOpenBugs = "https://api.github.com/repos/jquery/jquery/issues?state=open&labels=bug";
$(document).ready(function () {
$.getJSON(urlToGetAllOpenBugs, function (allIssues) {
$("div").append("found " + allIssues.length + " issues</br>");
$.each(allIssues, function (i, issue) {
$("div")
.append("<b>" + issue.number + " - " + issue.title + "</b></br>")
.append("created at: " + issue.created_at + "</br>")
.append(issue.body + "</br></br></br>");
});
});
});
Look at https://github.com/serverless/scope which is based on serverless configuration, uses Amazon DynamoDB framework and github webhook service to fetch issue stats (open, close, comment, labels, milestones, etc.) and pull requests. It's well documented and allows several configurations, including embedding to one's website. I have just tried it and works well so far!

GreenDAO really simple query

I want to create a very simple query to look up a sqlite db using greendao. 2 fields, one is the ID and the other 'affirmation'.
i am sorry to be such a beginner, but i am not sure how to use greendao including what to import etc.. All i have been able to do so far is add the greendao libraries but i cant find a good tutorial to just do a query. Basically i want it to be a random ID that calls up a random affirmation and return it to my main activity.. Once again i am sorry but i am really trying and getting nowhere..
Greendao is a ORM-framework. If you don't know what this means you should look up this first.
Greendao generally works as follows:
You create a java-project that generates your sourcecode for your real app. You have to include DaoCore and DaoGenerator in this project.
You add the generated sourcecode to your android-project and include DaoCore in it. DaoGemerator is not neccessary.
For examples how to generate the code and define your entities the greendao-website is a good place to go.
According to your description you need an entity with id-property and a string-property (affirmation).
In your android-project you then use the DevOpenHelper to get a session and from the session you can get the dao (Data Access Object) for your entity. The dao includes the very basic query to load data by id (load ()).
Please notice that the DevOpenHelper is only meant for development process. For your final release you should extend OpenHelper and costumize your actions to be taken on DB-schema update.
Here is some example code I have in my application.
DaoHelper.getInstance().getDaoSession().clear();
OperationDao dao = DaoHelper.getInstance().getDaoSession().getOperationDao();
String userId = "some id"
WhereCondition wc1 = new WhereCondition.PropertyCondition(OperationDao.Properties.UserId,
" = " + userId);
WhereCondition wc2 = new WhereCondition.PropertyCondition(OperationDao.Properties.Priority,
" > " + 4);
// Uncached is important if your data may have changed recently.
List<Operation> answer = dao.queryBuilder().where(wc1, wc2).listLazyUncached();
This is a decent tutorial on how to learn greendao. Make sure you follow the links to the further parts.
You can use:
daoMaster = new DaoMaster(db);
daoSession = daoMaster.newSession();
yourDao = daoSession.getYourDao();
Random() random = new Random();
List<YourObject> objects = yourDao.loadAll();
YourObject yourObject = objects.get(random.nextInt(objects.size());

Change name of generated Context file with EF PowerTools Reverse Engineer Code First

I have been attempting to figure out how to make the EF Power Tools - Reverse Engineer Code First use a different name for the generated Context-file, than what it uses now.
Example
I have a database called My_Awesome_Dev_Database. When I run Reverse-engineer against that, the file that is generated will be called:
My_Awesome_Dev_DatabaseContext.cs
What it would like to do is specify what the file is to be called, for instance:
MyAwesomeDatabaseContext.cs
Attempts so far
I have tried looking through the EF.Utilities.CS.ttinclude file, to figure out how the filename is generated - but I have been unsuccessful so far.
Does anyone know ?
Thanks in advance!
Currently the generated context file naming convention is hard-coded and non configurable.
All the logic is inside the ReverseEngineerCodeFirstHandler class (the source is on CodePlex).
It sets the context file name and path with
var contextFilePath = Path.Combine(modelsDirectory,
modelGenerator.EntityContainer.Name + contextHost.FileExtension);
var contextItem = project.AddNewFile(contextFilePath, contextContents);
So the file name is coming from modelGenerator.EntityContainer.Name which gets created upper in the method with:
var contextName =
connection.Database.Replace(" ", string.Empty)
.Replace(".", string.Empty) + "Context";
var modelGenerator =
new EntityModelSchemaGenerator(storeGenerator.EntityContainer,
"DefaultNamespace", contextName);
So as you can see the tool just takes the db name removes the spaces and dots and use it as the context name which will end up as the generated file name.
You can open an issue or - because Entity Framework is open source - take the code, add this configuration option, and send back a pull request.